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.
    • DiabolicaTrixD Hors-ligne
      DiabolicaTrix Correcteurs Moddeurs confirmés
      dernière édition par

      Oui, car mon Gui de Coffre fonctionne

      NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
      
      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

        Ah en fait j’avais pas fait attention. Tu as seulement ton coffre dans le gui handler. Ta machine n’y est pas.

        1 réponse Dernière réponse Répondre Citer 0
        • DiabolicaTrixD Hors-ligne
          DiabolicaTrix Correcteurs Moddeurs confirmés
          dernière édition par

          Maintenant, j’ai un NPE ici:

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

          Honnêtement je ne comprend pas trop le openGui.

          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

            Étrange. La seule chose qui peut être null c’est l’instance. Tu as quoi dans la classe Base ?

            1 réponse Dernière réponse Répondre Citer 0
            • DiabolicaTrixD Hors-ligne
              DiabolicaTrix Correcteurs Moddeurs confirmés
              dernière édition par

              ​package diabolicatrix.base;
              
              import cpw.mods.fml.common.FMLCommonHandler;
              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 diabolicatrix.base.block.BlockAlloyFurnace;
              import diabolicatrix.base.block.BlockMineral;
              import diabolicatrix.base.block.BlockNetherTNT;
              import diabolicatrix.base.block.BlockNormal;
              import diabolicatrix.base.block.BlockTestChest;
              import diabolicatrix.base.gui.GuiHandler;
              import diabolicatrix.base.proxy.CommonProxy;
              import diabolicatrix.base.tileentity.TileEntityAlloyFurnace;
              import diabolicatrix.base.tileentity.TileEntityBlockChest;
              import net.minecraft.block.Block;
              import net.minecraft.block.material.Material;
              import net.minecraft.client.Minecraft;
              import net.minecraft.creativetab.CreativeTabs;
              import net.minecraft.item.Item;
              import net.minecraft.item.ItemArmor.ArmorMaterial;
              import net.minecraft.item.ItemFood;
              import net.minecraft.item.ItemStack;
              import net.minecraftforge.common.util.EnumHelper;
              
              @Mod(modid = Base.MODID, name = "T4 Bases", version = "1.0.1")
              public class Base {
              
              public static final String MODID = "t4";
              
              @Instance(MODID)
              public static Base instance;
              
              @SidedProxy(clientSide = "diabolicatrix.base.proxy.ClientProxy", serverSide = "diabolicatrix.base.proxy.CommonProxy")
              public static CommonProxy proxy;
              
              public static Item itemPizza, itemTopaze, itemRuby, itemSaphir, itemTitane, itemCobalt, itemAdamantine, itemOrichalque;
              public static Block blockTopaze, blockRuby, blockSaphir, blockTitane, blockCobalt, blockPlatine, blockAlloyFurnace, testChest, blockBrick, blockNTNT;
              
              public static Item itemSaphirHelmet, itemSaphirChestPlate, itemSaphirPants, itemSaphirBoots;
              
              public static ArmorMaterial saphir = EnumHelper.addArmorMaterial("saphir", 40, new int[] { 4, 9, 7, 4 }, 9);
              
              @EventHandler
              public void preInit(FMLPreInitializationEvent event) {
              
              itemTopaze = new ItemMineral().setUnlocalizedName("ItemTopaze").setTextureName("t4:itemtopaze")
              .setCreativeTab(tabTesseract4);
              itemRuby = new ItemMineral().setUnlocalizedName("ItemRuby").setTextureName("t4:itemruby")
              .setCreativeTab(tabTesseract4);
              itemSaphir = new ItemMineral().setUnlocalizedName("ItemSaphir").setTextureName("t4:itemsaphir")
              .setCreativeTab(tabTesseract4);
              itemTitane = new ItemMineral().setUnlocalizedName("ItemTitane").setTextureName("t4:itemtitane")
              .setCreativeTab(tabTesseract4);
              itemCobalt = new ItemMineral().setUnlocalizedName("ItemCobalt").setTextureName("t4:itemcobalt")
              .setCreativeTab(tabTesseract4);
              itemAdamantine = new ItemMineral().setUnlocalizedName("ItemAdamantine").setTextureName("t4:itemadamantine")
              .setCreativeTab(tabTesseract4);
              itemOrichalque = new ItemMineral().setUnlocalizedName("ItemOri").setTextureName("t4:itemorichalque")
              .setCreativeTab(tabTesseract4);
              itemPizza = new ItemFood(10, 0.8F, false).setUnlocalizedName("ItemPizza").setTextureName("t4:itempizza")
              .setCreativeTab(tabTesseract4);
              
              blockTopaze = new BlockMineral(Material.rock, "Topaze").setBlockName("BlockTopaze")
              .setBlockTextureName("t4:blocktopaze").setCreativeTab(tabTesseract4).setHardness(3.0F)
              .setResistance(5.0F);
              blockRuby = new BlockMineral(Material.rock, "Ruby").setBlockName("BlockRuby")
              .setBlockTextureName("t4:blockruby").setCreativeTab(tabTesseract4).setHardness(3.0F)
              .setResistance(5.0F);
              blockSaphir = new BlockMineral(Material.rock, "Saphir").setBlockName("BlockSaphir")
              .setBlockTextureName("t4:blocksaphir").setCreativeTab(tabTesseract4).setHardness(3.0F)
              .setResistance(5.0F);
              blockTitane = new BlockNormal(Material.rock).setBlockName("BlockTitane").setBlockTextureName("t4:blocktitane")
              .setCreativeTab(tabTesseract4).setHardness(3.0F).setResistance(5.0F);
              blockCobalt = new BlockNormal(Material.rock).setBlockName("BlockCobalt").setBlockTextureName("t4:blockcobalt")
              .setCreativeTab(tabTesseract4).setHardness(3.0F).setResistance(5.0F);
              blockBrick = new BlockNormal(Material.rock).setBlockName("BlockBrick").setBlockTextureName("t4:furnace_top")
              .setCreativeTab(tabTesseract4).setHardness(4.0F);
              blockNTNT = new BlockNetherTNT().setBlockName("BlockNTNT").setCreativeTab(tabTesseract4).setHardness(0.0F);
              blockAlloyFurnace = new BlockAlloyFurnace(Material.rock).setBlockName("BlockAlloyFurnace")
              .setCreativeTab(tabTesseract4).setHardness(3.5F);
              testChest = new BlockTestChest(Material.rock).setBlockName("BlockTestChest").setCreativeTab(tabTesseract4)
              .setHardness(4.0F).setResistance(35.0F).setBlockTextureName("t4:nether_brick");
              
              itemSaphirHelmet = new ItemArmorSaphir(saphir, 0).setUnlocalizedName("itemSaphirHelmet")
              .setTextureName("t4:itemSaphirHelmet").setCreativeTab(tabTesseract4);
              itemSaphirChestPlate = new ItemArmorSaphir(saphir, 1).setUnlocalizedName("itemSaphirChestPlate")
              .setTextureName("t4:itemSaphirChestPlate").setCreativeTab(tabTesseract4);
              itemSaphirPants = new ItemArmorSaphir(saphir, 2).setUnlocalizedName("itemSaphirPants")
              .setTextureName("t4:itemSaphirPants").setCreativeTab(tabTesseract4);
              itemSaphirBoots = new ItemArmorSaphir(saphir, 3).setUnlocalizedName("itemSaphirBoots")
              .setTextureName("t4:itemSaphirBoots").setCreativeTab(tabTesseract4);
              
              GameRegistry.registerItem(itemPizza, itemPizza.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemTopaze, itemTopaze.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemRuby, itemRuby.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemSaphir, itemSaphir.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemTitane, itemTitane.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemCobalt, itemCobalt.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemAdamantine, itemAdamantine.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemOrichalque, itemOrichalque.getUnlocalizedName().substring(5));
              
              GameRegistry.registerItem(itemSaphirHelmet, itemSaphirHelmet.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemSaphirChestPlate, itemSaphirChestPlate.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemSaphirPants, itemSaphirPants.getUnlocalizedName().substring(5));
              GameRegistry.registerItem(itemSaphirBoots, itemSaphirBoots.getUnlocalizedName().substring(5));
              
              GameRegistry.registerBlock(blockTopaze, blockTopaze.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockRuby, blockRuby.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockSaphir, blockSaphir.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockTitane, blockTitane.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockCobalt, blockCobalt.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockBrick, blockBrick.getUnlocalizedName().substring(5));
              GameRegistry.registerBlock(blockNTNT, blockNTNT.getUnlocalizedName().substring(5));
              
              GameRegistry.registerBlock(blockAlloyFurnace, ItemBlockMetadata.class, "blockalloyfurnace");
              GameRegistry.registerBlock(testChest, testChest.getUnlocalizedName().substring(5));
              
              GameRegistry.registerWorldGenerator(new MineralGeneration(), 0);
              
              GameRegistry.registerTileEntity(TileEntityAlloyFurnace.class, "t4:TileEntityAlloyFurnace");
              GameRegistry.registerTileEntity(TileEntityBlockChest.class, "TileEntityBlockChest");
              
              }
              
              @EventHandler
              public void init(FMLInitializationEvent event) {
              NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
              proxy.registerRender();
              proxy.registerKeyBinding();
              FMLCommonHandler.instance().bus().register(new T4EventHandler());
              }
              
              @EventHandler
              public void postInit(FMLPostInitializationEvent event) {
              
              }
              
              public static CreativeTabs tabTesseract4 = new CreativeTabs("tabTesseract4") {
              @Override
              public Item getTabIconItem() {
              return new ItemStack(itemTopaze).getItem();
              }
              };
              }
              
              
              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

                L’instance est pourtant ok …
                Tu es sur que tu as bien un NPE sur cette ligne et non une autre ? Envoies le rapport de crash.

                1 réponse Dernière réponse Répondre Citer 0
                • DiabolicaTrixD Hors-ligne
                  DiabolicaTrix Correcteurs Moddeurs confirmés
                  dernière édition par

                  http://pastebin.com/0qvAwrYb

                  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

                    Le NPE se trouve ici :
                    at net.minecraft.inventory.Slot.getStack(Slot.java:88) ~[Slot.class:?]

                    public ItemStack getStack()
                    {
                    return this.inventory.getStackInSlot(this.slotIndex); // ligne 88
                    }
                    

                    Donc inventory est null alors qu’il ne devrait pas.
                    Et en effet dans ton container :

                    […]
                    public class ContainerAlloyFurnace extends Container {
                    
                    private TileEntityAlloyFurnace tileAlloyFurnace; // revient à faire private TileEntityAlloyFurnace tileAlloyFurnace = null;
                    
                    public ContainerAlloyFurnace(TileEntityAlloyFurnace tile, InventoryPlayer inventory)
                    {
                    
                    this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 0, 49, 75));
                    this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 1, 89, 75));
                    this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 2, 129, 75));
                    this.addSlotToContainer(new SlotResult(this.tileAlloyFurnace, 3, 89, 135));
                    this.bindPlayerInventory(inventory);
                    }
                    […]
                    

                    Regarde bien, this.tileAlloyFurnace est toujours null.
                    Il te manque la ligne this.tileAlloyFurnace = tile au début du constructeur.

                    1 réponse Dernière réponse Répondre Citer 0
                    • DiabolicaTrixD Hors-ligne
                      DiabolicaTrix Correcteurs Moddeurs confirmés
                      dernière édition par

                      Ah parfait, merci beaucoup, ça fonctionne!

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

                        J’avais une question , tu parle du nom de la machine mais même dans les photos le nom n’apparaît pas c’est normal ?

                        Oui ce gif est drôle.

                        1 réponse Dernière réponse Répondre Citer 0
                        • DiabolicaTrixD Hors-ligne
                          DiabolicaTrix Correcteurs Moddeurs confirmés
                          dernière édition par

                          Il ne l’a pas print 😛

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

                            Bonsoir,

                            Quand je fais un shift+click pour envoyer ou retirer un stack de la machine, il me reste un item fantôme dans le slot, que ça soit dans mon inventaire ou dans la machine. L’ItemStack n’est pas redéfini à null. Je pense que ça doit venir des fonctions getStackInSlotOnClosing(int index) et setInventorySlotContent(int index, ItemStack stack). Le problème, c’est que ce sont exactement les mêmes que dans le tuto… Voilà le code :

                            KrakPot.java :

                            package com.google.sleindarfeau.dragonQuestIX.common;
                            
                            import net.minecraft.block.Block;
                            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 KrakPot extends Block {
                            
                            protected KrakPot(Material material) {
                                 super(material);
                                 this.setCreativeTab(CreativeTabs.tabTools);
                                 this.setHardness(8.0F);
                            }
                            
                            @Override
                            public boolean hasTileEntity(int metadata) {
                                 return true;
                            }
                            
                            @Override
                            public TileEntity createTileEntity(World world, int metadata) {
                                 return new TileEntityKrakPot();
                            }
                            
                            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(DragonQuestIX.instance, 0, world, x, y, z);
                                 return true;
                                 }
                            }
                            
                            

                            TileEntityKrakPot.java :

                            
                            package com.google.sleindarfeau.dragonQuestIX.common;
                            
                            import java.util.Map.Entry;
                            
                            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;
                            import net.minecraftforge.common.util.Constants;
                            
                            public class TileEntityKrakPot extends TileEntity  implements IInventory {
                            
                            private ItemStack[] contents = new ItemStack[4];
                            private int workingTime = 0;
                            private int workingTimeNeeded = 40;
                            
                            @Override
                            public void readFromNBT(NBTTagCompound compound) {
                            super.readFromNBT(compound);
                            
                            NBTTagList tagList = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
                            this.contents = new ItemStack[this.getSizeInventory()];
                            for(int i = 0; i < tagList.tagCount(); ++i) {
                            NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
                            int j = tagCompound.getByte("Slot") & 255;
                            
                            if(j >= 0 && j < this.contents.length) {
                            this.contents* = ItemStack.loadItemStackFromNBT(tagCompound);
                            }
                            }
                            
                            this.workingTime = compound.getShort("WorkingTime");
                            this.workingTimeNeeded = compound.getShort("WorkingTimeNeeded");
                            }
                            
                            @Override
                            public void writeToNBT(NBTTagCompound compound) {
                            super.writeToNBT(compound);
                            
                            NBTTagList tagList = new NBTTagList();
                            for(int i = 0; i < this.contents.length; ++i) {
                            if(this.contents* != null) {
                            NBTTagCompound tagCompound = new NBTTagCompound();
                            tagCompound.setByte("Slot", (byte)i);
                            this.contents*.writeToNBT(tagCompound);
                            tagList.appendTag(tagCompound);
                            }
                            }
                            compound.setTag("Items", tagList);
                            compound.setShort("WorkingTime", (short)this.workingTime);
                            compound.setShort("WorkingTimeNeeded", (short)this.workingTimeNeeded);
                            }
                            
                            @Override
                            public int getSizeInventory() {
                            return this.contents.length;
                            }
                            
                            @Override
                            public ItemStack getStackInSlot(int index) {
                            return this.contents[index];
                            }
                            
                            @Override
                            public ItemStack decrStackSize(int index, int amt) {
                            if(this.contents[index] != null) {
                            ItemStack stack;
                            
                            if(this.contents[index].stackSize <= amt) {
                            stack = this.contents[index];
                            this.contents[index] = null;
                            this.markDirty();
                            return stack;
                            }
                            else {
                            stack = this.contents[index].splitStack(amt);
                            if(this.contents[index].stackSize == 0)
                            this.contents[index] = null;
                            this.markDirty();
                            return stack;
                            }
                            }
                            else {
                            return null;
                            }
                            }
                            
                            @Override
                            public ItemStack getStackInSlotOnClosing(int index) {
                            if(this.contents[index] != null) {
                            ItemStack stack = this.contents[index];
                            this.contents[index] = null;
                            return stack;
                            }
                            else {
                            return null;
                            }
                            }
                            
                            @Override
                            public void setInventorySlotContents(int index, ItemStack stack) {
                            this.contents[index] = stack;
                            if(stack != null && stack.stackSize > this.getInventoryStackLimit())
                            stack.stackSize = this.getInventoryStackLimit();
                            this.markDirty();
                            }
                            
                            @Override
                            public String getInventoryName() {
                            return "tile.KrakPot";
                            }
                            
                            @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)
                            return false;
                            else {
                            Entry entry = KrakPotRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]});
                            if(entry == null)
                            return false;
                            ItemStack stack = (ItemStack)entry.getValue();
                            if(this.contents[3] == null)
                            return true;
                            if(!this.contents[3].isItemEqual(stack))
                            return false;
                            int result = contents[3].stackSize + stack.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()) {
                            Entry entry = KrakPotRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]});
                            ItemStack stack = (ItemStack)entry.getValue();
                            ItemStack[] stackList = (ItemStack[])entry.getKey();
                            
                            if(this.contents[3] == null) {
                            this.contents[3] = stack.copy();
                            }
                            else if(this.contents[3].getItem() == stack.getItem()) {
                            this.contents[3].stackSize += stack.stackSize;
                            }
                            
                            if(stackList.length == 1) {
                            int i = this.contents[0] != null ? 0 : (this.contents[1] != null ? 1 : 2);
                            
                            this.contents*.stackSize -= stackList[0].stackSize;
                            if(this.contents*.stackSize <= 0)
                            this.contents* = null;
                            }
                            else if(stackList.length == 2) {
                            int j = this.contents[0] != null ? 0 : 1;
                            int k = this.contents[2] != null ? 2 : 1;
                            
                            this.contents[j].stackSize -= stackList[0].stackSize;
                            this.contents[k].stackSize -= stackList[1].stackSize;
                            if(this.contents[j].stackSize <= 0)
                            this.contents[j] = null;
                            if(this.contents[k].stackSize <= 0)
                            this.contents[k] = null;
                            }
                            else {
                            this.contents[0].stackSize -= stackList[0].stackSize;
                            this.contents[1].stackSize -= stackList[1].stackSize;
                            this.contents[2].stackSize -= stackList[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;
                            }
                            }
                            }
                            }
                            
                            

                            KrakPotRecipes.java :

                            package com.google.sleindarfeau.dragonQuestIX.common;
                            
                            import java.util.HashMap;
                            import java.util.Iterator;
                            import java.util.Map;
                            import java.util.Map.Entry;
                            
                            import net.minecraft.init.Blocks;
                            import net.minecraft.init.Items;
                            import net.minecraft.item.Item;
                            import net.minecraft.item.ItemStack;
                            
                            public class KrakPotRecipes {
                            
                            private static final KrakPotRecipes smeltingBase = new KrakPotRecipes();
                            private Map smeltingList1 = new HashMap();
                            private Map smeltingList2 = new HashMap();
                            private Map smeltingList3 = new HashMap();
                            
                            public KrakPotRecipes() {
                            this.addRecipe(new ItemStack(DragonQuestIX.medicinalHerb, 2), new ItemStack(DragonQuestIX.strongMedicine));
                            this.addRecipe(new ItemStack(DragonQuestIX.medicinalHerb), new ItemStack(DragonQuestIX.strongMedicine), new ItemStack(DragonQuestIX.superiorMedicine));
                            this.addRecipe(new ItemStack(DragonQuestIX.strongMedicine, 2), new ItemStack(DragonQuestIX.specialMedicine));
                            this.addRecipe(new ItemStack(DragonQuestIX.antidotalHerb), new ItemStack(DragonQuestIX.medicinalHerb), new ItemStack(DragonQuestIX.strongAntidote));
                            this.addRecipe(new ItemStack(DragonQuestIX.strongAntidote, 2),  new ItemStack(DragonQuestIX.specialAntidote));
                            this.addRecipe(new ItemStack(DragonQuestIX.moonwortBulb), new ItemStack(DragonQuestIX.strongMedicine), new ItemStack(DragonQuestIX.softwort));
                            this.addRecipe(new ItemStack(DragonQuestIX.softwort), new ItemStack(DragonQuestIX.moonwortBulb, 2), new ItemStack(DragonQuestIX.lunaria));
                            }
                            
                            public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4) {
                            ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
                            this.smeltingList3.put(stackList, stack4);
                            }
                            
                            public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3) {
                            ItemStack[] stackList = new ItemStack[]{stack1, stack2};
                            this.smeltingList2.put(stackList, stack3);
                            }
                            
                            public void addRecipe(ItemStack stack1, ItemStack stack2) {
                            ItemStack[] stackList = new ItemStack[]{stack1};
                            this.smeltingList1.put(stackList, stack2);
                            }
                            
                            public Entry getSmeltingResult(ItemStack[] stack) {
                            Entry entry;
                            Iterator it;
                            
                            if(stack[0] == null && stack[1] == null && stack[2] != null) {
                            ItemStack stack1 = stack[2];
                            stack = new ItemStack[]{stack1, null, null};
                            }
                            else if(stack[0] == null && stack[1] != null && stack[2] == null) {
                            ItemStack stack1 = stack[1];
                            stack = new ItemStack[]{stack1, null, null};
                            }
                            else if(stack[0] == null && stack[1] != null && stack[2] != null) {
                            ItemStack stack1 = stack[1], stack2 = stack[2];
                            stack = new ItemStack[]{stack1, stack2, null};
                            }
                            else if(stack[0] != null && stack[1] == null && stack[2] != null) {
                            ItemStack stack1 = stack[0], stack2 = stack[2];
                            stack = new ItemStack[]{stack1, stack2, null};
                            }
                            
                            if(stack[1] == null && stack[2] == null) {
                            ItemStack stack1 = stack[0];
                            stack = new ItemStack[]{stack1};
                            it = this.smeltingList1.entrySet().iterator();
                            }
                            else if(stack[1] != null && stack[2] == null) {
                            ItemStack stack1 = stack[0], stack2 = stack[1];
                            stack = new ItemStack[]{stack1, stack2};
                            it = this.smeltingList2.entrySet().iterator();
                            }
                            else {
                            it = this.smeltingList3.entrySet().iterator();
                            }
                            do {
                            if(!it.hasNext())
                            return null;
                            entry = (Entry)it.next();
                            } while(!this.isSameKey(stack, (ItemStack[])entry.getKey()));
                            return entry;
                            }
                            
                            private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2) {
                            boolean isSame = false;
                            
                            if(stackList.length == 1)
                            isSame = (stackList[0].getItem() == stackList2[0].getItem() && stackList[0].stackSize >= stackList2[0].stackSize);
                            else if(stackList.length == 2) {
                            for(int i = 0; i < stackList.length; i++) {
                            if((stackList2*.getItem() == stackList[0].getItem() && stackList2*.stackSize >= stackList[0].stackSize) || 
                              (stackList2*.getItem() == stackList[1].getItem() && stackList2*.stackSize >= stackList[1].stackSize))
                            isSame = true;
                            else
                            return false;
                            }
                            }
                            else if(stackList.length == 3) {
                            for(int i = 0; i < stackList.length; i++) {
                            if((stackList2*.getItem() == stackList[0].getItem() && stackList2*.stackSize >= stackList[0].stackSize) || 
                              (stackList2*.getItem() == stackList[1].getItem() && stackList2*.stackSize >= stackList[1].stackSize) ||
                              (stackList2*.getItem() == stackList[2].getItem() && stackList2*.stackSize >= stackList[2].stackSize))
                            isSame = true;
                            else
                            return false;
                            }
                            }
                            return isSame;
                            }
                            
                            public Map[] getSmeltingList() {
                            return new Map[]{smeltingList1, smeltingList2, smeltingList3};
                            }
                            
                            public static KrakPotRecipes smelting() {
                            return smeltingBase;
                            }
                            }
                            
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • SCAREXS Hors-ligne
                              SCAREX
                              dernière édition par

                              Les classes des recipe vont pas servir à grand chose, envoi les classes du 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
                              • S Hors-ligne
                                Sleindarfeau
                                dernière édition par

                                Voilà la classe du containerKrakPot :

                                package com.google.sleindarfeau.dragonQuestIX.common;
                                
                                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 ContainerKrakPot extends Container {
                                private final TileEntityKrakPot tileKrakPot;
                                
                                public ContainerKrakPot(TileEntityKrakPot tile, InventoryPlayer inventory) {
                                this.tileKrakPot = tile;
                                
                                this.addSlotToContainer(new Slot(tile, 0, 49, 75));
                                this.addSlotToContainer(new Slot(tile, 1, 89, 75));
                                this.addSlotToContainer(new Slot(tile, 2, 129, 75));
                                this.addSlotToContainer(new SlotResult(tile, 3, 89, 135));
                                
                                this.bindPlayerInventory(inventory);
                                }
                                
                                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 index) {
                                ItemStack stack = null;
                                Slot slot = (Slot)this.inventorySlots.get(index);
                                
                                if(slot != null && slot.getHasStack()) {
                                ItemStack stack1 = slot.getStack();
                                stack = stack1.copy();
                                
                                if(index < this.tileKrakPot.getSizeInventory()) {
                                if(!this.mergeItemStack(stack1, this.tileKrakPot.getSizeInventory(), this.inventorySlots.size(), true))
                                return null;
                                }
                                else if(!this.mergeItemStack(stack1, 0, this.tileKrakPot.getSizeInventory(), false)) {
                                return null;
                                }
                                
                                if(stack1.stackSize != 0)
                                slot.putStack((ItemStack)null);
                                else
                                slot.onSlotChanged();
                                }
                                return stack;
                                }
                                
                                @Override
                                public boolean canInteractWith(EntityPlayer player) {
                                return this.tileKrakPot.isUseableByPlayer(player);
                                }
                                
                                }
                                
                                
                                1 réponse Dernière réponse Répondre Citer 0
                                • 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
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 11
                                            • 12
                                            • 1 / 12
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB