MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Créer un bloc type four (machine)

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.7.10
    236 Messages 39 Publieurs 69.0k Vues 15 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • S Hors-ligne
      Sleindarfeau
      dernière édition par

      Up. Personne ne voit ?

      1 réponse Dernière réponse Répondre Citer 0
      • SCAREXS Hors-ligne
        SCAREX
        dernière édition par

        Envoi les sources, j’essaierai de tester de mon côté

        Site web contenant mes scripts : http://SCAREXgaming.github.io

        Pas de demandes de support par MP ni par skype SVP.
        Je n'accepte sur skype que l…

        1 réponse Dernière réponse Répondre Citer 0
        • FolganskyF Hors-ligne
          Folgansky Correcteurs
          dernière édition par

          Salutations les gens,

          Ce tuto me tentait bien, d’avoir une machine à proposer pour mon serveur, mais je n’avais pas encore d’idée d’application.

          Ceci étant fait (Edit: je vais bien sûr changer la texture du GUI par la suite, je cherche déjà à prendre le truc en main), j’ai un petit soucis et une question dans tout ça.

          Tout d’abord les slots de l’inventaire du joueur s’affichent trop bas et je me demandais où régler ça svp.

          :::
          (http://img15.hostingpics.net/pics/487544MachineStupGUI.png)
          :::

          Ensuite ma petite question était de savoir si il était possible d’avoir un rendu custom sur un tel bloc. Model Techne toussah toussah.

          Merci pour l’attention que vous aurez porté à ce message les gens.

          1 réponse Dernière réponse Répondre Citer 0
          • SCAREXS Hors-ligne
            SCAREX
            dernière édition par

            Pour la position des slots : La position est gérée dans le container avec this.addSlotToContainer

            Pour les models techne : Il y a un tutoriel là-dessus sur le forum

            Site web contenant mes scripts : http://SCAREXgaming.github.io

            Pas de demandes de support par MP ni par skype SVP.
            Je n'accepte sur skype que l…

            1 réponse Dernière réponse Répondre Citer 0
            • FolganskyF Hors-ligne
              Folgansky Correcteurs
              dernière édition par

              @‘SCAREX’:

              Pour la position des slots : La position est gérée dans le container avec this.addSlotToContainer

              Pour les models techne : Il y a un tutoriel là-dessus sur le forum

              Merci bien pour la position des slots.

              Pour le model custom j’en ai déjà fait, je me demandais simplement si ça ne posait pas de soucis avec la fonction du bloc. Vu que tu ne soulèves pas ce point, je vais m’y pencher plus en détail en pensant à un “bah non suffit de le faire” 😃

              1 réponse Dernière réponse Répondre Citer 0
              • Z Hors-ligne
                ZephyrinGames
                dernière édition par

                Bonjour, je n’arrive pas a fusionner mon GuiHandler pouvez vous m’aider SVP

                Code de mon GuiHandler

                package fr.modchelou.common;
                
                import cpw.mods.fml.common.network.IGuiHandler;
                import fr.modchelou.client.gui.GuiBackPack;
                import fr.modchelou.common.gui.ContainerBackPack;
                import fr.modchelou.common.inventory.InventoryBackPack;
                import fr.modchelou.items.ItemBackPack;
                import net.minecraft.entity.player.EntityPlayer;
                import net.minecraft.world.World;
                
                public class GuiHandler implements IGuiHandler
                {
                
                   @Override
                   public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                   {
                       switch (ID)
                       {
                           case 0:
                               if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;
                               return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));
                       }
                       return null;
                
                   }
                
                   @Override
                   public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                   {
                       switch (ID)
                       {
                           case 0:
                               if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;
                               return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));            
                       }
                       return null;
                   }
                
                }
                
                1 réponse Dernière réponse Répondre Citer 0
                • robin4002R Hors-ligne
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                  dernière édition par

                  à fusionner ? C’est à dire ?

                  1 réponse Dernière réponse Répondre Citer 0
                  • Z Hors-ligne
                    ZephyrinGames
                    dernière édition par

                    en fait c’est bon je l’ai fix ( j’ai récup le code d’un autre mod et copié ici )___par contre je n’arrive pas a ouvrir mon Gui aidez-moi plz

                    1 réponse Dernière réponse Répondre Citer 0
                    • robin4002R Hors-ligne
                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                      dernière édition par

                      Ça serait bien d’avoir le code concerné.
                      On ne peut pas deviner d’où vient le problème.

                      1 réponse Dernière réponse Répondre Citer 0
                      • Z Hors-ligne
                        ZephyrinGames
                        dernière édition par

                        Ok je l’envoie

                        Classe du Gui

                        :::

                        package fr.modchelou.client.gui;
                        
                        import org.lwjgl.opengl.GL11;
                        
                        import fr.modchelou.Ref;
                        import fr.modchelou.common.gui.ContainerEuropiumMachine;
                        import fr.modchelou.tiles.TileEntityEuropiumMachine;
                        import net.minecraft.client.gui.inventory.GuiContainer;
                        import net.minecraft.client.resources.I18n;
                        import net.minecraft.entity.player.InventoryPlayer;
                        import net.minecraft.inventory.Container;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.util.ResourceLocation;
                        
                        public class GuiEuropiumMachine extends GuiContainer
                        {
                        
                            private static final ResourceLocation texture = new ResourceLocation("chelou:textures/gui/guiEuropiumMachine.png");
                        
                            private TileEntityEuropiumMachine tileEuropiumMachine;
                            private IInventory playerInv;
                            public GuiEuropiumMachine(TileEntityEuropiumMachine tile, InventoryPlayer inventory)
                            {
                                super(new ContainerEuropiumMachine(tile, inventory));
                                this.tileEuropiumMachine = tile;
                                this.playerInv = inventory;
                                this.allowUserInput = false;
                                this.ySize = 256;
                                this.xSize = 256;
                            }
                        
                            @Override
                            protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                            {
                        
                                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                this.mc.getTextureManager().bindTexture(texture);
                                int k = (this.width - this.xSize) / 2;
                                int l = (this.height - this.ySize) / 2;
                                this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                                this.drawTexturedModalRect(0, 0, 176, 14, 100 + 1, 16);
                        
                            }
                        
                            protected void drawGuiContainerForegroundLayer(int x, int y)
                            {
                                this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752);
                            }
                        

                        :::

                        La classe du GuiHandler

                        :::

                        package fr.modchelou.common;
                        
                        import cpw.mods.fml.common.network.IGuiHandler;
                        import fr.modchelou.client.gui.GuiBackPack;
                        import fr.modchelou.client.gui.GuiEuropiumMachine;
                        import fr.modchelou.common.gui.ContainerBackPack;
                        import fr.modchelou.common.gui.ContainerEuropiumMachine;
                        import fr.modchelou.common.inventory.InventoryBackPack;
                        import fr.modchelou.items.ItemBackPack;
                        import fr.modchelou.tiles.TileEntityEuropiumMachine;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.world.World;
                        
                        public class GuiHandler implements IGuiHandler
                        {
                        
                            @Override
                            public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                            {
                                switch (ID)
                                {
                                    case 0:
                                        if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;//backpack
                                        return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));//backpack
                                    case 1:
                                        return new ContainerEuropiumMachine((TileEntityEuropiumMachine)world.getTileEntity(x, y, z), player.inventory);//Le block en question
                                }
                                return null;
                        
                            }
                        
                            @Override
                            public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                            {
                                switch (ID)
                                {
                                    case 0:
                                        if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;//backpack
                                        return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));//backpack
                                    case 1:
                                        return new GuiEuropiumMachine((TileEntityEuropiumMachine)world.getTileEntity(x, y, z), player.inventory);//Le block en question
                                }
                                return null;
                            }
                        
                        }
                        

                        :::

                        La classe du Container

                        :::

                        package fr.modchelou.common.gui;
                        
                        import fr.modchelou.common.slot.SlotResult;
                        import fr.modchelou.tiles.TileEntityEuropiumMachine;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.entity.player.InventoryPlayer;
                        import net.minecraft.inventory.Container;
                        import net.minecraft.inventory.Slot;
                        import net.minecraft.item.ItemStack;
                        
                        public class ContainerEuropiumMachine extends Container
                        {
                            private TileEntityEuropiumMachine tileEuropiumMachine;
                        
                            public ContainerEuropiumMachine(TileEntityEuropiumMachine tile, InventoryPlayer inventory)
                                {
                                    this.tileEuropiumMachine = tile;
                                    this.addSlotToContainer(new Slot(tile, 0, 52, 93));
                                    this.addSlotToContainer(new Slot(tile, 1, 34, 122));
                                    this.addSlotToContainer(new Slot(tile, 2, 88, 94));
                                    this.addSlotToContainer(new Slot(tile, 3, 142, 122));
                                    this.addSlotToContainer(new Slot(tile, 4, 124, 93));
                                    this.addSlotToContainer(new SlotResult(tile, 5, 88, 145));
                                    this.bindPlayerInventory(inventory);
                                }
                        
                            @Override
                                public boolean canInteractWith(EntityPlayer player) {
                                    return this.tileEuropiumMachine.isUseableByPlayer(player);
                                }
                        
                                private void bindPlayerInventory(InventoryPlayer inventory)
                                {
                                    int i;
                                    for (i = 0; i < 3; ++i)
                                    {
                                        for (int j = 0; j < 9; ++j)
                                        {
                                            this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18));
                                        }
                                    }
                        
                                    for (i = 0; i < 9; ++i)
                                    {
                                        this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229));
                                    }
                                }
                        
                                public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
                                {
                                    ItemStack itemstack = null;
                                    Slot slot = (Slot)this.inventorySlots.get(quantity);
                        
                                    if (slot != null && slot.getHasStack())
                                    {
                                        ItemStack itemstack1 = slot.getStack();
                                        itemstack = itemstack1.copy();
                        
                                        if (quantity < this.tileEuropiumMachine.getSizeInventory())
                                        {
                                            if (!this.mergeItemStack(itemstack1, this.tileEuropiumMachine.getSizeInventory(), this.inventorySlots.size(), true))
                                            {
                                                return null;
                                            }
                                        }
                                        else if (!this.mergeItemStack(itemstack1, 0, this.tileEuropiumMachine.getSizeInventory(), false))
                                        {
                                            return null;
                                        }
                        
                                        if (itemstack1.stackSize == 0)
                                        {
                                            slot.putStack((ItemStack)null);
                                        }
                                        else
                                        {
                                            slot.onSlotChanged();
                                        }
                                    }
                        
                                    return itemstack;
                                }
                        
                                public void onContainerClosed(EntityPlayer player)
                                {
                                    super.onContainerClosed(player);
                                    this.tileEuropiumMachine.closeInventory();
                                }
                        
                        }
                        

                        :::

                        La classe du Block

                        :::

                        package fr.modchelou.blocks;
                        
                        import fr.modchelou.ChelouPrincipal;
                        import fr.modchelou.Ref;
                        import fr.modchelou.tiles.TileEntityEuropiumMachine;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.BlockContainer;
                        import net.minecraft.block.material.Material;
                        import net.minecraft.creativetab.CreativeTabs;
                        import net.minecraft.entity.item.EntityItem;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.nbt.NBTTagCompound;
                        import net.minecraft.tileentity.TileEntity;
                        import net.minecraft.world.World;
                        
                        public class BlockEuropiumMachine extends BlockContainer
                        {
                            public BlockEuropiumMachine()
                            {
                                super(Material.rock);
                                this.setResistance(8.0F);
                                this.setHarvestLevel("pickaxe", 2);
                                this.setBlockTextureName(Ref.MOD_ID + ":EuropiumMachine");
                                this.setCreativeTab(CreativeTabs.tabRedstone);
                            }
                            @Override
                                public TileEntity createNewTileEntity(World world, int metadata)
                                {
                                    return new TileEntityEuropiumMachine();
                                }
                        
                                @Override
                                public boolean hasTileEntity(int metadata)
                                {
                                    return true;
                                }
                        
                                public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                {
                                    TileEntity tileentity = world.getTileEntity(x, y, z);
                        
                                           if (tileentity instanceof IInventory)
                                           {
                                               IInventory inv = (IInventory)tileentity;
                                               for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                                               {
                                                   ItemStack itemstack = inv.getStackInSlot(i1);
                        
                                                   if (itemstack != null)
                                                   {
                                                       float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                                       float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                       EntityItem entityitem;
                        
                                                       for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                                       {
                                                           int j1 = world.rand.nextInt(21) + 10;
                        
                                                           if (j1 > itemstack.stackSize)
                                                           {
                                                               j1 = itemstack.stackSize;
                                                           }
                        
                                                           itemstack.stackSize -= j1;
                                                           entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2));
                                                           float f3 = 0.05F;
                                                           entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                                                           entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                                                           entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                        
                                                           if (itemstack.hasTagCompound())
                                                           {
                                                               entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                           }
                                                       }
                                                   }
                                               }
                        
                                           world.func_147453_f(x, y, z, block);
                                       }
                        
                                    super.breakBlock(world, x, y, z, block, metadata);
                                }
                        
                                public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
                                {
                                    if(world.isRemote)
                                    {
                                        return true;
                                    }
                                        else
                                    {
                                        player.openGui(ChelouPrincipal.instance, 0, world, x, y, z);
                                        return true;
                                    }
                            }
                        }
                        

                        :::

                        La classe d’init des Blocks

                        :::

                        package fr.modchelou.blocks;
                        
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import net.minecraft.block.Block;
                        
                        public class ModBlocks
                        {
                            public static Block EuropiumMachine;
                        
                            public static void init()
                            {
                              EuropiumMachine = new BlockEuropiumMachine().setBlockName("EuropiumMachine");
                        
                              GameRegistry.registerBlock(EuropiumMachine, "EuropiumMachine");
                            }
                        
                        }
                        

                        :::

                        la classe d’init des TileEntity

                        :::

                        package fr.modchelou.tiles;
                        
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import fr.modchelou.Ref;
                        
                        public class ModTiles
                        {
                            public static void init()
                            {
                                GameRegistry.registerTileEntity(TileEntityEuropiumMachine.class, "chelou:EuropiumMachineTileEntity");
                            }
                        }
                        

                        :::

                        La classe du TileEntity

                        :::

                        package fr.modchelou.tiles;
                        
                        import fr.modchelou.recipes.EuropiumMachineRecipes;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.nbt.NBTTagCompound;
                        import net.minecraft.nbt.NBTTagList;
                        import net.minecraft.tileentity.TileEntity;
                        
                        public class TileEntityEuropiumMachine extends TileEntity implements IInventory
                        {
                            private ItemStack[] contents = new ItemStack[6];
                            private int workingTime = 0;
                            private int workingTimeNeeded = 200;
                        
                            @Override
                            public void readFromNBT(NBTTagCompound compound)
                            {
                                super.readFromNBT(compound);
                        
                                NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                this.contents = new ItemStack[this.getSizeInventory()];
                                for (int i = 0; i < nbttaglist.tagCount(); ++i)
                                        {
                                            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                            int j = nbttagcompound1.getByte("Slot") & 255;
                        
                                            if (j >= 0 && j < this.contents.length)
                                            {
                                                this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                            }
                                        }
                        
                                        this.workingTime = compound.getShort("workingTime");
                                        this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                                    }
                        
                                   @Override
                                   public int getSizeInventory() {
                                       return this.contents.length;
                                   }
                        
                                   @Override
                                   public ItemStack getStackInSlot(int slotIndex) {
                                       return this.contents[slotIndex];
                                   }
                        
                                   @Override
                                   public ItemStack decrStackSize(int slotIndex, int amount) {
                                        if (this.contents[slotIndex] != null)
                                           {
                                               ItemStack itemstack;
                        
                                               if (this.contents[slotIndex].stackSize <= amount)
                                               {
                                                   itemstack = this.contents[slotIndex];
                                                   this.contents[slotIndex] = null;
                                                   this.markDirty();
                                                   return itemstack;
                                               }
                                               else
                                               {
                                                   itemstack = this.contents[slotIndex].splitStack(amount);
                        
                                                   if (this.contents[slotIndex].stackSize == 0)
                                                   {
                                                       this.contents[slotIndex] = null;
                                                   }
                        
                                                   this.markDirty();
                                                   return itemstack;
                                               }
                                           }
                                           else
                                           {
                                               return null;
                                           }
                                   }
                        
                                 @Override
                                    public ItemStack getStackInSlotOnClosing(int slotIndex) {
                                        if (this.contents[slotIndex] != null)
                                        {
                                            ItemStack itemstack = this.contents[slotIndex];
                                            this.contents[slotIndex] = null;
                                            return itemstack;
                                        }
                                        else
                                        {
                                            return null;
                                        }
                                   }
                        
                                @Override
                                   public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                                      this.contents[slotIndex] = stack;
                        
                                        if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                        {
                                            stack.stackSize = this.getInventoryStackLimit();
                                        }
                        
                                        this.markDirty();
                                   }
                        
                                @Override
                                   public String getInventoryName() {
                                       return "tile.machineTuto";
                                   }
                        
                                @Override
                                   public boolean hasCustomInventoryName() {
                                       return false;
                                   }
                        
                                @Override
                                   public int getInventoryStackLimit() {
                                       return 64;
                                   }
                        
                                @Override
                                   public boolean isUseableByPlayer(EntityPlayer player) {
                                       return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
                                   }
                        
                                @Override
                                   public void openInventory() {
                        
                                   }
                        
                                @Override
                                   public void closeInventory() {
                        
                                   }
                        
                                @Override
                                   public boolean isItemValidForSlot(int slot, ItemStack stack) {
                                       return slot == 3 ? false : true;    
                                   }
                        
                                   public boolean isBurning()
                                    {
                                       return this.workingTime > 0;
                                   }
                        
                                   private boolean canSmelt()
                                    {
                                        if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null || this.contents[3] == null || this.contents[4] == null || this.contents[5] == null)
                                        {
                                            return false;
                                        }
                                        else
                                        {
                                            ItemStack itemstack = EuropiumMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]});
                                            if (itemstack == null) return false;
                                            if (this.contents[3] == null) return true;
                                            if (!this.contents[3].isItemEqual(itemstack)) return false;
                                            int result = contents[3].stackSize + itemstack.stackSize;
                                            return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize();
                                        }
                                    }
                        
                                   public void updateEntity()
                                    {
                                       if(this.isBurning() && this.canSmelt())
                                       {
                                               ++this.workingTime;
                                       }
                                       if(this.canSmelt() && !this.isBurning())
                                       {
                                           this.workingTime = 1;
                                       }
                                       if(this.canSmelt() && this.workingTime == this.workingTimeNeeded)
                                       {
                                           this.smeltItem();
                                           this.workingTime = 0;
                                       }
                                        if(!this.canSmelt())
                                        {
                                                   this.workingTime= 0;
                                        }
                                    }
                        
                                   public void smeltItem()
                                    {
                                        if (this.canSmelt())
                                        {
                                            ItemStack itemstack = EuropiumMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]});
                                             if (this.contents[3] == null)
                                             {
                                                      this.contents[3] = itemstack.copy();
                                             }
                                             else if (this.contents[3].getItem() == itemstack.getItem())
                                             {
                                                      this.contents[3].stackSize += itemstack.stackSize;
                                             }
                        
                                             –this.contents[0].stackSize;
                                             –this.contents[1].stackSize;
                                             –this.contents[2].stackSize;
                        
                                             if (this.contents[0].stackSize <= 0)
                                             {
                                                 this.contents[0] = null;
                                             }
                                             if (this.contents[1].stackSize <= 0)
                                             {
                                                 this.contents[1] = null;
                                             }
                                             if (this.contents[2].stackSize <= 0)
                                             {
                                                 this.contents[2] = null;
                                             }
                                             if (this.contents[3].stackSize <= 0)
                                             {
                                                 this.contents[3] = null;
                                             }
                                             if (this.contents[4].stackSize <= 0)
                                             {
                                                 this.contents[4] = null;
                                             }
                                             if (this.contents[5].stackSize <= 0)
                                             {
                                                 this.contents[5] = null;
                                             }
                        
                                        }
                                    }
                        
                        }
                        

                        :::

                        La classe du SlotResult

                        :::

                        package fr.modchelou.common.slot;
                        
                        import fr.modchelou.tiles.TileEntityEuropiumMachine;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.inventory.Slot;
                        import net.minecraft.item.ItemStack;
                        
                        public class SlotResult extends Slot
                        {
                        
                                public SlotResult(IInventory inventory, int id, int x, int y)
                                {
                                    super(inventory, id, x, y);
                                }
                        
                                @Override
                                public boolean isItemValid(ItemStack stack)
                                {
                                    return false;
                                }
                        
                                public ItemStack decrStackSize(int amount)
                                {
                                    return super.decrStackSize(amount);
                                }
                        
                                public void onPickupFromSlot(EntityPlayer player, ItemStack stack)
                                {
                                    super.onCrafting(stack);
                                    super.onPickupFromSlot(player, stack);
                                }
                        
                            }
                        

                        :::

                        La classe Principale
                        :::

                        package fr.modchelou;
                        
                        import cpw.mods.fml.common.Mod;
                        import cpw.mods.fml.common.Mod.EventHandler;
                        import cpw.mods.fml.common.Mod.Instance;
                        import cpw.mods.fml.common.SidedProxy;
                        import cpw.mods.fml.common.event.FMLInitializationEvent;
                        import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                        import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                        import cpw.mods.fml.common.network.NetworkRegistry;
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import cpw.mods.fml.relauncher.Side;
                        import cpw.mods.fml.relauncher.SideOnly;
                        import fr.modchelou.blocks.ModBlocks;
                        import fr.modchelou.common.CommonProxy;
                        import fr.modchelou.common.GuiHandler;
                        import fr.modchelou.items.ModItems;
                        import fr.modchelou.tiles.ModTiles;
                        import net.minecraft.creativetab.CreativeTabs;
                        import net.minecraft.item.Item;
                        
                        @Mod(modid = Ref.MOD_ID, name = Ref.MOD_NAME, version = Ref.VERSION)
                        
                        public class ChelouPrincipal
                        {
                            @Instance(Ref.MOD_ID)
                            public static ChelouPrincipal instance;
                        
                            @SidedProxy(clientSide = Ref.CLIENT_PROXY, serverSide = Ref.SERVER_PROXY)
                            public static CommonProxy proxy;
                        
                            @EventHandler
                            public void preInit(FMLPreInitializationEvent event)
                            {
                              ModTiles.init();
                              ModBlocks.init();
                              ModItems.init();
                            }
                        
                            @EventHandler
                            public void init(FMLInitializationEvent event)
                            {
                                proxy.registerRenders();
                                NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
                            }
                        
                            @EventHandler
                            public void postInit(FMLPostInitializationEvent event)
                            {
                        
                            }
                        }
                        

                        :::

                        Ma clase de References

                        :::

                        package fr.modchelou;
                        
                        public class Ref
                        {
                            public static final String MOD_ID = "chelou";
                            public static final String MOD_NAME = "Mod CHELOU";
                            public static final String VERSION = "beta 0.0.1";
                            public static final String CLIENT_PROXY = "fr.modchelou.client.ClientProxy";
                            public static final String SERVER_PROXY = "fr.modchelou.common.CommonProxy";
                        }
                        

                        :::

                        Et enfin la classe des Recipes

                        :::

                        package fr.modchelou.recipes;
                        
                        import java.util.HashMap;
                        import java.util.Iterator;
                        import java.util.Map;
                        import java.util.Map.Entry;
                        
                        import fr.modchelou.items.ModItems;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.BlockChest;
                        import net.minecraft.init.Blocks;
                        import net.minecraft.init.Items;
                        import net.minecraft.item.Item;
                        import net.minecraft.item.ItemStack;
                        
                        public class EuropiumMachineRecipes
                        {
                            private static final EuropiumMachineRecipes smeltingBase = new EuropiumMachineRecipes();
                                private Map smeltingList = new HashMap();
                        
                                public EuropiumMachineRecipes()
                                    {
                                        this.addRecipe(Items.leather, Items.leather, Items.string, Items.leather, Items.leather, new ItemStack(ModItems.backpack));
                                    }
                        
                                public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack4, ItemStack stack5, ItemStack stack6)
                                    {
                                        ItemStack[] stackList = new ItemStack[]{stack1, stack2, };
                                        this.smeltingList.put(stackList, stack4);
                                    }
                        
                                        public void addRecipe(Item item1, Item item2, Item item3, Item item4, Item item5, ItemStack stack) //1er cas
                                    {
                                        this.addRecipe(item1, item2, item3, item4, item5, stack);
                                    }
                        
                                    public void addRecipe(Block block1, Item item2, Item item3, Item item4, Item item5, ItemStack stack) //2nd cas
                                    {
                                        this.addRecipe(Item.getItemFromBlock(block1), item2, item3, item4, item5, stack);
                                    }
                        
                                    public void addRecipe(Block block1, Block block2, Item item3, Item item4, Item item5, ItemStack stack) //3ème cas
                                    {
                                        this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, item4, item5, stack);
                                    }
                        
                                    public void addRecipe(Block block1, Block block2, Block block3, Item item4, Item item5, ItemStack stack) //4ème cas
                                    {
                                        this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), item4, item5, stack);
                                    }
                        
                                    public void addRecipe(Block block1, Block block2, Block block3, Block block4, Item item5, ItemStack stack) //5ème cas
                                    {
                                        this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), Item.getItemFromBlock(block4), item5, stack);
                                    }
                        
                                    public void addRecipe(Block block1, Block block2, Block block3, Block block4, Block block5, ItemStack stack) //6ème cas
                                    {
                                        this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), Item.getItemFromBlock(block4), Item.getItemFromBlock(block5), stack);
                                    }     
                        
                                    public ItemStack getSmeltingResult(ItemStack[] stack)
                                         {
                                             Iterator iterator = this.smeltingList.entrySet().iterator();
                                             Entry entry;
                        
                                             do
                                             {
                                                 if (!iterator.hasNext())
                                                 {
                                                     return null;
                                                 }
                                                entry = (Entry)iterator.next();
                                            }
                                            while (!this.isSameKey(stack, (ItemStack[])entry.getKey()));
                        
                                            return (ItemStack)entry.getValue();
                                          }
                        
                                    private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
                                         {
                                             boolean isSame = false;
                                             for(int i=0; i<=2; i++)
                                             {
                                                 if(stackList*.getItem() == stackList2*.getItem())
                                                 {
                                                     isSame = true;
                                                 }
                                                 else
                                                 {
                                                     return false;
                                                 }
                                             }
                                             return isSame;
                                         }
                        
                                    public Map getSmeltingList()
                                         {
                                            return this.smeltingList;
                                         }
                        
                                    public static EuropiumMachineRecipes smelting()
                                        {
                                            return smeltingBase;
                                        }
                        
                        }
                        

                        :::

                        Voila j’ai terminé surtout n’héstez pas a me redemander d’autres classes!

                        PS: Vu que j’avais peu de temps pour le faire j’ai fait du copier-coller du tuto donc faites juste des citations de ce que je dois changer!!!

                        1 réponse Dernière réponse Répondre Citer 0
                        • robin4002R Hors-ligne
                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                          dernière édition par

                          la ligne suivante dans onBlockActivated dans la classe BlockEuropiumMachine
                                         player.openGui(ChelouPrincipal.instance, 0, world, x, y, z);
                          devait être :
                                         player.openGui(ChelouPrincipal.instance, 1, world, x, y, z);

                          pour être cohérent avec ton gui handler.

                          1 réponse Dernière réponse Répondre Citer 0
                          • Z Hors-ligne
                            ZephyrinGames
                            dernière édition par

                            mrc je teste tds___c’est bon mrc bcp

                            1 réponse Dernière réponse Répondre Citer 0
                            • robin4002R Hors-ligne
                              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                              dernière édition par

                              Attention aux doubles posts.
                              Je fusionne.

                              1 réponse Dernière réponse Répondre Citer 0
                              • Z Hors-ligne
                                ZephyrinGames
                                dernière édition par

                                Bonjour j’ai encore un bug et je m’en remet a vous, ma barre de progression ne s’affiche pas et mes recettes ne s’enregistrent pas:

                                la classe du CommonProxy:

                                :::

                                package fr.modchelou.common;
                                
                                import cpw.mods.fml.common.event.FMLInitializationEvent;
                                import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                                import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                                import cpw.mods.fml.common.network.NetworkRegistry;
                                import fr.modchelou.ChelouPrincipal;
                                import fr.modchelou.blocks.ModBlocks;
                                import fr.modchelou.items.ModItems;
                                import fr.modchelou.recipes.ModRecipes;
                                import fr.modchelou.tiles.ModTiles;
                                
                                public class CommonProxy
                                {
                                
                                    public void preInit(FMLPreInitializationEvent event)
                                    {
                                
                                    }
                                
                                    public void init(FMLInitializationEvent event)
                                    {
                                        ModTiles.init();
                                        ModBlocks.init();
                                        ModItems.init();
                                        ModRecipes.init();
                                
                                        NetworkRegistry.INSTANCE.registerGuiHandler(ChelouPrincipal.instance, new GuiHandler());
                                    }
                                
                                    public void postInit(FMLPostInitializationEvent event)
                                    {
                                
                                    }
                                
                                    public void registerRenders()
                                    {
                                
                                    }
                                }
                                

                                :::

                                La classe Principale:

                                :::

                                package fr.modchelou;
                                
                                import cpw.mods.fml.common.Mod;
                                import cpw.mods.fml.common.Mod.EventHandler;
                                import cpw.mods.fml.common.Mod.Instance;
                                import cpw.mods.fml.common.SidedProxy;
                                import cpw.mods.fml.common.event.FMLInitializationEvent;
                                import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                                import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                                import cpw.mods.fml.common.network.NetworkRegistry;
                                import cpw.mods.fml.common.registry.GameRegistry;
                                import cpw.mods.fml.relauncher.Side;
                                import cpw.mods.fml.relauncher.SideOnly;
                                import fr.modchelou.blocks.ModBlocks;
                                import fr.modchelou.common.CommonProxy;
                                import fr.modchelou.common.GuiHandler;
                                import fr.modchelou.items.ModItems;
                                import fr.modchelou.recipes.ModRecipes;
                                import fr.modchelou.tiles.ModTiles;
                                import net.minecraft.creativetab.CreativeTabs;
                                import net.minecraft.item.Item;
                                
                                @Mod(modid = Ref.MOD_ID, name = Ref.MOD_NAME, version = Ref.VERSION)
                                
                                public class ChelouPrincipal
                                {
                                    @Instance(Ref.MOD_ID)
                                    public static ChelouPrincipal instance;
                                
                                    @SidedProxy(clientSide = Ref.CLIENT_PROXY, serverSide = Ref.SERVER_PROXY)
                                    public static CommonProxy proxy;
                                
                                    @EventHandler
                                    public void preInit(FMLPreInitializationEvent event)
                                    {
                                        proxy.preInit(event);
                                    }
                                
                                    @EventHandler
                                    public void init(FMLInitializationEvent event)
                                    {
                                        proxy.init(event);
                                    }
                                
                                    @EventHandler
                                    public void postInit(FMLPostInitializationEvent event)
                                    {
                                        proxy.postInit(event);
                                    }
                                }
                                

                                :::

                                La classe du GUI:

                                :::

                                package fr.modchelou.client.gui;
                                
                                import org.lwjgl.opengl.GL11;
                                
                                import fr.modchelou.Ref;
                                import fr.modchelou.common.gui.ContainerEuropiumMachine;
                                import fr.modchelou.tiles.TileEntityEuropiumMachine;
                                import net.minecraft.client.gui.inventory.GuiContainer;
                                import net.minecraft.client.resources.I18n;
                                import net.minecraft.entity.player.InventoryPlayer;
                                import net.minecraft.inventory.Container;
                                import net.minecraft.inventory.IInventory;
                                import net.minecraft.util.ResourceLocation;
                                
                                public class GuiEuropiumMachine extends GuiContainer
                                {
                                
                                    private static final ResourceLocation texture = new ResourceLocation("chelou:textures/gui/guiEuropiumMachine.png");
                                
                                    private TileEntityEuropiumMachine tileEuropiumMachine;
                                    private IInventory playerInv;
                                    public GuiEuropiumMachine(TileEntityEuropiumMachine tile, InventoryPlayer inventory)
                                    {
                                        super(new ContainerEuropiumMachine(tile, inventory));
                                        this.tileEuropiumMachine = tile;
                                        this.playerInv = inventory;
                                        this.allowUserInput = false;
                                        this.ySize = 340;
                                        this.xSize = 200;
                                    }
                                
                                    @Override
                                    protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                                    {
                                
                                        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                        this.mc.getTextureManager().bindTexture(texture);
                                        int k = (this.width - this.xSize) / 2;
                                        int l = (this.height - this.ySize) / 2;
                                        this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                                
                                        if(this.tileEuropiumMachine.isBurning())
                                        {
                                            int i = this.tileEuropiumMachine.getCookProgress();
                                            this.drawTexturedModalRect(k + 110, l, 199, 122, 14, 14);
                                        }
                                
                                    }
                                
                                }
                                

                                :::

                                La classe d’init des recettes:

                                :::

                                package fr.modchelou.recipes;
                                
                                import fr.modchelou.items.ModItems;
                                import net.minecraft.init.Blocks;
                                import net.minecraft.init.Items;
                                import net.minecraft.item.ItemStack;
                                
                                public class ModRecipes
                                {
                                    public static void init()
                                    {
                                        europiumMachineRecipes();
                                    }
                                    private static void europiumMachineRecipes()
                                    {
                                        EuropiumMachineRecipes.getManager().add(Items.leather, Items.leather, Blocks.chest, Items.leather, Items.leather, new ItemStack(ModItems.backpack, 1));
                                        EuropiumMachineRecipes.getManager().add(Items.diamond, Items.diamond, Items.diamond, Items.diamond, Items.diamond, new ItemStack(Blocks.diamond_block, 1));
                                    }
                                }
                                

                                :::

                                La classe des Recettes:

                                :::

                                package fr.modchelou.recipes;
                                
                                import java.util.HashMap;
                                import java.util.Iterator;
                                import java.util.Map;
                                import java.util.Map.Entry;
                                
                                import fr.modchelou.items.ModItems;
                                import net.minecraft.block.Block;
                                import net.minecraft.block.BlockChest;
                                import net.minecraft.init.Blocks;
                                import net.minecraft.init.Items;
                                import net.minecraft.item.Item;
                                import net.minecraft.item.ItemStack;
                                
                                public class EuropiumMachineRecipes
                                {
                                    private static final EuropiumMachineRecipes instance = new EuropiumMachineRecipes();
                                    private static final EuropiumMachineRecipes smeltingBase = new EuropiumMachineRecipes();
                                    private Map <itemstack[], itemstack="">smeltingList = new HashMap();
                                
                                    public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4, ItemStack stack5, ItemStack stack)
                                            {
                                                ItemStack[] stackList = new ItemStack[]{stack1, stack2, };
                                                this.smeltingList.put(stackList, stack4);
                                            }
                                
                                        public void add(Item item1, Block item2, Item item3, Block item4, Item item5, ItemStack stack)
                                        {
                                          this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), stack);
                                        }
                                
                                        public void add(Item item1, Item item2, Item item3, Item item4, Item item5, ItemStack stack)
                                        {
                                            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), stack);
                                        }
                                
                                        public void add(Block item1, Block item2, Item item3, Block item4, Block item5, ItemStack stack)
                                        {
                                            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), stack);
                                        }
                                
                                        public void add(Item item1, Block item2, Block item3, Block item4, Block item5, ItemStack stack)
                                        {
                                            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), stack);
                                        }
                                
                                        public void add(Item item1, Item item2, Block item3, Item item4, Item item5, ItemStack stack)
                                        {
                                            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), stack);
                                        }
                                
                                            public ItemStack getSmeltingResult(ItemStack[] stack)
                                                 {
                                                     Iterator iterator = this.smeltingList.entrySet().iterator();
                                                     Entry entry;
                                
                                                     do
                                                     {
                                                         if (!iterator.hasNext())
                                                         {
                                                             return null;
                                                         }
                                                        entry = (Entry)iterator.next();
                                                    }
                                                    while (!this.isSameKey(stack, (ItemStack[])entry.getKey()));
                                
                                                    return (ItemStack)entry.getValue();
                                                  }
                                
                                            private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
                                                 {
                                                     boolean isSame = false;
                                                     for(int i=0; i<=2; i++)
                                                     {
                                                         if(stackList*.getItem() == stackList2*.getItem())
                                                         {
                                                             isSame = true;
                                                         }
                                                         else
                                                         {
                                                             return false;
                                                         }
                                                     }
                                                     return isSame;
                                                 }
                                
                                            public Map <itemstack[], itemstack="">getSmeltingList()
                                                 {
                                                    return this.smeltingList;
                                                 }
                                
                                            public static EuropiumMachineRecipes smelting()
                                                {
                                                    return smeltingBase;
                                                }
                                
                                            public static EuropiumMachineRecipes getManager()
                                            {
                                              return instance;
                                            }
                                
                                }
                                

                                :::

                                Et enin la texture de mon gui(progressbar comprise)

                                http://www.noelshack.com/2016-18-1462518704-guieuropiummachine.png

                                si jamais vous avez besoin de l’image envoyez moi un mp et je vous donnerais un lien dropbox</itemstack[],></itemstack[],>

                                1 réponse Dernière réponse Répondre Citer 0
                                • AymericRedA Hors-ligne
                                  AymericRed
                                  dernière édition par

                                  Tes recettes ne s’enregistrent pas ? Quand tu met tous les items qu’il faut elle ne se lance pas ? Montre ton tileentity, c’est possible que ce soit lui la cause du problème.

                                  Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                  AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                  Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                  Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • Z Hors-ligne
                                    ZephyrinGames
                                    dernière édition par

                                    ok,

                                    La classe du TileEntity:

                                    :::

                                    package fr.modchelou.tiles;
                                    
                                    import cpw.mods.fml.relauncher.Side;
                                    import cpw.mods.fml.relauncher.SideOnly;
                                    import fr.modchelou.recipes.EuropiumMachineRecipes;
                                    import net.minecraft.entity.player.EntityPlayer;
                                    import net.minecraft.inventory.IInventory;
                                    import net.minecraft.item.ItemStack;
                                    import net.minecraft.nbt.NBTTagCompound;
                                    import net.minecraft.nbt.NBTTagList;
                                    import net.minecraft.tileentity.TileEntity;
                                    
                                    public class TileEntityEuropiumMachine extends TileEntity implements IInventory
                                    {
                                        private ItemStack[] contents = new ItemStack[6];
                                        private int workingTime = 0;
                                        private int TimeNeeded = 200;
                                    
                                        @Override
                                        public void readFromNBT(NBTTagCompound compound)
                                        {
                                            super.readFromNBT(compound);
                                    
                                            NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                            this.contents = new ItemStack[this.getSizeInventory()];
                                            for (int i = 0; i < nbttaglist.tagCount(); ++i)
                                                    {
                                                        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                                        int j = nbttagcompound1.getByte("Slot") & 255;
                                    
                                                        if (j >= 0 && j < this.contents.length)
                                                        {
                                                            this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                                        }
                                                    }
                                    
                                                    this.workingTime = compound.getShort("workingTime");
                                                    this.TimeNeeded = compound.getShort("TimeNeeded");
                                                }
                                    
                                               @Override
                                               public int getSizeInventory()
                                               {
                                                   return this.contents.length;
                                               }
                                    
                                               @Override
                                               public ItemStack getStackInSlot(int slotIndex)
                                               {
                                                   return this.contents[slotIndex];
                                               }
                                    
                                               @Override
                                               public ItemStack decrStackSize(int slotIndex, int amount) {
                                                    if (this.contents[slotIndex] != null)
                                                       {
                                                           ItemStack itemstack;
                                    
                                                           if (this.contents[slotIndex].stackSize <= amount)
                                                           {
                                                               itemstack = this.contents[slotIndex];
                                                               this.contents[slotIndex] = null;
                                                               this.markDirty();
                                                               return itemstack;
                                                           }
                                                           else
                                                           {
                                                               itemstack = this.contents[slotIndex].splitStack(amount);
                                    
                                                               if (this.contents[slotIndex].stackSize == 0)
                                                               {
                                                                   this.contents[slotIndex] = null;
                                                               }
                                    
                                                               this.markDirty();
                                                               return itemstack;
                                                           }
                                                       }
                                                       else
                                                       {
                                                           return null;
                                                       }
                                               }
                                    
                                             @Override
                                                public ItemStack getStackInSlotOnClosing(int slotIndex) {
                                                    if (this.contents[slotIndex] != null)
                                                    {
                                                        ItemStack itemstack = this.contents[slotIndex];
                                                        this.contents[slotIndex] = null;
                                                        return itemstack;
                                                    }
                                                    else
                                                    {
                                                        return null;
                                                    }
                                               }
                                    
                                            @Override
                                               public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                                                  this.contents[slotIndex] = stack;
                                    
                                                    if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                                    {
                                                        stack.stackSize = this.getInventoryStackLimit();
                                                    }
                                    
                                                    this.markDirty();
                                               }
                                    
                                            @Override
                                               public String getInventoryName()
                                               {
                                                   return "tile.EuropiumMachine";
                                               }
                                    
                                            @Override
                                               public boolean hasCustomInventoryName()
                                               {
                                                   return false;
                                               }
                                    
                                            @Override
                                               public int getInventoryStackLimit()
                                               {
                                                   return 64;
                                               }
                                    
                                            @Override
                                               public boolean isUseableByPlayer(EntityPlayer player)
                                               {
                                                   return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
                                               }
                                    
                                            @Override
                                               public void openInventory()
                                               {
                                    
                                               }
                                    
                                            @Override
                                               public void closeInventory()
                                               {
                                    
                                               }
                                    
                                            @Override
                                               public boolean isItemValidForSlot(int slot, ItemStack stack)
                                               {
                                                   return slot == 3 ? false : true;    
                                               }
                                    
                                               public boolean isBurning()
                                                {
                                                   return this.workingTime > 0;
                                               }
                                    
                                               private boolean canSmelt()
                                                {
                                                    if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null || this.contents[3] == null || this.contents[4] == null || this.contents[5] == null)
                                                    {
                                                        return false;
                                                    }
                                                    else
                                                    {
                                                        ItemStack itemstack = EuropiumMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2], this.contents[3], this.contents[4], this.contents[5]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                                        if (itemstack == null) return false;
                                                        if (this.contents[5] == null) return true;
                                                        if (!this.contents[5].isItemEqual(itemstack)) return false;
                                                        int result = contents[5].stackSize + itemstack.stackSize;
                                                        return result <= getInventoryStackLimit() && result <= this.contents[5].getMaxStackSize();
                                                    }
                                                }
                                    
                                               public void updateEntity()
                                                {
                                                   if(this.isBurning() && this.canSmelt())
                                                   {
                                                           ++this.workingTime;
                                                   }
                                                   if(this.canSmelt() && !this.isBurning())
                                                   {
                                                       this.workingTime = 1;
                                                   }
                                                   if(this.canSmelt() && this.workingTime == this.TimeNeeded)
                                                   {
                                                       this.smeltItem();
                                                       this.workingTime = 0;
                                                   }
                                                    if(!this.canSmelt())
                                                    {
                                                               this.workingTime= 0;
                                                    }
                                                }
                                    
                                               public void smeltItem()
                                                {
                                                    if (this.canSmelt())
                                                    {
                                                        ItemStack itemstack = EuropiumMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2], this.contents[3], this.contents[4], this.contents[5]}); //On récupère l'output de la recette
                                                         if (this.contents[5] == null)
                                                         {
                                                                  this.contents[5] = itemstack.copy();
                                                         }
                                                         else if (this.contents[5].getItem() == itemstack.getItem())
                                                         {
                                                                  this.contents[5].stackSize += itemstack.stackSize;
                                                         }
                                    
                                                         –this.contents[0].stackSize;
                                                         –this.contents[1].stackSize;
                                                         –this.contents[2].stackSize;
                                                         –this.contents[3].stackSize;
                                                         –this.contents[4].stackSize;
                                    
                                                         if (this.contents[0].stackSize <= 0)
                                                         {
                                                             this.contents[0] = null;
                                                         }
                                                         if (this.contents[1].stackSize <= 0)
                                                         {
                                                             this.contents[1] = null;
                                                         }
                                                         if (this.contents[2].stackSize <= 0)
                                                         {
                                                             this.contents[2] = null;
                                                         }
                                                         if (this.contents[3].stackSize <= 0)
                                                         {
                                                             this.contents[3] = null;
                                                         }
                                                         if (this.contents[4].stackSize <= 0)
                                                         {
                                                             this.contents[4] = null;
                                                         }
                                    
                                                    }
                                                }
                                            @SideOnly(Side.CLIENT)
                                            public int getCookProgress()
                                            {
                                                return this.workingTime * 16 / this.TimeNeeded;
                                            }
                                    
                                    }
                                    

                                    :::

                                    Et voila ma classe du tileEntity

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • AymericRedA Hors-ligne
                                      AymericRed
                                      dernière édition par

                                      “//Il y a une erreur ici, c’est normal, on y vient après (c’est pour les recettes)” bah il vaut mieux  voir ça maintenant, parce que logiquement, si tes recettes marchent pas, c’est normal que la barre de progression ne monte pas, donc je regarde.
                                      EDIT : c’est quoi l’erreur ?

                                      Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                      AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                      Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                      Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • Z Hors-ligne
                                        ZephyrinGames
                                        dernière édition par

                                        @‘AymericRed’:

                                        “//Il y a une erreur ici, c’est normal, on y vient après (c’est pour les recettes)” bah il vaut mieux  voir ça maintenant, parce que logiquement, si tes recettes marchent pas, c’est normal que la barre de progression ne monte pas, donc je regarde.
                                        EDIT : c’est quoi l’erreur ?

                                        "//Il y a une erreur ici, c’est normal, on y vient après (c’est pour les recettes)"vient du Ctrl-C/Ctrl-V du tuto (peu de temps)

                                        et l’erreur vient du fait que quand je met mes items pour la recette, il ne se passe rien!!!
                                        Aidez-moi svp

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • robin4002R Hors-ligne
                                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                          dernière édition par

                                          Dans la fonction public void smeltItem()
                                          Juste avant if(this.canSmelt()) …
                                          Ajoutes :
                                          System.out.println(this.canSmelt()));
                                          et regardes dans la console s’il affiche true ou false.
                                          S’il affiche false il y a un problème avec la fonction canSmelt
                                          S’il affiche true le problème est surement dans smeltItem
                                          S’il n’affiche rien, ta fonction smeltItem n’est jamais appelé.

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • Z Hors-ligne
                                            ZephyrinGames
                                            dernière édition par

                                            @‘robin4002’:

                                            Dans la fonction public void smeltItem()
                                            Juste avant if(this.canSmelt()) …
                                            Ajoutes :
                                            System.out.println(this.canSmelt()));
                                            et regardes dans la console s’il affiche true ou false.
                                            S’il affiche false il y a un problème avec la fonction canSmelt
                                            S’il affiche true le problème est surement dans smeltItem
                                            S’il n’affiche rien, ta fonction smeltItem n’est jamais appelé.

                                            Il n’affiche rien et en supplément je crash!!

                                            donc j’en déduis que ma fonction smeltItem n’est pas appelée mais comment l’appeler et surtout où???

                                            Merci d’avance pour m’avoir aidé!!

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 8
                                            • 9
                                            • 10
                                            • 11
                                            • 12
                                            • 10 / 12
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB