Résolu Problème d'ouverture du GUI de mon four 1.7.10
-
Bonjour,
Je n’arrive pas, une fois mon tileentity container placé, à ouvrir son GUI.
Je n’ai pas de rapport de crash, alors voici mes classes :Ma classe principale (ModReality) :
package fr.minecraft.reality.common; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.minecraft.reality.proxy.CommonProxy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkSystem; import net.minecraftforge.common.util.EnumHelper; @Mod(modid = ModReality.MODID, name = "Mod Reality", version = "1.0.0") public class ModReality { public static final String MODID = "modreality"; @Instance(MODID) public static ModReality instance; @SidedProxy(clientSide = "fr.minecraft.reality.proxy.ClientProxy", serverSide = "fr.minecraft.reality.proxy.CommonProxy") public static CommonProxy proxy; //blocks public static Block plastic; public static Block compacted_plastic; public static Block craftingTable5x5; public static Block decomposeurChimique; public static Block petrolFurnace; //items //lingots public static Item plasticIngot; public static Item silverIngot; //armures public static Item silverHelmet; public static Item silverChestPlate; public static Item silverLeggins; public static Item silverBoots; //atomes public static Item atome_hydrogene; public static Item atome_helium; public static Item atome_lithium; public static Item atome_beryllium; public static Item atome_bore; public static Item atome_carbone; public static Item atome_azote; public static Item atome_oxygene; public static Item atome_fluor; public static Item atome_neon; public static Item atome_sodium; public static Item atome_magnesium; public static Item atome_aluminium; public static Item atome_silicium; public static Item atome_phosphore; public static Item atome_soufre; public static Item atome_chlore; public static Item atome_argon; //Creatives Tabs public static CreativeTabs tabAtomes = new CreativeTabs("atomes") { @SideOnly(Side.CLIENT) public Item getTabIconItem() { return ModReality.atome_hydrogene; } }; public static CreativeTabs tabPlastic = new CreativeTabs("plastic") { @SideOnly(Side.CLIENT) public Item getTabIconItem() { return ModReality.plasticIngot; } }; public static ArmorMaterial silverArmor = EnumHelper.addArmorMaterial("silverArmor", 13, new int[]{2, 6, 4, 2}, 17); //fonction de pré-initialisation @EventHandler public void preInit(FMLPreInitializationEvent event) { //blocks plastic = new Plastic(Material.rock).setBlockName("plastic").setHardness(1.5F).setResistance(8.0F).setBlockTextureName(MODID + ":plastic").setCreativeTab(tabPlastic); compacted_plastic = new Plastic(Material.rock).setHardness(1.5F).setResistance(11.0F).setBlockName("compacted_plastic").setBlockTextureName(MODID + ":compacted_plastic").setCreativeTab(tabPlastic); decomposeurChimique = new DecomposeurChimique().setHardness(1.5F).setResistance(10.0F).setBlockName("decomposeur_chimique").setBlockTextureName(MODID + ":decomposeur_chimique").setCreativeTab(tabAtomes); craftingTable5x5 = new CraftingTable5x5().setHardness(2.0F).setResistance(5.0F).setBlockName("crafting_table_5x5").setStepSound(Block.soundTypeWood).setCreativeTab(CreativeTabs.tabDecorations); petrolFurnace = new PetrolFurnace().setHardness(3.5F).setStepSound(Block.soundTypePiston).setResistance(9.0F).setBlockName("petrol_furnace").setCreativeTab(CreativeTabs.tabDecorations); //items plasticIngot = new PlasticIngot().setUnlocalizedName("plasticIngot").setTextureName(MODID + ":plastic_ingot").setCreativeTab(tabPlastic); silverIngot = new SilverIngot().setUnlocalizedName("silverIngot").setTextureName(MODID + ":silver_ingot").setCreativeTab(CreativeTabs.tabMaterials); //armures silverHelmet = new ItemSilverArmor(silverArmor, 0).setUnlocalizedName("silverHelmet").setTextureName(MODID + ":silver_helmet"); silverChestPlate = new ItemSilverArmor(silverArmor, 1).setUnlocalizedName("silverChestPlate").setTextureName(MODID + ":silver_chestplate"); silverLeggins = new ItemSilverArmor(silverArmor, 2).setUnlocalizedName("silverLeggins").setTextureName(MODID + ":silver_leggins"); silverBoots = new ItemSilverArmor(silverArmor, 3).setUnlocalizedName("silverBoots").setTextureName(MODID + ":silver_boots"); //atomes atome_hydrogene = new Item().setUnlocalizedName("atome_hydrogene").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_hydrogene"); atome_helium = new Item().setUnlocalizedName("atome_helium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_helium"); atome_lithium = new Item().setUnlocalizedName("atome_lithium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_lithium"); atome_beryllium = new Item().setUnlocalizedName("atome_beryllium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_beryllium"); atome_bore = new Item().setUnlocalizedName("atome_bore").setCreativeTab(ModReality.tabAtomes).setTextureName(MODID + ":atome_bore"); atome_carbone = new Item().setUnlocalizedName("atome_carbone").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_carbone"); atome_azote = new Item().setUnlocalizedName("atome_azote").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_azote"); atome_oxygene = new Item().setUnlocalizedName("atome_oxygene").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_oxygene"); atome_fluor = new Item().setUnlocalizedName("atome_fluor").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_fluor"); atome_neon = new Item().setUnlocalizedName("atome_neon").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_neon"); atome_sodium = new Item().setUnlocalizedName("atome_sodium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_sodium"); atome_magnesium = new Item().setUnlocalizedName("atome_magnesium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_magnesium"); atome_aluminium = new Item().setUnlocalizedName("atome_aluminium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_aluminium"); atome_silicium = new Item().setUnlocalizedName("atome_silicium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_silicium"); atome_phosphore = new Item().setUnlocalizedName("atome_phosphore").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_phosphore"); atome_soufre = new Item().setUnlocalizedName("atome_soufre").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_soufre"); atome_chlore = new Item().setUnlocalizedName("atome_chlore").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_chlore"); atome_argon = new Item().setUnlocalizedName("atome_argon").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_argon"); //enregistrement des blocks GameRegistry.registerBlock(plastic, "plastic"); GameRegistry.registerBlock(compacted_plastic, "compacted_plastic"); GameRegistry.registerBlock(craftingTable5x5, "craftingTable5x5"); GameRegistry.registerBlock(decomposeurChimique, "decomposeurChimique"); GameRegistry.registerBlock(petrolFurnace, "petrolFurnace"); //enregistrement des items //lingots GameRegistry.registerItem(plasticIngot, "plasticIngot"); GameRegistry.registerItem(silverIngot, "silverIngot"); //armures GameRegistry.registerItem(silverHelmet, "silver_helmet"); GameRegistry.registerItem(silverChestPlate, "silver_chest_plate"); GameRegistry.registerItem(silverLeggins, "silver_leggins"); GameRegistry.registerItem(silverBoots, "silver_boots"); //atomes GameRegistry.registerItem(atome_hydrogene, "atome_hydrogene"); GameRegistry.registerItem(atome_helium, "atome_helium"); GameRegistry.registerItem(atome_lithium, "atome_lithium"); GameRegistry.registerItem(atome_beryllium, "atome_beryllium"); GameRegistry.registerItem(atome_bore, "atome_bore"); GameRegistry.registerItem(atome_carbone, "atome_carbone"); GameRegistry.registerItem(atome_azote, "atome_azote"); GameRegistry.registerItem(atome_oxygene, "atome_oxygene"); GameRegistry.registerItem(atome_fluor, "atome_fluor"); GameRegistry.registerItem(atome_neon, "atome_neon"); GameRegistry.registerItem(atome_sodium, "atome_sodium"); GameRegistry.registerItem(atome_magnesium, "atome_magnesium"); GameRegistry.registerItem(atome_aluminium, "atome_aluminium"); GameRegistry.registerItem(atome_silicium, "atome_silicium"); GameRegistry.registerItem(atome_phosphore, "atome_phosphore"); GameRegistry.registerItem(atome_soufre, "atome_soufre"); GameRegistry.registerItem(atome_chlore, "atome_chlore"); GameRegistry.registerItem(atome_argon, "atome_argon"); //TileEntity GameRegistry.registerTileEntity(TileEntityPetrolFurnace.class, MODID + "PetrolFunace"); } //fonction d'initialisation @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); } //fonction de post-initialisation @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
Mon block (PetrolFurnace) :
package fr.minecraft.reality.common; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; 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 PetrolFurnace extends Block { protected PetrolFurnace() { super(Material.rock); } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityPetrolFurnace(); } @Override public boolean hasTileEntity(int metadata) { return true; } 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(ModReality.instance, 0, world, x, y, z); return true; } } public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { TileEntity tileentity = world.getTileEntity(x, y, z); if(tileentity instanceof IInventory) { IInventory inv = (IInventory)tileentity; for(int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if(itemstack != null) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for(float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if(j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3); entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3); if(itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } world.func_147453_f(x, y, z, block); } super.breakBlock(world, x, y, z, block, metadata); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityPetrolFurnace) { if(stack.hasDisplayName()) { ((TileEntityPetrolFurnace)tile).setCustomName(stack.getDisplayName()); } } } }
Mon tileentity (TileEntityPetrolFurnace) :
package fr.minecraft.reality.common; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; 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; import net.minecraftforge.common.util.Constants; public class TileEntityPetrolFurnace extends TileEntity implements IInventory { private ItemStack[] contents = new ItemStack[4]; private String customName; //Temps de cuisson actuel private int workingTime = 0; //Temps de cuisson nécessaire private int workingTimeNeeded = 200; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); // exécute ce qui se trouve dans la fonction readFromNBT de la classe mère (lecture de la position du tile entity) if(compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) // si un tag custom name de type string existe { this.customName = compound.getString("CustomName"); // on le lit } NBTTagList nbttaglist = compound.getTagList("Items", 10); // on obtient la liste de tags nommée Items this.contents = new ItemStack[this.getSizeInventory()]; // on réinitialise le tableau for(int i = 0; i < nbttaglist.tagCount(); ++i) // i varie de 0 à la taille la liste { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); // on lit le tag nbt int j = nbttagcompound1.getByte("Slot") & 255; // on lit à quel slot se trouve l'item stack if(j >= 0 && j < this.contents.length) { this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); // on lit l'item stack qui se trouve dans le tag } } } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); // exécute se qui se trouve dans la fonction writeToNBT de la classe mère (écriture de la position du tile entity) if(this.hasCustomInventoryName()) // s'il y a un nom custom { compound.setString("CustomName", this.customName); // on le met dans le tag nbt } NBTTagList nbttaglist = new NBTTagList(); // on créé une nouvelle liste de tags for(int i = 0; i < this.contents.length; ++i) // i varie de 0 à la taille de notre tableau { if(this.contents[ i] != null) // si l'item stack à l'emplacement i du tableau n'est pas null { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); // on créé un tag nbt nbttagcompound1.setByte("Slot", (byte)i); // on enregistre son emplacement dans le tableau this.contents[ i].writeToNBT(nbttagcompound1); // on écrit l'item dans le tag nbttaglist.appendTag(nbttagcompound1); // on ajoute le tab à la liste } } compound.setTag("Items", nbttaglist); compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded); } 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()); } @Override public int getSizeInventory() { return this.contents.length; } @Override public ItemStack getStackInSlot(int slotIndex) { return this.contents[slotIndex]; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { if(this.contents[slotIndex] != null) // si le contenu dans l'emplacement n'est pas null { ItemStack itemstack; if(this.contents[slotIndex].stackSize <= amount) // si la quantité est inférieur où égale à ce qu'on souhaite retirer { itemstack = this.contents[slotIndex]; // la variable itemstack prends la valeur du contenu this.contents[slotIndex] = null; // on retire ce qui est dans la variable contents this.markDirty(); // met à jour le tile entity return itemstack; // renvoie itemstack } else // sinon { itemstack = this.contents[slotIndex].splitStack(amount); // la fonction splitStack(quantité) retire dans this.contents[slotIndex] le contenu et le met dans itemstack if(this.contents[slotIndex].stackSize == 0) // au cas où la quantité passe à 0 (ce qui ne devrait pas arriver en temps normal) { this.contents[slotIndex] = null; // on met sur null, ça évite de se retrouver avec des itemstack bugué qui contiennent 0 } this.markDirty(); // met à jour le tile entity return itemstack; // renvoie itemstack } } else // sinon si le contenu dans cette emplacement est null { return null; // renvoie null, puisqu'il n'y a rien dans cette emplacement } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; // met l'item stack dans le tableau if(stack != null && stack.stackSize > this.getInventoryStackLimit()) // si la taille de l'item stack dépasse la limite maximum de l'inventaire { stack.stackSize = this.getInventoryStackLimit(); // on le remet sur la limite } this.markDirty(); // met à jour le tile entity } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "tile.petrolFurnace"; } public void setCustomName(String customName) { this.customName = customName; } @Override public int getInventoryStackLimit() { return 64; } @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 boolean hasCustomInventoryName() { return false; } @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) //Si les trois premiers slots sont vides { return false; //On ne peut pas lancer le processus } else { ItemStack itemstack = PetrolFurnaceRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes) if (itemstack == null) return false; //rapport avec les recettes if (this.contents[3] == null) return true; //vérifications du slot d'output if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi int result = contents[3].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément } } public void updateEntity() //Méthode exécutée à chaque tick { if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue { ++this.workingTime; //incrémentation } if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance { this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0) } if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne { this.smeltItem(); //on "cuit" les items this.workingTime = 0; //et on réinitialise le temps de cuisson } if(!this.canSmelt()) //Si la recette la recette n'est plus bonne { this.workingTime= 0; //le temps de cuisson est de 0 } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = PetrolFurnaceRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette if (this.contents[3] == null) //Si il y a rien dans le slot d'output { this.contents[3] = itemstack.copy(); //On met directement l'ItemStack } else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà { this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack } --this.contents[0].stackSize; //On décrémente les slots d'input --this.contents[1].stackSize; --this.contents[2].stackSize; if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot { this.contents[0] = null; } if (this.contents[1].stackSize <= 0) { this.contents[1] = null; } if (this.contents[2].stackSize <= 0) { this.contents[2] = null; } } } }
Mon container (PetrolFurnaceContainer) :
package fr.minecraft.reality.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 PetrolFurnaceContainer extends Container { private final TileEntityPetrolFurnace tilePetrolFurnace; public PetrolFurnaceContainer(TileEntityPetrolFurnace tile, InventoryPlayer inventory) { this.tilePetrolFurnace = tile; this.addSlotToContainer(new Slot(tile, 0, 49, 75)); //Lancez votre jeu en debug pour calibrer vos slots this.addSlotToContainer(new Slot(tile, 1, 89, 75)); this.addSlotToContainer(new Slot(tile, 2, 129, 75)); this.addSlotToContainer(new SlotResult(tile, 3, 89, 135)); //Ici c'est un slot que j'ai créer, on le fera après this.bindPlayerInventory(inventory); //Les containers ont été vus dans un tutoriel de robin, merci de d'y référer } @Override public boolean canInteractWith(EntityPlayer player) { return this.tilePetrolFurnace.isUseableByPlayer(player); } private void bindPlayerInventory(InventoryPlayer inventory) { int i; for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229)); } } public ItemStack transferStackInSlot(EntityPlayer player, int quantity) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(quantity); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (quantity < this.tilePetrolFurnace.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.tilePetrolFurnace.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(itemstack1, 0, this.tilePetrolFurnace.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.tilePetrolFurnace.closeInventory(); } }
Mes recettes (PetrolFurnaceRecipes) :
package fr.minecraft.reality.common; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class PetrolFurnaceRecipes { private static final PetrolFurnaceRecipes smeltingBase = new PetrolFurnaceRecipes(); //Permet d'instancier votre classe car vous le l'instancierez nul part ailleur private Map smeltingList = new HashMap(); //Ceci permet de mettre vos recettes public PetrolFurnaceRecipes() { this.addRecipe(Items.apple, Items.apple, Items.arrow, new ItemStack(Blocks.diamond_block)); //Ajout d'une recette, on fait un bloc de diamant à partie de deux pommes et une flèche } public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4) //Cette fonction de comprend que des ItemStack, c'est celle qui ajoute les recettes à la HashMap { ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3}; this.smeltingList.put(stackList, stack4); } //3 items public void addRecipe(Item item1, Item item2, Item item3, ItemStack stack) //1er cas { this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), stack); } //1 block et 2 items public void addRecipe(Block block1, Item item2, Item item3, ItemStack stack) //2nd cas { this.addRecipe(Item.getItemFromBlock(block1), item2, item3, stack); } //2 blocks et 1 item public void addRecipe(Block block1, Block block2, Item item3, ItemStack stack) //3ème cas { this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, stack); } //3 blocks public void addRecipe(Block block1, Block block2, Block block3, ItemStack stack) //4ème cas { this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), stack); } public ItemStack getSmeltingResult(ItemStack[] stack) // En argument : un tableau avec le contenu des trois slots d'input { Iterator iterator = this.smeltingList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) // Si il n'y a plus de recettes dans la liste { return null; //Il n'y a pas de recette correspondante } entry = (Entry)iterator.next(); //prend la recette suivante } while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); //Check si le tableau passé en argument correspond à celui de la recette, vous avez une erreur ici, on crée la fonction tout de suite. return (ItemStack)entry.getValue(); //retourne l'itemstack : resultat de la recette } private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2) { boolean isSame = false; //Au début ce n'est pas la même for(int i=0; i<=2; i++) // Pour les 3 items { if(stackList[i].getItem() == stackList2[i].getItem()) //On vérifie si ce sont les même { isSame = true; // Si c'est le cas alors isSame vaut true } else { return false; //Si un seul n'est pas bon, on cherche pas, c'est pas la bonne recette } } return isSame; } public Map getSmeltingList() { return this.smeltingList; } public static PetrolFurnaceRecipes smelting() { return smeltingBase; } }
Ma classe de résultat (SlotResult) :
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotResult extends Slot { public SlotResult(IInventory inventory, int id, int x, int y) { super(inventory, id, x, y); } @Override public boolean isItemValid(ItemStack stack) //Interdit la pose d'items dans le slot { return false; } public ItemStack decrStackSize(int amount) { return super.decrStackSize(amount); } public void onPickupFromSlot(EntityPlayer player, ItemStack stack) { super.onCrafting(stack); super.onPickupFromSlot(player, stack); } }
Mon Gui (GuiPetrolFurnace) :
package fr.minecraft.reality.common; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; public class GuiPetrolFurnace extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation(ModReality.MODID,"textures/gui/container/guiMachineTuto.png"); @SuppressWarnings("unused") private TileEntityPetrolFurnace tilePetrolFurnace; private IInventory playerInv; public GuiPetrolFurnace(TileEntityPetrolFurnace tile, InventoryPlayer inventory) { super(new PetrolFurnaceContainer(tile, inventory)); this.tilePetrolFurnace = tile; this.playerInv = inventory; this.allowUserInput = false; this.ySize = 256; this.xSize = 256; } @Override protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(0, 0, 176, 14, 100 + 1, 16); } protected void drawGuiContainerForegroundLayer(int x, int y) { this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752); } }
PS: certaines lignes ne veulent sûrement rien dire ou le/les problèmes peuvent être évidents.
Merci d’avance -
Bonjour,
Il manque le gui handler, vérifies que tu en as bien un et qu’il est bien enregistré. -
Merci beaucoup, je m’améliore grâce à vous
-
Bonjour j’ai repris ton code mais j’ai une erreur quand je pose le four
---- Minecraft Crash Report ---- // Don't be sad. I'll do better next time, I promise! Time: 18/11/19 15:57 Description: Exception ticking world java.lang.RuntimeException: class fr.r0x4s.cite4.tileentity.TileEntityFour is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96) at fr.r0x4s.cite4.tileentity.TileEntityFour.writeToNBT(TileEntityFour.java:72) at fr.r0x4s.cite4.tileentity.TileEntityFour.getDescriptionPacket(TileEntityFour.java:115) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:632) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:574) at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:80) at net.minecraft.world.WorldServer.tick(WorldServer.java:193) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692) 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 net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96) at fr.r0x4s.cite4.tileentity.TileEntityFour.writeToNBT(TileEntityFour.java:72) at fr.r0x4s.cite4.tileentity.TileEntityFour.getDescriptionPacket(TileEntityFour.java:115) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendTileToAllPlayersWatchingChunk(PlayerManager.java:632) at net.minecraft.server.management.PlayerManager$PlayerInstance.sendChunkUpdate(PlayerManager.java:574) at net.minecraft.server.management.PlayerManager.updatePlayerInstances(PlayerManager.java:80) at net.minecraft.world.WorldServer.tick(WorldServer.java:193) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Player385'/347, l='New World', x=-153,28, y=70,00, z=257,18]] Chunk stats: ServerChunkCache: 683 Drop: 0 Level seed: -4580569012153532039 Level generator: ID 00 - default, ver 1. Features enabled: true Level generator options: Level spawn location: World: (-156,64,256), Chunk: (at 4,4,0 in -10,16; contains blocks -160,0,256 to -145,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 315862 game time, 1341 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 5362 (now: false), thunder time: 62331 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_211, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 862255904 bytes (822 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA cite4{0.1} [Cité 4] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player385'/347, l='New World', x=-153,28, y=70,00, z=257,18]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
-
Donc je sait pas si toi @Binaire ou @robin4002 vous pourriez m’aider
-
C’est sur que copié une classe comme sa … C’est moyen
Essaye de regarder déjà à quoi correspond ce qu’il y’a dans ses classes. -
Il faut enregistrer le tile entity.
-
Dac merci j’avais pas fait gaffe a enregistrer le Titleentity
serrai tu a quoi correspond cette erreur @robin4002 ?
en gros quand je veux faire cuire un item sa crash et sa de dit sa---- Minecraft Crash Report ---- // My bad. Time: 19/11/19 12:08 Description: Ticking block entity java.lang.ClassCastException: net.minecraft.tileentity.TileEntityFurnace cannot be cast to fr.r0x4s.cite4.tileentity.TileEntityFourTest at fr.r0x4s.cite4.blocks.fourTest.breakBlock(fourTest.java:182) at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:658) at net.minecraft.world.World.setBlock(World.java:519) at net.minecraft.world.World.setBlock(World.java:681) at net.minecraft.block.BlockFurnace.updateFurnaceBlockState(BlockFurnace.java:138) at net.minecraft.tileentity.TileEntityFurnace.updateEntity(TileEntityFurnace.java:289) at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) 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.r0x4s.cite4.blocks.fourTest.breakBlock(fourTest.java:182) at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:658) at net.minecraft.world.World.setBlock(World.java:519) at net.minecraft.world.World.setBlock(World.java:681) at net.minecraft.block.BlockFurnace.updateFurnaceBlockState(BlockFurnace.java:138) at net.minecraft.tileentity.TileEntityFurnace.updateEntity(TileEntityFurnace.java:289) -- Block entity being ticked -- Details: Name: Furnace // net.minecraft.tileentity.TileEntityFurnace Block type: ID #180 (tile.fourTest // fr.r0x4s.cite4.blocks.fourTest) Block data value: 4 / 0x4 / 0b0100 Block location: World: (-151,70,257), Chunk: (at 9,4,1 in -10,16; contains blocks -160,0,256 to -145,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Actual block type: ID #62 (tile.furnace // net.minecraft.block.BlockFurnace) Actual block data value: 0 / 0x0 / 0b0000 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) -- Affected level -- Details: Level name: New World All players: 1 total; [EntityPlayerMP['Player412'/347, l='New World', x=-153,03, y=70,00, z=257,70]] Chunk stats: ServerChunkCache: 721 Drop: 0 Level seed: -4580569012153532039 Level generator: ID 00 - default, ver 1. Features enabled: true Level generator options: Level spawn location: World: (-156,64,256), Chunk: (at 4,4,0 in -10,16; contains blocks -160,0,256 to -145,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 347061 game time, 25839 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 131415 (now: false), thunder time: 116021 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_211, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 700898480 bytes (668 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA cite4{0.1} [Cité 4] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player412'/347, l='New World', x=-153,03, y=70,00, z=257,70]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
-
Ton problème se trouve dans la classe fourTest à la ligne 182, dans laquelle il y a un cast invalide.
-
@robin4002
J’ai repris le code de base de minecraft mais je vois pas trop se qui vas pasLigne 182
TileEntityFourTest tileentityfourtest = (TileEntityFourTest) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
-
class fourTest:
package fr.r0x4s.cite4.blocks; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.r0x4s.cite4.Cite4; import fr.r0x4s.cite4.tileentity.TileEntityFourTest; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class fourTest extends BlockContainer { private final Random field_149933_a = new Random(); private final boolean field_149932_b; private static boolean field_149934_M; @SideOnly(Side.CLIENT) private IIcon field_149935_N; @SideOnly(Side.CLIENT) private IIcon field_149936_O; private static final String __OBFID = "CL_00000248"; public fourTest(boolean rock) { super(Material.rock); this.field_149932_b = rock; } public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(Blocks.furnace); } /** * Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); this.func_149930_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); } private void func_149930_e(World p_149930_1_, int p_149930_2_, int p_149930_3_, int p_149930_4_) { if (!p_149930_1_.isRemote) { Block block = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ - 1); Block block1 = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ + 1); Block block2 = p_149930_1_.getBlock(p_149930_2_ - 1, p_149930_3_, p_149930_4_); Block block3 = p_149930_1_.getBlock(p_149930_2_ + 1, p_149930_3_, p_149930_4_); byte b0 = 3; if (block.func_149730_j() && !block1.func_149730_j()) { b0 = 3; } if (block1.func_149730_j() && !block.func_149730_j()) { b0 = 2; } if (block2.func_149730_j() && !block3.func_149730_j()) { b0 = 5; } if (block3.func_149730_j() && !block2.func_149730_j()) { b0 = 4; } p_149930_1_.setBlockMetadataWithNotify(p_149930_2_, p_149930_3_, p_149930_4_, b0, 2); } } /** * Gets the block's texture. Args: side, meta */ @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { return p_149691_1_ == 1 ? this.field_149935_N : (p_149691_1_ == 0 ? this.field_149935_N : (p_149691_1_ != p_149691_2_ ? this.blockIcon : this.field_149936_O)); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.blockIcon = p_149651_1_.registerIcon("four_side"); this.field_149936_O = p_149651_1_.registerIcon(this.field_149932_b ? "four_front_on" : "four_front_off"); this.field_149935_N = p_149651_1_.registerIcon("four_top"); } /** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isRemote) { return true; } else { TileEntityFurnace tileentityfurnace = (TileEntityFurnace) p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (tileentityfurnace != null) { p_149727_5_.func_146101_a(tileentityfurnace); } return true; } } /** * Update which block the furnace is using depending on whether or not it is * burning */ public static void updateFurnaceBlockState(boolean p_149931_0_, World p_149931_1_, int p_149931_2_, int p_149931_3_, int p_149931_4_) { int l = p_149931_1_.getBlockMetadata(p_149931_2_, p_149931_3_, p_149931_4_); TileEntity tileentity = p_149931_1_.getTileEntity(p_149931_2_, p_149931_3_, p_149931_4_); field_149934_M = true; if (p_149931_0_) { p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, Blocks.lit_furnace); } else { p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, Blocks.furnace); } field_149934_M = false; p_149931_1_.setBlockMetadataWithNotify(p_149931_2_, p_149931_3_, p_149931_4_, l, 2); if (tileentity != null) { tileentity.validate(); p_149931_1_.setTileEntity(p_149931_2_, p_149931_3_, p_149931_4_, tileentity); } } /** * Returns a new instance of a block's tile entity class. Called on placing the * block. */ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityFurnace(); } /** * Called when the block is placed in the world. */ public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { int l = MathHelper.floor_double((double) (p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2, 2); } if (l == 1) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 5, 2); } if (l == 2) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3, 2); } if (l == 3) { p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 4, 2); } if (p_149689_6_.hasDisplayName()) { ((TileEntityFourTest) p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)) .func_145951_a(p_149689_6_.getDisplayName()); } } public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) { if (!field_149934_M) { TileEntityFourTest tileentityfourtest = (TileEntityFourTest) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); if (tileentityfourtest != null) { for (int i1 = 0; i1 < tileentityfourtest.getSizeInventory(); ++i1) { ItemStack itemstack = tileentityfourtest.getStackInSlot(i1); if (itemstack != null) { float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; while (itemstack.stackSize > 0) { int j1 = this.field_149933_a.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; EntityItem entityitem = new EntityItem(p_149749_1_, (double) ((float) p_149749_2_ + f), (double) ((float) p_149749_3_ + f1), (double) ((float) p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); if (itemstack.hasTagCompound()) { entityitem.getEntityItem() .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } float f3 = 0.05F; entityitem.motionX = (double) ((float) this.field_149933_a.nextGaussian() * f3); entityitem.motionY = (double) ((float) this.field_149933_a.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) this.field_149933_a.nextGaussian() * f3); p_149749_1_.spawnEntityInWorld(entityitem); } } } p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); } } super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); } /** * A randomly called display update to be able to add particles or other items * for display */ @SideOnly(Side.CLIENT) public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) { if (this.field_149932_b) { int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); float f = (float) p_149734_2_ + 0.5F; float f1 = (float) p_149734_3_ + 0.0F + p_149734_5_.nextFloat() * 6.0F / 16.0F; float f2 = (float) p_149734_4_ + 0.5F; float f3 = 0.52F; float f4 = p_149734_5_.nextFloat() * 0.6F - 0.3F; if (l == 4) { p_149734_1_.spawnParticle("smoke", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double) (f - f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 5) { p_149734_1_.spawnParticle("smoke", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double) (f + f3), (double) f1, (double) (f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 2) { p_149734_1_.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 - f3), 0.0D, 0.0D, 0.0D); } else if (l == 3) { p_149734_1_.spawnParticle("smoke", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double) (f + f4), (double) f1, (double) (f2 + f3), 0.0D, 0.0D, 0.0D); } } } /** * If this returns true, then comparators facing away from this block will use * the value from getComparatorInputOverride instead of the actual redstone * signal strength. */ public boolean hasComparatorInputOverride() { return true; } /** * If hasComparatorInputOverride returns true, the return value from this is * used instead of the redstone signal strength when this block inputs to a * comparator. */ /** * Gets an item for the block being called on. Args: world, x, y, z */ @SideOnly(Side.CLIENT) public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { return Item.getItemFromBlock(Cite4.fourTest); } }
-
Dans ta fonction createNewTileEntity tu créés un
TileEntityFurnace
pas étonnant d’avoir des soucis ensuite …