Custom Chest Error



  • Bonjour,

    J'essaie de faire un coffre qui en ouvre un double simplement, quand je l'ouvre tout vas bien j'ai bien un double mais le jeu crash instantanément, bien embêtant, apreès maintes recherche je me dirige vers vous pour des explications plus détaillés peut etre  😄  !

    Voici mon TileEntityChestRuby :

    package com.mod.noyt.tileentity;
    
    import com.mod.noyt.blocks.BlockChestRuby;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockChest;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.tileentity.TileEntityChest;
    
    public class TileEntityChestRuby extends TileEntityChest
    {
    private String customName;
    private int cachedChestType;
    private ItemStack[] chestContents = new ItemStack[36];
    
        public TileEntityChestRuby adjacentChestZNeg;
    
        public TileEntityChestRuby adjacentChestXPos;
    
        public TileEntityChestRuby adjacentChestXNeg;
    
        public TileEntityChestRuby adjacentChestZPos;
    
        /**
         * Returns the name of the inventory
         */
        public String getInventoryName()
        {
            return this.hasCustomInventoryName() ? this.customName : "container.chest";
        }
    
        public int getSizeInventory()
        {
            return 54;
        }
    
        /**
         * Returns if the inventory is named
         */
        public boolean hasCustomInventoryName()
        {
            return this.customName != null && this.customName.length() > 0;
        }
    
        public void func_145976_a(String p_145976_1_)
        {
            this.customName = p_145976_1_;
        }
    
        public void readFromNBT(NBTTagCompound p_145839_1_)
        {
            super.readFromNBT(p_145839_1_);
            NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
            this.chestContents = new ItemStack[this.getSizeInventory()];
    
            if (p_145839_1_.hasKey("CustomName", 8))
            {
                this.customName = p_145839_1_.getString("CustomName");
            }
    
            for (int i = 0; i < nbttaglist.tagCount(); ++i)
            {
                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                int j = nbttagcompound1.getByte("Slot") & 255;
    
                if (j >= 0 && j < this.chestContents.length)
                {
                    this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                }
            }
        }
    
        public void writeToNBT(NBTTagCompound p_145841_1_)
        {
            super.writeToNBT(p_145841_1_);
            NBTTagList nbttaglist = new NBTTagList();
    
            for (int i = 0; i < this.chestContents.length; ++i)
            {
                if (this.chestContents* != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    nbttagcompound1.setByte("Slot", (byte)i);
                    this.chestContents*.writeToNBT(nbttagcompound1);
                    nbttaglist.appendTag(nbttagcompound1);
                }
            }
    
            p_145841_1_.setTag("Items", nbttaglist);
    
            if (this.hasCustomInventoryName())
            {
                p_145841_1_.setString("CustomName", this.customName);
            }
        }
    
        private void func_145978_a(TileEntityChest p_145978_1_, int p_145978_2_)
        {
            if (p_145978_1_.isInvalid())
            {
                this.adjacentChestChecked = false;
            }
            else if (this.adjacentChestChecked)
            {
                switch (p_145978_2_)
                {
                    case 0:
                        if (this.adjacentChestZPos != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }
    
                        break;
                    case 1:
                        if (this.adjacentChestXNeg != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }
    
                        break;
                    case 2:
                        if (this.adjacentChestZNeg != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }
    
                        break;
                    case 3:
                        if (this.adjacentChestXPos != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }
                }
            }
        }
    
        private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_)
        {
            if (this.worldObj == null)
            {
                return false;
            }
            else
            {
                Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_);
                return block instanceof BlockChestRuby && ((BlockChestRuby)block).field_149956_a == this.func_145980_j();
            }
        }
    
        public int func_145980_j()
        {
            if (this.cachedChestType == -1)
            {
                if (this.worldObj == null || !(this.getBlockType() instanceof BlockChestRuby))
                {
                    return 0;
                }
    
                this.cachedChestType = ((BlockChestRuby)this.getBlockType()).field_149956_a;
            }
    
            return this.cachedChestType;
        }
    
        public ItemStack getStackInSlot(int par1){
        return this.chestContents[par1];
        }
    
        public ItemStack decrStackSize(int par1, int par2)
        {
            if (this.chestContents[par1] != null)
            {
                ItemStack itemstack;
    
                if (this.chestContents[par1].stackSize <= par2)
                {
                    itemstack = this.chestContents[par1];
                    this.chestContents[par1] = null;
                    this.markDirty();
                    return itemstack;
                }
                else
                {
                    itemstack = this.chestContents[par1].splitStack(par2);
    
                    if (this.chestContents[par1].stackSize == 0)
                    {
                        this.chestContents[par1] = null;
                    }
    
                    this.markDirty();
                    return itemstack;
                }
            }
            else
            {
                return null;
            }
        }
    
        public ItemStack getStackInSlotOnClosing(int par1){
        if(this.chestContents[par1] != null){
        ItemStack itemstack = this.chestContents[par1];
        this.chestContents[par1] = null;
        return itemstack;
        }
        else{
        return null;
        }
        }
    
        public void setInventorySlotContents(int par1, ItemStack itemstack){
        this.chestContents[par1] = itemstack;
        if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){
        itemstack.stackSize = this.getInventoryStackLimit();
        }
        this.markDirty();
        }
    
        public int getInventoryStackLimit()
        {
            return 64;
        }
    
    }
    
    ``` 
    
    Et l'erreur affichée :
    
    ```java
    –-- Minecraft Crash Report ----
    // But it works on my machine.
    
    Time: 19/01/18 14:43
    Description: Ticking memory connection
    
    java.lang.ArrayIndexOutOfBoundsException: 36
    at com.mod.noyt.tileentity.TileEntityChestRuby.getStackInSlot(TileEntityChestRuby.java:169)
    at net.minecraft.inventory.Slot.getStack(Slot.java:88)
    at net.minecraft.inventory.Container.getInventory(Container.java:67)
    at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
    at net.minecraft.entity.player.EntityPlayerMP.displayGUIChest(EntityPlayerMP.java:726)
    at net.minecraft.block.BlockChest.onBlockActivated(BlockChest.java:427)
    at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
    at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
    at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
    at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Stacktrace:
    at com.mod.noyt.tileentity.TileEntityChestRuby.getStackInSlot(TileEntityChestRuby.java:169)
    at net.minecraft.inventory.Slot.getStack(Slot.java:88)
    at net.minecraft.inventory.Container.getInventory(Container.java:67)
    at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
    at net.minecraft.entity.player.EntityPlayerMP.displayGUIChest(EntityPlayerMP.java:726)
    at net.minecraft.block.BlockChest.onBlockActivated(BlockChest.java:427)
    at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
    at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
    at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
    at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
    
    -- Ticking connection --
    Details:
    Connection: net.minecraft.network.NetworkManager@75f85ef9
    Stacktrace:
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.10
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_151, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 822185792 bytes (784 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) 
    UCHIJAAAA Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) 
    UCHIJAAAA xr{1.0.0} [Noyt Mod] (bin) 
    GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Player Count: 1 / 8; [EntityPlayerMP['Player99'/274, l='New World', x=-242,50, y=69,00, z=-113,50]]
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    

    Merci de votre futur aide, si vous avez besoin de voir les autres classes pas de soucis mais je pense que le soucis viens d'ici  🙂 !


  • Moddeurs confirmés Rédacteurs Administrateurs

    Salut,
    Les demandes d'aides en rapport avec la programmation vont dans la section support pour les moddeurs.
    J'ai déplacé, merci de faire plus attention à l'avenir.

    Ton jeu crash car ton inventaire n'a que 36 slot alors que tu en as mis plus sur le container.



  • Ah d'accord mais comment faire dans ce cas car quand j'enleve cette ligne je n'ai que la moitié d'un coffre finalement ?


  • Moddeurs confirmés Rédacteurs Modérateurs Administrateurs

    Je sais pas, tu devrais peut être lire cette partie de ton code : ```java
    private ItemStack[] chestContents = new ItemStack[36];



  • Merci beaucoup sa a réglé mon problème c'étais tellement évident !

    Et aussi je n'arrive pas a poser 3 coffres a coté comme si je voulais poser un double coffre et un coffre simple à coté je vois vraiment pas pour ce coups ci, c'est dans la classe BlockChestRuby que ça se passe ?

    Merci !


  • Moddeurs confirmés Rédacteurs Administrateurs

    Dans le bloc et dans le tile entity, il faut retirer tout ce qui est en rapport avec les adjacents chest.



  • Bonjour,

    Si j'enlève tout les fonctions en rapport avec adjacents cela bug encore et rajoute un bug c'est qu'un des deux devient invisible 😕

    Cordialement.

    RubyChestRenderer :

    package com.mod.noyt.render.tileentity;
    
    import cpw.mods.fml.common.FMLLog;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import java.util.Calendar;
    import net.minecraft.block.Block;
    import net.minecraft.client.model.ModelChest;
    import net.minecraft.client.model.ModelLargeChest;
    import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.ResourceLocation;
    import org.lwjgl.opengl.GL11;
    import org.lwjgl.opengl.GL12;
    
    import com.mod.noyt.Reference;
    import com.mod.noyt.blocks.BlockChestRuby;
    import com.mod.noyt.tileentity.TileEntityChestRuby;
    
    @SideOnly(Side.CLIENT)
    public class RubyChestRenderer extends TileEntitySpecialRenderer
    {
        private static final ResourceLocation field_147504_g = new ResourceLocation(Reference.MOD_ID + ":textures/blocks/ruby_chest.png");
        private ModelChest field_147510_h = new ModelChest();
        private boolean field_147509_j;
    
        public RubyChestRenderer()
        {
            Calendar calendar = Calendar.getInstance();
    
            if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
            {
                this.field_147509_j = true;
            }
        }
    
        public void renderTileEntityAt(TileEntityChestRuby p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
        {
            int i;
    
            if (!p_147500_1_.hasWorldObj())
            {
                i = 0;
            }
            else
            {
                Block block = p_147500_1_.getBlockType();
                i = p_147500_1_.getBlockMetadata();
            }
    
            if (p_147500_1_.adjacentChestZNeg == null && p_147500_1_.adjacentChestXNeg == null)
            {
                ModelChest modelchest = this.field_147510_h;
                this.bindTexture(field_147504_g);
    
                GL11.glPushMatrix();
                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glTranslatef((float)p_147500_2_, (float)p_147500_4_ + 1.0F, (float)p_147500_6_ + 1.0F);
                GL11.glScalef(1.0F, -1.0F, -1.0F);
                GL11.glTranslatef(0.5F, 0.5F, 0.5F);
                short short1 = 0;
    
                if (i == 2)
                {
                    short1 = 180;
                }
    
                if (i == 3)
                {
                    short1 = 0;
                }
    
                if (i == 4)
                {
                    short1 = 90;
                }
    
                if (i == 5)
                {
                    short1 = -90;
                }
    
                GL11.glRotatef((float)short1, 0.0F, 1.0F, 0.0F);
                GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
                float f1 = p_147500_1_.prevLidAngle + (p_147500_1_.lidAngle - p_147500_1_.prevLidAngle) * p_147500_8_;
                float f2;
    
                f1 = 1.0F - f1;
                f1 = 1.0F - f1 * f1 * f1;
                modelchest.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F);
                modelchest.renderAll();
                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                GL11.glPopMatrix();
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            }
        }
    
        public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
        {
            this.renderTileEntityAt((TileEntityChestRuby)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_);
        }
    }
    

    TileEnityChestRuby :

    package com.mod.noyt.tileentity;
    
    import com.mod.noyt.blocks.BlockChestRuby;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockChest;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.tileentity.TileEntityChest;
    
    public class TileEntityChestRuby extends TileEntityChest
    {
    private String customName;
    private int cachedChestType;
    private ItemStack[] chestContents = new ItemStack[54];
    
        /**
         * Returns the name of the inventory
         */
        public String getInventoryName()
        {
            return this.hasCustomInventoryName() ? this.customName : "container.chest";
        }
    
        public int getSizeInventory()
        {
            return 54;
        }
    
        /**
         * Returns if the inventory is named
         */
        public boolean hasCustomInventoryName()
        {
            return this.customName != null && this.customName.length() > 0;
        }
    
        public void func_145976_a(String p_145976_1_)
        {
            this.customName = p_145976_1_;
        }
    
        public void readFromNBT(NBTTagCompound p_145839_1_)
        {
            super.readFromNBT(p_145839_1_);
            NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
            this.chestContents = new ItemStack[this.getSizeInventory()];
    
            if (p_145839_1_.hasKey("CustomName", 8))
            {
                this.customName = p_145839_1_.getString("CustomName");
            }
    
            for (int i = 0; i < nbttaglist.tagCount(); ++i)
            {
                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                int j = nbttagcompound1.getByte("Slot") & 255;
    
                if (j >= 0 && j < this.chestContents.length)
                {
                    this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                }
            }
        }
    
        public void writeToNBT(NBTTagCompound p_145841_1_)
        {
            super.writeToNBT(p_145841_1_);
            NBTTagList nbttaglist = new NBTTagList();
    
            for (int i = 0; i < this.chestContents.length; ++i)
            {
                if (this.chestContents* != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    nbttagcompound1.setByte("Slot", (byte)i);
                    this.chestContents*.writeToNBT(nbttagcompound1);
                    nbttaglist.appendTag(nbttagcompound1);
                }
            }
    
            p_145841_1_.setTag("Items", nbttaglist);
    
            if (this.hasCustomInventoryName())
            {
                p_145841_1_.setString("CustomName", this.customName);
            }
        }
    
        private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_)
        {
                Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_);
                return block instanceof BlockChestRuby && ((BlockChestRuby)block).field_149956_a == this.func_145980_j();
        }
    
        public int func_145980_j()
        {
            if (this.cachedChestType == -1)
            {
                if (this.worldObj == null || !(this.getBlockType() instanceof BlockChestRuby))
                {
                    return 0;
                }
    
                this.cachedChestType = ((BlockChestRuby)this.getBlockType()).field_149956_a;
            }
    
            return this.cachedChestType;
        }
    
        public ItemStack getStackInSlot(int par1){
        return this.chestContents[par1];
        }
    
        public ItemStack decrStackSize(int par1, int par2)
        {
            if (this.chestContents[par1] != null)
            {
                ItemStack itemstack;
    
                if (this.chestContents[par1].stackSize <= par2)
                {
                    itemstack = this.chestContents[par1];
                    this.chestContents[par1] = null;
                    this.markDirty();
                    return itemstack;
                }
                else
                {
                    itemstack = this.chestContents[par1].splitStack(par2);
    
                    if (this.chestContents[par1].stackSize == 0)
                    {
                        this.chestContents[par1] = null;
                    }
    
                    this.markDirty();
                    return itemstack;
                }
            }
            else
            {
                return null;
            }
        }
    
        public ItemStack getStackInSlotOnClosing(int par1){
        if(this.chestContents[par1] != null){
        ItemStack itemstack = this.chestContents[par1];
        this.chestContents[par1] = null;
        return itemstack;
        }
        else{
        return null;
        }
        }
    
        public void setInventorySlotContents(int par1, ItemStack itemstack){
        this.chestContents[par1] = itemstack;
        if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){
        itemstack.stackSize = this.getInventoryStackLimit();
        }
        this.markDirty();
        }
    
        public int getInventoryStackLimit()
        {
            return 64;
        }
    
    }
    
    

    BlockChestRuby :

    package com.mod.noyt.blocks;
    
    import static net.minecraftforge.common.util.ForgeDirection.DOWN;
    
    import java.util.Iterator;
    import java.util.Random;
    
    import com.mod.noyt.Reference;
    import com.mod.noyt.tileentity.TileEntityChestRuby;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockChest;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.passive.EntityOcelot;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.InventoryLargeChest;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.MathHelper;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class BlockChestRuby extends BlockChest
    {
    private final Random field_149955_b = new Random();
    
    public BlockChestRuby(int p_i45397_1_) 
    {
    super(p_i45397_1_);
    }
    
       /**
         * Called when the block is placed in the world.
         */
        public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
        {
            Block var7 = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ - 1);
            Block var8 = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ + 1);
            Block var9 = p_149689_1_.getBlock(p_149689_2_ - 1, p_149689_3_, p_149689_4_);
            Block var10 = p_149689_1_.getBlock(p_149689_2_ + 1, p_149689_3_, p_149689_4_);
            byte var11 = 0;
            int var12 = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    
            if (var12 == 0)
            {
                var11 = 2;
            }
    
            if (var12 == 1)
            {
                var11 = 5;
            }
    
            if (var12 == 2)
            {
                var11 = 3;
            }
    
            if (var12 == 3)
            {
                var11 = 4;
            }
    
            p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, var11, 0);
        }
    
        /**
         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
         * their own) Args: x, y, z, neighbor Block
         */
        public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
        {
            super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
            TileEntityChestRuby tileentitychest = (TileEntityChestRuby)p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_);
    
            if (tileentitychest != null)
            {
                tileentitychest.updateContainingBlockInfo();
            }
        }
    
        public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
        {
            TileEntityChestRuby tileentitychest = (TileEntityChestRuby)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
    
            if (tileentitychest != null)
            {
                for (int i1 = 0; i1 < tileentitychest.getSizeInventory(); ++i1)
                {
                    ItemStack itemstack = tileentitychest.getStackInSlot(i1);
    
                    if (itemstack != null)
                    {
                        float f = this.field_149955_b.nextFloat() * 0.8F + 0.1F;
                        float f1 = this.field_149955_b.nextFloat() * 0.8F + 0.1F;
                        EntityItem entityitem;
    
                        for (float f2 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem))
                        {
                            int j1 = this.field_149955_b.nextInt(21) + 10;
    
                            if (j1 > itemstack.stackSize)
                            {
                                j1 = itemstack.stackSize;
                            }
    
                            itemstack.stackSize -= j1;
                            entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                            float f3 = 0.05F;
                            entityitem.motionX = (double)((float)this.field_149955_b.nextGaussian() * f3);
                            entityitem.motionY = (double)((float)this.field_149955_b.nextGaussian() * f3 + 0.2F);
                            entityitem.motionZ = (double)((float)this.field_149955_b.nextGaussian() * f3);
    
                            if (itemstack.hasTagCompound())
                            {
                                entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                            }
                        }
                    }
                }
    
                p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
            }
    
            super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
        }
    
        public IInventory func_149951_m(World p_149951_1_, int p_149951_2_, int p_149951_3_, int p_149951_4_)
        {
            Object var5 = (TileEntityChestRuby)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_);
    
            if (var5 == null)
            {
                return null;
            }
            else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_ + 1, p_149951_4_).isNormalCube())
            {
                return null;
            }
            else if (func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_))
            {
                return null;
            }
            else if (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_ + 1, p_149951_4_).isNormalCube() || func_149953_o(p_149951_1_, p_149951_2_ - 1, p_149951_3_, p_149951_4_)))
            {
                return null;
            }
            else if (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_ + 1, p_149951_4_).isNormalCube() || func_149953_o(p_149951_1_, p_149951_2_ + 1, p_149951_3_, p_149951_4_)))
            {
                return null;
            }
            else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ - 1) == this && (p_149951_1_.getBlock(p_149951_2_, p_149951_3_ + 1, p_149951_4_ - 1).isNormalCube() || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ - 1)))
            {
                return null;
            }
            else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ + 1) == this && (p_149951_1_.getBlock(p_149951_2_, p_149951_3_ + 1, p_149951_4_ + 1).isNormalCube() || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ + 1)))
            {
                return null;
            }
    
            return (IInventory)var5;
    
        }
    
        private static boolean func_149953_o(World p_149953_0_, int p_149953_1_, int p_149953_2_, int p_149953_3_)
        {
            Iterator iterator = p_149953_0_.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox((double)p_149953_1_, (double)(p_149953_2_ + 1), (double)p_149953_3_, (double)(p_149953_1_ + 1), (double)(p_149953_2_ + 2), (double)(p_149953_3_ + 1))).iterator();
            EntityOcelot entityocelot;
    
            do
            {
                if (!iterator.hasNext())
                {
                    return false;
                }
    
                Entity entity = (Entity)iterator.next();
                entityocelot = (EntityOcelot)entity;
            }
            while (!entityocelot.isSitting());
    
            return true;
        }
    
        /**
         * Returns a new instance of a block's tile entity class. Called on placing the block.
         */
        public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
        {
            TileEntityChestRuby tileentitychest = new TileEntityChestRuby();
            return tileentitychest;
        }
    
        public boolean canProvidePower()
        {
            return this.field_149956_a == 1;
        }
    
        @SideOnly(Side.CLIENT)
        public void registerBlockIcons(IIconRegister p_149651_1_)
        {
            this.blockIcon = p_149651_1_.registerIcon(Reference.MOD_ID + ":ruby_chest");
        }
    
    }
    

  • Moddeurs confirmés Rédacteurs Administrateurs

    Retires cette condition dans le rendu :

    if (p_147500_1_.adjacentChestZNeg == null && p_147500_1_.adjacentChestXNeg == null)
    {
    

    Sinon le tutoriel sur le container du forum explique comment faire un coffre sans double coffre.



  • Voila et toujours la meme erreur en ajoutant que on ne voit plus aucun rendu 😕

    package com.mod.xenoria.render.tileentity;
    
    import cpw.mods.fml.common.FMLLog;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import java.util.Calendar;
    import net.minecraft.block.Block;
    import net.minecraft.client.model.ModelChest;
    import net.minecraft.client.model.ModelLargeChest;
    import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.ResourceLocation;
    import org.lwjgl.opengl.GL11;
    import org.lwjgl.opengl.GL12;
    
    import com.mod.xenoria.Reference;
    import com.mod.xenoria.blocks.BlockChestRuby;
    import com.mod.xenoria.tileentity.TileEntityChestRuby;
    
    @SideOnly(Side.CLIENT)
    public class RubyChestRenderer extends TileEntitySpecialRenderer
    {
        private static final ResourceLocation field_147504_g = new ResourceLocation(Reference.MOD_ID + ":textures/blocks/ruby_chest.png");
        private ModelChest field_147510_h = new ModelChest();
        private boolean field_147509_j;
    
        public RubyChestRenderer()
        {
            Calendar calendar = Calendar.getInstance();
    
            if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
            {
                this.field_147509_j = true;
            }
        }
    
        public void renderTileEntityAt(TileEntityChestRuby p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
        {
            int i;
    
            if (!p_147500_1_.hasWorldObj())
            {
                i = 0;
            }
            else
            {
                Block block = p_147500_1_.getBlockType();
                i = p_147500_1_.getBlockMetadata();
            }
        }
    
        public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
        {
            this.renderTileEntityAt((TileEntityChestRuby)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_);
        }
    }
    

    Re,

    J'ai régler mon problème en mettant BlockContainer au lieu de BlockChest mais maintenant j'ai un autre soucis le coffre ne se referme pas, quelle classe gère sa ? (une fois le coffre quitter le coffre reste ouver)

    Cordialement


  • Moddeurs confirmés Rédacteurs Administrateurs

    Il fallait retirer la condition (et toujours exécuter le code qu'il avait dedans) pas retirer la condition + le code qu'elle contenait.

    Pour l'animation ce sont les fonctions openInventory et closeInventory qui gère ça.
    https://www.minecraftforgefrance.fr/showthread.php?tid=2082
    https://www.minecraftforgefrance.fr/showthread.php?tid=2559


Log in to reply