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.
    • MinantcraftM Hors-ligne
      Minantcraft
      dernière édition par

      Super TUTO!

      Minantcraft ;)

      >! Binary Dimension
      [url=https://minecraft.cu…

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

        Plop les gens,
        J’ai fais deux machines à 3slots grâce à ce tuto bien réalisé.

        Mais maintenant que j’essaie de faire une machine à un slot et une pourvu de deux slots, j’ai un crash identique dans les deux cas:

        –-- Minecraft Crash Report ----
        // I blame Dinnerbone.
        
        Time: 22/06/16 17:41
        Description: Ticking memory connection
        
        java.lang.ArrayIndexOutOfBoundsException: 3
        at fr.powergame.modpg2.client.TileEntitySechoir.getStackInSlot(TileEntitySechoir.java:38)
        at net.minecraft.inventory.Slot.getStack(Slot.java:88)
        at net.minecraft.inventory.Container.getInventory(Container.java:67)
        at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
        at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88)
        at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
        at fr.powergame.modpg2.common.BlockSechoir.onBlockActivated(BlockSechoir.java:46)
        at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
        at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
        at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
        at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
        at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
        at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
        at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
        at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
        
        A detailed walkthrough of the error, its code path and all known details is as follows:
        ---------------------------------------------------------------------------------------
        
        -- Head --
        Stacktrace:
        at fr.powergame.modpg2.client.TileEntitySechoir.getStackInSlot(TileEntitySechoir.java:38)
        at net.minecraft.inventory.Slot.getStack(Slot.java:88)
        at net.minecraft.inventory.Container.getInventory(Container.java:67)
        at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
        at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88)
        at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
        at fr.powergame.modpg2.common.BlockSechoir.onBlockActivated(BlockSechoir.java:46)
        at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
        at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
        at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
        at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
        
        -- Ticking connection --
        Details:
        Connection: net.minecraft.network.NetworkManager@13f82374
        Stacktrace:
        at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
        at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
        at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
        at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
        at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
        

        Du coup voici la classe du tileEntity pour la machine mono-slot, les tableaux etc, ça me passe encore au dessus =/

        package fr.powergame.modpg2.client;
        
        import cpw.mods.fml.relauncher.Side;
        import cpw.mods.fml.relauncher.SideOnly;
        import fr.powergame.modpg2.common.AlambicRecipes;
        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.network.NetworkManager;
        import net.minecraft.network.Packet;
        import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
        import net.minecraft.tileentity.TileEntity;
        
        public class TileEntitySechoir extends TileEntity implements IInventory
        {
            private byte direction;
            private ItemStack[] contents = new ItemStack[3];
            private int workingTime = 0;
            private int workingTimeNeeded = 200;
        
            @SideOnly(Side.CLIENT)
            public int getCookProgress()
            {
                return this.workingTime * 41 / this.workingTimeNeeded;
            }
        
            @Override
            public int getSizeInventory()
            {
                return this.contents.length;
            }
        
            @Override
            public ItemStack getStackInSlot(int slotIndex)
            {
                return this.contents[slotIndex];
            }
        
            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.Sechoir";
            }
        
            @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 == 1 ? false : true;
            }
        
            public boolean isBurning()
            {
                return this.workingTime > 0;
            }
        
            private boolean canSmelt()
            {
                if (this.contents[0] == null)
                {
                    return false;
                }
                else
                {
                    ItemStack itemstack = AlambicRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0]});
                    if (itemstack == null) return false;
                    if (this.contents[1] == null) return true;
                    if (!this.contents[1].isItemEqual(itemstack)) return false;
                    int result = contents[1].stackSize + itemstack.stackSize;
                    return result <= getInventoryStackLimit() && result <= this.contents[1].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 = AlambicRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0]});
                     if (this.contents[1] == null)
                     {
                          this.contents[1] = itemstack.copy();
                     }
                     else if (this.contents[1].getItem() == itemstack.getItem())
                     {
                          this.contents[1].stackSize += itemstack.stackSize;
                     }
        
                     –this.contents[0].stackSize;
        
                     if (this.contents[0].stackSize <= 0)
                     {
                         this.contents[0] = null;
                     }
                }
            }
        
            @Override
            public void writeToNBT(NBTTagCompound compound)
            {
                super.writeToNBT(compound);
                NBTTagList nbttaglist = new NBTTagList();
        
                for (int i = 0; i < this.contents.length; ++i)
                {
                    if (this.contents* != null)
                    {
                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                        nbttagcompound1.setByte("Slot", (byte)i);
                        this.contents*.writeToNBT(nbttagcompound1);
                        nbttaglist.appendTag(nbttagcompound1);
                    }
                }
        
                compound.setTag("Items", nbttaglist);
                compound.setShort("workingTime",(short)this.workingTime);
                compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
                compound.setByte("Direction", this.direction);
            }
        
            @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");
                this.direction = compound.getByte("Direction");
            }
        
            public byte getDirection()
            {
                return direction;
            }
        
            public void setDirection(byte direction)
            {
                this.direction = direction;
                this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
            }
        
            public Packet getDescriptionPacket()
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                this.writeToNBT(nbttagcompound);
                return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
            }
        
            public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
            {
                this.readFromNBT(pkt.func_148857_g());
                this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
            }
        }
        

        Qu’est ce que j’ai oublié de modifier pour parvenir à un bloc fonctionnel, svp?

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

          private ItemStack[] contents = new ItemStack[3]; -> à changer en fonction du nombre de slots et il faut aussi modifier le Container

          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

            J’ai mis à 2, ça crash aussi.  (Le trois est un fail, j’ai fais des tests et j’ai laissé cette valeur pour voir un peu de mon côté mais bon)

            Edit: Voici le container

            package fr.powergame.modpg2.common;
            
            import fr.powergame.modpg2.client.TileEntitySechoir;
            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 SechoirContainer extends Container
            {
                private TileEntitySechoir tileSechoir;
            
                public SechoirContainer(TileEntitySechoir tile, InventoryPlayer inventory)
                {
                    this.tileSechoir = tile;
                    this.addSlotToContainer(new Slot(tile, 1, 89, 29));
                    this.addSlotToContainer(new SechoirSlotResult(tile, 3, 89, 89));
                    this.bindPlayerInventory(inventory);    
                }
            
                @Override
                public boolean canInteractWith(EntityPlayer player)
                {
                    return this.tileSechoir.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, 125 + i * 18));
                        }
                    }
            
                    for(i = 0; i < 9; ++i)
                    {
                        this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                    }
                }
            
                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.tileSechoir.getSizeInventory())
                        {
                            if (!this.mergeItemStack(itemstack1, this.tileSechoir.getSizeInventory(), this.inventorySlots.size(), true))
                            {
                                return null;
                            }
                        }
                        else if (!this.mergeItemStack(itemstack1, 0, this.tileSechoir.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.tileSechoir.closeInventory();
                }
            }
            
            
            1 réponse Dernière réponse Répondre Citer 0
            • BrokenSwingB Hors-ligne
              BrokenSwing Moddeurs confirmés Rédacteurs
              dernière édition par

              Essai de mettre ça comme constructeur dans ton container

              
              public SechoirContainer(TileEntitySechoir tile, InventoryPlayer inventory)
                 {
                     this.tileSechoir = tile;
                     this.addSlotToContainer(new Slot(tile, 0, 89, 29));
                     this.addSlotToContainer(new SechoirSlotResult(tile, 1, 89, 89));
                     this.bindPlayerInventory(inventory);    
                 }
              
              
              1 réponse Dernière réponse Répondre Citer 0
              • FolganskyF Hors-ligne
                Folgansky Correcteurs
                dernière édition par

                Ah oui, j’avais bêtement supprimé les autres lignes sans réaliser ce que ces paramètres représentaient.

                Mais ça “crash” toujours, en fait ça  fait “terminated” la connexion.
                Peut-être mon GUIHandler qui n’est pas bon, j’ai eu des hésitations en ajoutant les nouveaux GUI:

                package fr.powergame.modpg2.common;
                
                import cpw.mods.fml.common.network.IGuiHandler;
                import fr.powergame.modpg2.client.TileEntityAlambic;
                import fr.powergame.modpg2.client.TileEntityEntubeuse;
                import fr.powergame.modpg2.client.TileEntitySechoir;
                import net.minecraft.entity.player.EntityPlayer;
                import net.minecraft.tileentity.TileEntity;
                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)
                    {
                        TileEntity tile = world.getTileEntity(x, y, z);
                
                        if(tile instanceof TileEntityAlambic)
                        {
                            return new AlambicContainer((TileEntityAlambic)tile, player.inventory);
                        }
                        if(tile instanceof TileEntitySechoir)
                        {
                            return new SechoirContainer((TileEntitySechoir)tile, player.inventory);
                        }
                        if(tile instanceof TileEntityEntubeuse)
                        {
                            return new EntubeuseContainer((TileEntityEntubeuse)tile, player.inventory);
                        }
                        return null;
                    }
                
                    @Override
                    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                    {
                        TileEntity tile = world.getTileEntity(x, y, z);
                
                        if(tile instanceof TileEntityAlambic)
                        {
                            return new AlambicGUI((TileEntityAlambic)tile, player.inventory);
                        }
                        if(tile instanceof TileEntitySechoir)
                        {
                            return new SechoirContainer((TileEntitySechoir)tile, player.inventory);
                        }
                        if(tile instanceof TileEntityEntubeuse)
                        {
                            return new EntubeuseContainer((TileEntityEntubeuse)tile, player.inventory);
                        }
                        return null;
                    }
                }
                

                edit: sachant que je mets “0” pour les trois blocs:

                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(ModPg2.instance, 0, world, x, y, z);
                            return true;
                        }
                    }
                

                Ps: je sais que mes noms de classes devraient être en anglais, mais c’est un mod qui ne sera pas redistribué ou autre, ça vous pique simplement un peu les yeux sur le forum 😃

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

                  Dans ta fonction getClientGuiElement :

                  if(tile instanceof TileEntitySechoir)
                  {
                  return new SechoirContainer((TileEntitySechoir)tile, player.inventory);
                  }
                  if(tile instanceof TileEntityEntubeuse)
                  {
                  return new EntubeuseContainer((TileEntityEntubeuse)tile, player.inventory);
                  }
                  

                  Le problème vient de là car il faut toujours retourner un Gui, donc tu dois changer les “return UnContainer” par des “return UnGui”.

                  PS: “Entubeuse”, quel nom ! 🙂

                  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
                  • FolganskyF Hors-ligne
                    Folgansky Correcteurs
                    dernière édition par

                    Hum, je ne comprend pas, l’Alambic ne pose aucun soucis alors qu’il retourne un Container lui-aussi.

                    :::
                    (https://t2.ftcdn.net/jpg/00/03/53/61/500_F_3536130_VwfKdvaF345kuC0foyHZNXq8eo7dI5.jpg)
                    :::

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

                      Non c’est un gui : " return new AlambicGUI((TileEntityAlambic)tile, player.inventory);"

                      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
                      • FolganskyF Hors-ligne
                        Folgansky Correcteurs
                        dernière édition par

                        Ouki! Sacrée poutre que tu me retires de l’oeil, je me persuadais moi-même qu’il n’y avait qu’une fonction dans cette classe… Bref merci pour ce point qui m’empêchait d’avancer.

                        Du coup la machine à deux slots fonctionnent bien, pas de soucis.
                        Celle à un seul par contre ne semble pas comprendre les recettes suggérées.

                        Comme les autres fonctionnent par tableau de stacks mais que je suppose que ce n’est pas nécessaire et j’ai donc regardé la classe du four vanilla pour obtenir cette classe:

                        package fr.powergame.modpg2.common;
                        
                        import java.util.HashMap;
                        import java.util.Iterator;
                        import java.util.Map;
                        import java.util.Map.Entry;
                        
                        import net.minecraft.item.Item;
                        import net.minecraft.item.ItemStack;
                        
                        public class SechoirRecipes
                        {
                            private static final SechoirRecipes smeltingBase = new SechoirRecipes();
                        
                            @SuppressWarnings("rawtypes")
                            private Map smeltingList = new HashMap();
                        
                        //    private Map <itemstack[], itemstack="">smeltingList = new HashMap<itemstack[], itemstack="">();
                        
                            public SechoirRecipes()
                            {
                                this.addRecipe(new ItemStack(ModPg2.itemMetadata, 1, 21), new ItemStack(ModPg2.itemMetadata, 1, 22));
                                this.addRecipe(new ItemStack(ModPg2.itemMetadata, 1, 23), new ItemStack(ModPg2.itemMetadata, 1, 24));    
                            }
                        
                            @SuppressWarnings("unchecked")
                            public void addRecipe(ItemStack stack1, ItemStack stack2)
                            {
                                this.smeltingList.put(stack1, stack2);
                            }
                        
                            public void addRecipe(Item item1, ItemStack stack)
                            {
                                this.addRecipe(new ItemStack(item1), stack);
                            }
                        
                        //    @SuppressWarnings("rawtypes")
                        //    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() && stackList*.getItemDamage() == stackList2*.getItemDamage())
                        //            {
                        //                isSame = true;
                        //            }
                        //            else
                        //            {
                        //                return false;
                        //            }
                        //        }
                        //        return isSame;
                        //    }
                        
                            @SuppressWarnings("rawtypes")
                            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 stack1, ItemStack stack2)
                            {
                                return stack2.getItem() == stack1.getItem() && (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage());
                            }
                        
                            @SuppressWarnings("rawtypes")
                            public Map getSmeltingList()
                            {
                                return this.smeltingList;
                            }
                        
                            public static SechoirRecipes smelting()
                            {
                                return smeltingBase;
                            }
                        }
                        

                        Je ne sais pas ce que devient le smeltingList dans le cas où il n’y a qu’un slot d’input</itemstack[],></itemstack[],>

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

                          Tu as juste à remplacer les ItemStack[] par des ItemStacks.
                          PS : Tu n’as pas de crash, parce que tu essayes de cast un ItemStack[] en un ItemStack à la ligne 84;

                          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
                          • FolganskyF Hors-ligne
                            Folgansky Correcteurs
                            dernière édition par

                            Euh non je n’ai pas de crash si c’est une question et j’ai retiré déjà tous les ItemStack[] que j’ai vu, le code ne fonctionne pas cela dit.

                            Tu as peut-être répondu avant que j’édit mon message pour la dernière fois, mauvais timing de ma part.
                            J’ai changé la fonction isSameKey et du coup les arguments de la fonction précédente et le mapping, enfin le “Map truc bidule” comme je dirais…

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

                              Là ça devrait marcher, montre la classe de ton TE si les fonctions canSmelt, smelt ou updateEntity ont changé.
                              Et essaye de mettre workingTime >= workingTimeNeeded au lieu de workingTime == workingTimeNeeded dans ta fonction updateEntity().

                              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
                              • FolganskyF Hors-ligne
                                Folgansky Correcteurs
                                dernière édition par

                                J’ai essayé de faire le plus attention à changer les bons slots, à voir =d

                                Edit:

                                            ItemStack itemstack = SechoirRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0]});
                                
                                

                                Mon erreur était là à cause d’un oubli, j’avais laissé les recettes de l’alambic comme un idiot (je travaille trop tard visiblement)

                                Mais du coup, le new ItemStack[]{this.contents[0]} devient quoi? Je teste des choses mais c’pas conventionnel visiblement

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

                                  ça dépend de ce que tu veux faire mais si tu n’as besoin que d’un seul slot tu n’es pas obligé d’utiliser une array d’ItemStack

                                  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

                                    Oui clairement je n’ai qu’un slot et donc pas besoin de cet array d’ItemStack

                                    C’est mon “niveau” de java qui me bloque

                                    Je teste "  new ItemStack({this.contents[0]})  " ou encore "  new ItemStack{this.contents[0]}  " mais eclipse semble se demander ce que j’essaie de faire.

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

                                      new ItemStack[]{this.contents[0]}

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

                                        Euh, mais précédemment j’ai changé des fonctions pour enlever l’array partout ailleurs comme:

                                        package fr.powergame.modpg2.common;
                                        
                                        import java.util.HashMap;
                                        import java.util.Iterator;
                                        import java.util.Map;
                                        import java.util.Map.Entry;
                                        
                                        import net.minecraft.item.Item;
                                        import net.minecraft.item.ItemStack;
                                        
                                        public class SechoirRecipes
                                        {
                                            private static final SechoirRecipes smeltingBase = new SechoirRecipes();
                                        
                                            @SuppressWarnings("rawtypes")
                                            private Map smeltingList = new HashMap();
                                        
                                            public SechoirRecipes()
                                            {
                                                this.addRecipe(new ItemStack(ModPg2.itemMetadata, 1, 21), new ItemStack(ModPg2.itemMetadata, 1, 22));
                                                this.addRecipe(new ItemStack(ModPg2.itemMetadata, 1, 23), new ItemStack(ModPg2.itemMetadata, 1, 24));    
                                            }
                                        
                                            @SuppressWarnings("unchecked")
                                            public void addRecipe(ItemStack stack1, ItemStack stack2)
                                            {
                                                this.smeltingList.put(stack1, stack2);
                                            }
                                        
                                            public void addRecipe(Item item1, ItemStack stack)
                                            {
                                                this.addRecipe(new ItemStack(item1), stack);
                                            }
                                        
                                            @SuppressWarnings("rawtypes")
                                            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 stack1, ItemStack stack2)
                                            {
                                                return stack2.getItem() == stack1.getItem() && (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage());
                                            }
                                        
                                            @SuppressWarnings("rawtypes")
                                            public Map getSmeltingList()
                                            {
                                                return this.smeltingList;
                                            }
                                        
                                            public static SechoirRecipes smelting()
                                            {
                                                return smeltingBase;
                                            }
                                        }
                                        

                                        Sinon je n’aurais rien eu à changer à ce niveau là dans la TileEntity BrockenSwing

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

                                          Pour transformer cet array “new ItemStack[]{this.contents[0]}” en variable simple, suffit de l’écrire comme ça “this.contents[0]”.

                                          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 1
                                          • FolganskyF Hors-ligne
                                            Folgansky Correcteurs
                                            dernière édition par

                                            Ok nickel.
                                            Du coup this.content[0] est un ItemStack apparement, je suis plus lent à apprendre que je ne le pensais.

                                            Tout fonctionne, merci d’avoir pris de votre temps pour m’aider à régler ces “détails” en somme.

                                            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