• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Un four "entité" qui ne fonctionne pas

    1.8.x
    4
    13
    1654
    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.
    • Ama
      Ama dernière édition par

      Bien le bonjoir !

      Je cherche à faire un piti mod sympa, et j’aimerais que mon entité puisse fonctionner comme le four, avec la cuisson des items, leurs sauvegardes etc…

      Le problème c’est que je me suis inspiré de la tile entity du four son container et son gui, et que les item une fois dans les slots dédiés ne cuisent pas et quand je quitte le gui ne se sauvegarde pas dedans.

      Je suis conscient que le problème viens des nbt, mais les nbt et moi ça fait deux…

      Je vous donne mes classes:

      :::

      package fr.zeamateis.livingutilities.common.entity;
      
      import fr.zeamateis.livingutilities.common.core.LivingUtilitiesCore;
      import net.minecraft.block.state.IBlockState;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.init.Blocks;
      import net.minecraft.init.Items;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.inventory.SlotFurnaceFuel;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.item.crafting.FurnaceRecipes;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.nbt.NBTTagList;
      import net.minecraft.tileentity.TileEntityFurnace;
      import net.minecraft.util.ChatComponentTranslation;
      import net.minecraft.util.IChatComponent;
      import net.minecraft.world.World;
      
      public class EntityLivingFurnace extends EntityUtilitiesBlock implements IInventory {
      
      public ItemStack[] furnaceItemStacks = new ItemStack[3];
      public int furnaceBurnTime;
      public int currentItemBurnTime;
      public int cookTime;
      public int totalCookTime;
      public String furnaceCustomName;
      
      public EntityLivingFurnace(World world) {// TileEntityFurnace
      super(world);
      }
      
      public void applyEntityAttributes() {
      super.applyEntityAttributes();
      }
      
      public void onUpdate() {
      super.onUpdate();
      }
      
      public void onLivingUpdate() {
      super.onLivingUpdate();
      }
      
      public void readEntityFromNBT(NBTTagCompound tagCompound) {
      super.readEntityFromNBT(tagCompound);
      NBTTagList nbttaglist = tagCompound.getTagList("Items", 10);
      this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
      
      for (int i = 0; i < nbttaglist.tagCount(); ++i) {
      NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
      byte b0 = nbttagcompound1.getByte("Slot");
      
      if (b0 >= 0 && b0 < this.furnaceItemStacks.length) {
      this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
      }
      
      this.furnaceBurnTime = tagCompound.getShort("BurnTime");
      this.cookTime = tagCompound.getShort("CookTime");
      this.totalCookTime = tagCompound.getShort("CookTimeTotal");
      // this.currentItemBurnTime = getCookTime(this.furnaceItemStacks[1]);
      
      if (tagCompound.hasKey("CustomName", 8)) {
      this.furnaceCustomName = tagCompound.getString("CustomName");
      }
      }
      
      public void writeEntityToNBT(NBTTagCompound tagCompound) {
      
      super.writeEntityToNBT(tagCompound);
      tagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);
      tagCompound.setShort("CookTime", (short) this.cookTime);
      tagCompound.setShort("CookTimeTotal", (short) this.totalCookTime);
      NBTTagList nbttaglist = new NBTTagList();
      
      for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
      if (this.furnaceItemStacks* != null) {
      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
      nbttagcompound1.setByte("Slot", (byte) i);
      this.furnaceItemStacks*.writeToNBT(nbttagcompound1);
      nbttaglist.appendTag(nbttagcompound1);
      }
      }
      
      tagCompound.setTag("Items", nbttaglist);
      
      if (this.hasCustomName()) {
      tagCompound.setString("CustomName", this.furnaceCustomName);
      }
      }
      
      @Override
      public boolean interact(EntityPlayer player) {
      if (!player.worldObj.isRemote) {
      player.openGui(LivingUtilitiesCore.getInstance(), 1, player.worldObj, this.getEntityId(), 0, 0);
      }
      return true;
      }
      
      public IBlockState getBlock() {
      return Blocks.furnace.getDefaultState();
      }
      
      public String getName() {
      return this.hasCustomName() ? this.furnaceCustomName : "container.furnace";
      }
      
      @Override
      public boolean hasCustomName() {
      return this.furnaceCustomName != null && this.furnaceCustomName.length() > 0;
      }
      
      public void setCustomInventoryName(String name) {
      this.furnaceCustomName = name;
      }
      
      @Override
      public IChatComponent getDisplayName() {
      return new ChatComponentTranslation("container.furnace");
      }
      
      @Override
      public int getSizeInventory() {
      return this.furnaceItemStacks.length;
      }
      
      @Override
      public ItemStack getStackInSlot(int index) {
      return this.furnaceItemStacks[index];
      }
      
      @Override
      public ItemStack decrStackSize(int index, int count) {
      if (this.furnaceItemStacks[index] != null) {
      ItemStack itemstack;
      
      if (this.furnaceItemStacks[index].stackSize <= count) {
      itemstack = this.furnaceItemStacks[index];
      this.furnaceItemStacks[index] = null;
      return itemstack;
      }
      itemstack = this.furnaceItemStacks[index].splitStack(count);
      
      if (this.furnaceItemStacks[index].stackSize == 0) {
      this.furnaceItemStacks[index] = null;
      }
      
      return itemstack;
      }
      return null;
      }
      
      @Override
      public ItemStack getStackInSlotOnClosing(int index) {
      if (this.furnaceItemStacks[index] != null) {
      ItemStack itemstack = this.furnaceItemStacks[index];
      this.furnaceItemStacks[index] = null;
      return itemstack;
      }
      return null;
      }
      
      @Override
      public void setInventorySlotContents(int index, ItemStack stack) {
      boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
      this.furnaceItemStacks[index] = stack;
      
      if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
      stack.stackSize = this.getInventoryStackLimit();
      }
      
      if (index == 0 && !flag) {
      this.totalCookTime = this.getCookTime();
      this.cookTime = 0;
      this.markDirty();
      }
      }
      
      @Override
      public int getInventoryStackLimit() {
      return 64;
      }
      
      @Override
      public void markDirty() {
      
      }
      
      @Override
      public boolean isUseableByPlayer(EntityPlayer player) {
      return player != null;
      }
      
      @Override
      public void openInventory(EntityPlayer player) {
      
      }
      
      @Override
      public void closeInventory(EntityPlayer player) {
      
      }
      
      @Override
      public boolean isItemValidForSlot(int index, ItemStack stack) {
      return index == 2 ? false : (index != 1 ? true : TileEntityFurnace.isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack));
      }
      
      @Override
      public int getField(int id) {
      switch (id) {
      case 0:
      return this.furnaceBurnTime;
      case 1:
      return this.currentItemBurnTime;
      case 2:
      return this.cookTime;
      case 3:
      return this.totalCookTime;
      default:
      return 0;
      }
      }
      
      @Override
      public void setField(int id, int value) {
      switch (id) {
      case 0:
      this.furnaceBurnTime = value;
      break;
      case 1:
      this.currentItemBurnTime = value;
      break;
      case 2:
      this.cookTime = value;
      break;
      case 3:
      this.totalCookTime = value;
      }
      }
      
      @Override
      public int getFieldCount() {
      return 4;
      }
      
      @Override
      public void clear() {
      for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
      this.furnaceItemStacks* = null;
      }
      }
      
      public boolean canSmelt() {
      if (this.furnaceItemStacks[0] == null) {
      return false;
      }
      ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
      if (itemstack == null) {
      return false;
      }
      if (this.furnaceItemStacks[2] == null) {
      return true;
      }
      if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) {
      return false;
      }
      int result = this.furnaceItemStacks[2].stackSize + itemstack.stackSize;
      return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize();
      }
      
      public void smeltItem() {
      if (this.canSmelt()) {
      ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
      
      if (this.furnaceItemStacks[2] == null) {
      this.furnaceItemStacks[2] = itemstack.copy();
      } else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) {
      this.furnaceItemStacks[2].stackSize += itemstack.stackSize;
      }
      
      if (this.furnaceItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.bucket) {
      this.furnaceItemStacks[1] = new ItemStack(Items.water_bucket);
      }
      
      –this.furnaceItemStacks[0].stackSize;
      
      if (this.furnaceItemStacks[0].stackSize <= 0) {
      this.furnaceItemStacks[0] = null;
      }
      }
      }
      
      public int getCookTime() {
      return 200;
      }
      
      public boolean isBurning() {
      return this.furnaceBurnTime > 0;
      }
      }
      

      :::

      :::

      package fr.zeamateis.livingutilities.client.gui;
      
      import fr.zeamateis.livingutilities.common.entity.EntityLivingFurnace;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.Container;
      import net.minecraft.inventory.ICrafting;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.inventory.Slot;
      import net.minecraft.inventory.SlotFurnaceFuel;
      import net.minecraft.inventory.SlotFurnaceOutput;
      import net.minecraft.item.ItemStack;
      import net.minecraft.item.crafting.FurnaceRecipes;
      import net.minecraft.tileentity.TileEntityFurnace;
      import net.minecraftforge.fml.relauncher.Side;
      import net.minecraftforge.fml.relauncher.SideOnly;
      
      public class ContainerLivingFurnace extends Container {
      private final EntityLivingFurnace livingFurnace;
      private final IInventory furnace;
      private int field_178152_f;
      private int field_178153_g;
      private int field_178154_h;
      private int field_178155_i;
      
      public ContainerLivingFurnace(EntityPlayer player) {
      this.livingFurnace = new EntityLivingFurnace(player.worldObj);
      this.furnace = this.livingFurnace;
      this.addSlotToContainer(new Slot(this.furnace, 0, 56, 17));
      this.addSlotToContainer(new SlotFurnaceFuel(this.furnace, 1, 56, 53));
      this.addSlotToContainer(new SlotFurnaceOutput(player, this.furnace, 2, 116, 35));
      int i;
      
      for (i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
      this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
      }
      }
      
      for (i = 0; i < 9; ++i) {
      this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
      }
      }
      
      @Override
      public void detectAndSendChanges() {
      super.detectAndSendChanges();
      
      for (int i = 0; i < this.crafters.size(); ++i) {
      ICrafting icrafting = (ICrafting) this.crafters.get(i);
      
      if (this.field_178152_f != this.furnace.getField(2)) {
      icrafting.sendProgressBarUpdate(this, 2, this.furnace.getField(2));
      }
      
      if (this.field_178154_h != this.furnace.getField(0)) {
      icrafting.sendProgressBarUpdate(this, 0, this.furnace.getField(0));
      }
      
      if (this.field_178155_i != this.furnace.getField(1)) {
      icrafting.sendProgressBarUpdate(this, 1, this.furnace.getField(1));
      }
      
      if (this.field_178153_g != this.furnace.getField(3)) {
      icrafting.sendProgressBarUpdate(this, 3, this.furnace.getField(3));
      }
      }
      
      this.field_178152_f = this.furnace.getField(2);
      this.field_178154_h = this.furnace.getField(0);
      this.field_178155_i = this.furnace.getField(1);
      this.field_178153_g = this.furnace.getField(3);
      }
      
      @Override
      @SideOnly(Side.CLIENT)
      public void updateProgressBar(int id, int data) {
      this.furnace.setField(id, data);
      }
      
      @Override
      public boolean canInteractWith(EntityPlayer player) {
      return this.livingFurnace != null;
      }
      
      @Override
      public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
      ItemStack itemstack = null;
      Slot slot = (Slot) this.inventorySlots.get(index);
      
      if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();
      
      if (index == 2) {
      if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
      return null;
      }
      
      slot.onSlotChange(itemstack1, itemstack);
      } else if (index != 1 && index != 0) {
      if (FurnaceRecipes.instance().getSmeltingResult(itemstack1) != null) {
      if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
      return null;
      }
      } else if (TileEntityFurnace.isItemFuel(itemstack1)) {
      if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
      return null;
      }
      } else if (index >= 3 && index < 30) {
      if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
      return null;
      }
      } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
      return null;
      }
      } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
      return null;
      }
      
      if (itemstack1.stackSize == 0) {
      slot.putStack((ItemStack) null);
      } else {
      slot.onSlotChanged();
      }
      
      if (itemstack1.stackSize == itemstack.stackSize) {
      return null;
      }
      
      slot.onPickupFromSlot(playerIn, itemstack1);
      }
      
      return itemstack;
      }
      }
      

      :::

      :::

      package fr.zeamateis.livingutilities.client.gui;
      
      import java.io.IOException;
      
      import fr.zeamateis.livingutilities.common.entity.EntityLivingFurnace;
      import net.minecraft.client.gui.inventory.GuiContainer;
      import net.minecraft.client.gui.inventory.GuiInventory;
      import net.minecraft.client.renderer.GlStateManager;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.util.ResourceLocation;
      
      public class GuiLivingFurnace extends GuiContainer {
      private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
      private final InventoryPlayer playerInventory;
      private IInventory tileFurnace;
      private EntityLivingFurnace livingFurnace;
      
      public GuiLivingFurnace(EntityPlayer player) {
      super(new ContainerLivingFurnace(player));
      this.playerInventory = player.inventory;
      livingFurnace = new EntityLivingFurnace(player.worldObj);
      this.tileFurnace = livingFurnace;
      }
      
      @Override
      protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
      String s = this.tileFurnace.getDisplayName().getUnformattedText();
      this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
      this.fontRendererObj.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
      }
      
      @Override
      protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
      GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
      this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
      int k = (this.width - this.xSize) / 2;
      int l = (this.height - this.ySize) / 2;
      this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
      int i1;
      
      if (livingFurnace.isBurning()) {
      i1 = this.getBurnLeftScaled(13);
      this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
      }
      
      i1 = this.getCookProgressScaled(24);
      this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
      }
      
      private int getCookProgressScaled(int pixels) {
      int j = this.tileFurnace.getField(2);
      int k = this.tileFurnace.getField(3);
      return k != 0 && j != 0 ? j * pixels / k : 0;
      }
      
      private int getBurnLeftScaled(int pixels) {
      int j = this.tileFurnace.getField(1);
      
      if (j == 0) {
      j = 200;
      }
      
      return this.tileFurnace.getField(0) * pixels / j;
      }
      
      @Override
      protected void keyTyped(char typedChar, int keyCode) throws IOException {
      if (keyCode == 1) {
      this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer));
      return;
      }
      super.keyTyped(typedChar, keyCode);
      }
      }
      

      :::

      Le code est pas parfait, mais il est suffisamment lisible 😉

      Merci de votre aide !

      Si je t'ai filé un coup de main n'oublie pas le + / -
      Par contre évite les demandes d'aides en MP, tu sera sympa'

      La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

      Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

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

        Pour les NBT je ne sais pas.
        Par contre pour la cuisson il faudrait peut-être appeler la fonction smeltItem dans onUpdate non ?

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

          Tu cherche à faire un four ?
          [1.7]http://www.minecraftforgefrance.fr/showthread.php?tid=2017
          [1.8]http://www.minecraftforgefrance.fr/showthread.php?tid=2716

          Non c’est pas de la pub ….

          Après si tu cherche pas à faire un four bah c’est que j’ai pas compris

          EDIT : tu m’as l’air d’être en 1.8 vu qu’il y a l’interface IBlockState

          1 réponse Dernière réponse Répondre Citer 0
          • Ama
            Ama dernière édition par

            Bon j’ai repris le code de A à Z du de la tile entity du four, et c’est pareil, ça ne cuit pas, ni ne sauvegarde les items dans ce dernier:

            Le code:

            :::

            package fr.zeamateis.livingutilities.common.entity;
            
            import fr.zeamateis.livingutilities.common.core.LivingUtilitiesCore;
            import net.minecraft.block.Block;
            import net.minecraft.block.BlockFurnace;
            import net.minecraft.block.material.Material;
            import net.minecraft.block.state.IBlockState;
            import net.minecraft.entity.player.EntityPlayer;
            import net.minecraft.init.Blocks;
            import net.minecraft.init.Items;
            import net.minecraft.inventory.IInventory;
            import net.minecraft.inventory.SlotFurnaceFuel;
            import net.minecraft.item.Item;
            import net.minecraft.item.ItemBlock;
            import net.minecraft.item.ItemHoe;
            import net.minecraft.item.ItemStack;
            import net.minecraft.item.ItemSword;
            import net.minecraft.item.ItemTool;
            import net.minecraft.item.crafting.FurnaceRecipes;
            import net.minecraft.nbt.NBTTagCompound;
            import net.minecraft.nbt.NBTTagList;
            import net.minecraft.util.MathHelper;
            import net.minecraft.world.World;
            import net.minecraftforge.fml.relauncher.Side;
            import net.minecraftforge.fml.relauncher.SideOnly;
            
            public class EntityLivingFurnace extends EntityUtilitiesBlock implements IInventory {
            
            /**
            * The ItemStacks that hold the items currently being used in the furnace
            */
            private ItemStack[] furnaceItemStacks = new ItemStack[3];
            /** The number of ticks that the furnace will keep burning */
            private int furnaceBurnTime;
            /**
            * The number of ticks that a fresh copy of the currently-burning item would
            * keep the furnace burning for
            */
            private int currentItemBurnTime;
            private int cookTime;
            private int totalCookTime;
            private String furnaceCustomName;
            
            public EntityLivingFurnace(World world) {
            super(world);
            }
            
            public void applyEntityAttributes() {
            super.applyEntityAttributes();
            }
            
            public void onUpdate() {
            
            boolean flag = this.isBurning();
            boolean flag1 = false;
            
            if (this.isBurning()) {
            –this.furnaceBurnTime;
            }
            
            if (!this.worldObj.isRemote) {
            if (!this.isBurning() && (this.furnaceItemStacks[1] == null || this.furnaceItemStacks[0] == null)) {
            if (!this.isBurning() && this.cookTime > 0) {
            this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
            }
            } else {
            if (!this.isBurning() && this.canSmelt()) {
            this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
            
            if (this.isBurning()) {
            flag1 = true;
            
            if (this.furnaceItemStacks[1] != null) {
            –this.furnaceItemStacks[1].stackSize;
            
            if (this.furnaceItemStacks[1].stackSize == 0) {
            this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(furnaceItemStacks[1]);
            }
            }
            }
            }
            
            if (this.isBurning() && this.canSmelt()) {
            ++this.cookTime;
            
            if (this.cookTime == this.totalCookTime) {
            this.cookTime = 0;
            this.totalCookTime = this.func_174904_a(this.furnaceItemStacks[0]);
            this.smeltItem();
            flag1 = true;
            }
            } else {
            this.cookTime = 0;
            }
            }
            
            if (flag != this.isBurning()) {
            flag1 = true;
            BlockFurnace.setState(this.isBurning(), this.worldObj, this.getPosition());
            }
            }
            
            if (flag1) {
            this.markDirty();
            }
            super.onUpdate();
            }
            
            public void onLivingUpdate() {
            super.onLivingUpdate();
            }
            
            public void writeEntityToNBT(NBTTagCompound compound) {
            super.writeEntityToNBT(compound);
            compound.setShort("BurnTime", (short) this.furnaceBurnTime);
            compound.setShort("CookTime", (short) this.cookTime);
            compound.setShort("CookTimeTotal", (short) this.totalCookTime);
            NBTTagList nbttaglist = new NBTTagList();
            
            for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
            if (this.furnaceItemStacks* != null) {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            nbttagcompound1.setByte("Slot", (byte) i);
            this.furnaceItemStacks*.writeToNBT(nbttagcompound1);
            nbttaglist.appendTag(nbttagcompound1);
            }
            }
            
            compound.setTag("Items", nbttaglist);
            
            if (this.hasCustomName()) {
            compound.setString("CustomName", this.furnaceCustomName);
            }
            }
            
            public void readEntityFromNBT(NBTTagCompound compound) {
            super.readEntityFromNBT(compound);
            NBTTagList nbttaglist = compound.getTagList("Items", 10);
            this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
            
            for (int i = 0; i < nbttaglist.tagCount(); ++i) {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            byte b0 = nbttagcompound1.getByte("Slot");
            
            if (b0 >= 0 && b0 < this.furnaceItemStacks.length) {
            this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
            }
            }
            
            this.furnaceBurnTime = compound.getShort("BurnTime");
            this.cookTime = compound.getShort("CookTime");
            this.totalCookTime = compound.getShort("CookTimeTotal");
            this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
            
            if (compound.hasKey("CustomName", 8)) {
            this.furnaceCustomName = compound.getString("CustomName");
            }
            }
            
            @Override
            public boolean interact(EntityPlayer player) {
            if (!player.worldObj.isRemote) {
            player.openGui(LivingUtilitiesCore.getInstance(), 1, player.worldObj, this.getEntityId(), 0, 0);
            }
            return true;
            }
            
            public IBlockState getBlock() {
            return Blocks.furnace.getDefaultState();
            }
            
            @Override
            public int getSizeInventory() {
            return this.furnaceItemStacks.length;
            }
            
            @Override
            public ItemStack getStackInSlot(int index) {
            return this.furnaceItemStacks[index];
            }
            
            @Override
            public ItemStack decrStackSize(int index, int count) {
            if (this.furnaceItemStacks[index] != null) {
            ItemStack itemstack;
            
            if (this.furnaceItemStacks[index].stackSize <= count) {
            itemstack = this.furnaceItemStacks[index];
            this.furnaceItemStacks[index] = null;
            return itemstack;
            } else {
            itemstack = this.furnaceItemStacks[index].splitStack(count);
            
            if (this.furnaceItemStacks[index].stackSize == 0) {
            this.furnaceItemStacks[index] = null;
            }
            
            return itemstack;
            }
            } else {
            return null;
            }
            }
            
            @Override
            public ItemStack getStackInSlotOnClosing(int index) {
            if (this.furnaceItemStacks[index] != null) {
            ItemStack itemstack = this.furnaceItemStacks[index];
            this.furnaceItemStacks[index] = null;
            return itemstack;
            } else {
            return null;
            }
            }
            
            @Override
            public void setInventorySlotContents(int index, ItemStack stack) {
            boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
            this.furnaceItemStacks[index] = stack;
            
            if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
            stack.stackSize = this.getInventoryStackLimit();
            }
            
            if (index == 0 && !flag) {
            this.totalCookTime = this.func_174904_a(stack);
            this.cookTime = 0;
            this.markDirty();
            }
            }
            
            /**
            * Gets the name of this command sender (usually username, but possibly
            * "Rcon")
            */
            public String getName() {
            return this.hasCustomName() ? this.furnaceCustomName : "container.furnace";
            }
            
            /**
            * Returns true if this thing is named
            */
            public boolean hasCustomName() {
            return this.furnaceCustomName != null && this.furnaceCustomName.length() > 0;
            }
            
            public void setCustomInventoryName(String p_145951_1_) {
            this.furnaceCustomName = p_145951_1_;
            }
            
            @Override
            public int getInventoryStackLimit() {
            return 64;
            }
            
            /**
            * Furnace isBurning
            */
            public boolean isBurning() {
            return this.furnaceBurnTime > 0;
            }
            
            @SideOnly(Side.CLIENT)
            public static boolean isBurning(IInventory p_174903_0_) {
            return p_174903_0_.getField(0) > 0;
            }
            
            public int func_174904_a(ItemStack p_174904_1_) {
            return 200;
            }
            
            /**
            * Returns true if the furnace can smelt an item, i.e. has a source item,
            * destination stack isn't full, etc.
            */
            private boolean canSmelt() {
            if (this.furnaceItemStacks[0] == null) {
            return false;
            } else {
            ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
            if (itemstack == null)
            return false;
            if (this.furnaceItemStacks[2] == null)
            return true;
            if (!this.furnaceItemStacks[2].isItemEqual(itemstack))
            return false;
            int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
            return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize(); // Forge
            // BugFix:
            // Make
            // it
            // respect
            // stack
            // sizes
            // properly.
            }
            }
            
            /**
            * Turn one item from the furnace source stack into the appropriate smelted
            * item in the furnace result stack
            */
            public void smeltItem() {
            if (this.canSmelt()) {
            ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]);
            
            if (this.furnaceItemStacks[2] == null) {
            this.furnaceItemStacks[2] = itemstack.copy();
            } else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) {
            this.furnaceItemStacks[2].stackSize += itemstack.stackSize; // Forge
            // BugFix:
            // Results
            // may
            // have
            // multiple
            // items
            }
            
            if (this.furnaceItemStacks[0].getItem() == Item.getItemFromBlock(Blocks.sponge) && this.furnaceItemStacks[0].getMetadata() == 1 && this.furnaceItemStacks[1] != null && this.furnaceItemStacks[1].getItem() == Items.bucket) {
            this.furnaceItemStacks[1] = new ItemStack(Items.water_bucket);
            }
            
            –this.furnaceItemStacks[0].stackSize;
            
            if (this.furnaceItemStacks[0].stackSize <= 0) {
            this.furnaceItemStacks[0] = null;
            }
            }
            }
            
            /**
            * Returns the number of ticks that the supplied fuel item will keep the
            * furnace burning, or 0 if the item isn't fuel
            */
            public static int getItemBurnTime(ItemStack p_145952_0_) {
            if (p_145952_0_ == null) {
            return 0;
            } else {
            Item item = p_145952_0_.getItem();
            
            if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
            Block block = Block.getBlockFromItem(item);
            
            if (block == Blocks.wooden_slab) {
            return 150;
            }
            
            if (block.getMaterial() == Material.wood) {
            return 300;
            }
            
            if (block == Blocks.coal_block) {
            return 16000;
            }
            }
            
            if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
            return 200;
            if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
            return 200;
            if (item instanceof ItemHoe && ((ItemHoe) item).getMaterialName().equals("WOOD"))
            return 200;
            if (item == Items.stick)
            return 100;
            if (item == Items.coal)
            return 1600;
            if (item == Items.lava_bucket)
            return 20000;
            if (item == Item.getItemFromBlock(Blocks.sapling))
            return 100;
            if (item == Items.blaze_rod)
            return 2400;
            return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(p_145952_0_);
            }
            }
            
            public static boolean isItemFuel(ItemStack itemStack) {
            return getItemBurnTime(itemStack) > 0;
            }
            
            @Override
            public void markDirty() {
            }
            
            @Override
            public boolean isUseableByPlayer(EntityPlayer player) {
            return player.getDistanceSq((double) this.getPosition().getX() + 0.5D, (double) this.getPosition().getY() + 0.5D, (double) this.getPosition().getZ() + 0.5D) <= 64.0D;
            }
            
            @Override
            public void openInventory(EntityPlayer player) {
            }
            
            @Override
            public void closeInventory(EntityPlayer player) {
            }
            
            public String getGuiID() {
            return "minecraft:furnace";
            }
            
            @Override
            public boolean isItemValidForSlot(int index, ItemStack stack) {
            return index == 2 ? false : (index != 1 ? true : isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack));
            }
            
            @Override
            public int getField(int id) {
            switch (id) {
            case 0:
            return this.furnaceBurnTime;
            case 1:
            return this.currentItemBurnTime;
            case 2:
            return this.cookTime;
            case 3:
            return this.totalCookTime;
            default:
            return 0;
            }
            }
            
            @Override
            public void setField(int id, int value) {
            switch (id) {
            case 0:
            this.furnaceBurnTime = value;
            break;
            case 1:
            this.currentItemBurnTime = value;
            break;
            case 2:
            this.cookTime = value;
            break;
            case 3:
            this.totalCookTime = value;
            }
            }
            
            @Override
            public int getFieldCount() {
            return 4;
            }
            
            @Override
            public void clear() {
            for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
            this.furnaceItemStacks* = null;
            }
            }
            
            }
            

            :::

            Si je t'ai filé un coup de main n'oublie pas le + / -
            Par contre évite les demandes d'aides en MP, tu sera sympa'

            La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

            Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

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

              C’est quoi la classe EntityUtilitiesBlock ?

              (Genre niveau extends, implements)

              1 réponse Dernière réponse Répondre Citer 0
              • Ama
                Ama dernière édition par

                extends EntityTameable (pour pouvoir faire en sorte que mon entité me suive dans le futur)

                quelques nbt pour sauvegarder le rendu 3D de mon entité “block” (via les json donc)

                :::
                (http://amateis.teamgussdx.fr/genisys/eecpqe.png)
                :::

                et c’est tout 🙂

                Oui je donne pas mon code tout fait sait-on jamais car c’est stylé une entité avec un rendu json 😉

                Si je t'ai filé un coup de main n'oublie pas le + / -
                Par contre évite les demandes d'aides en MP, tu sera sympa'

                La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

                Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

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

                  Ok, je suis en train de voir comment faire pour résoudre ton problème

                  EDIT : J’ai pas fini mais dans j’ai vu que dans la fonction d’update on utilise this.isBurning() qui n’as pas la même signification pour l’entité et le tileEntity du four

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

                    Je sais pas ce que ça peut donner, dites-moi si il y a moyen que ça marche ou pas du tout (actuellement ça marche pas, je suis d’accord mais bon …) mais je voyait un truc comme ça :

                    
                    public class EntityMobFurnace extends EntityCreature {
                    
                    private TileEntityFurnace tile;
                    
                    public EntityMobFurnace(World world) {
                    super(world);
                    }
                    
                    @Override
                    public boolean interact(EntityPlayer player)
                    {
                    if(tile == null)
                    {
                    tile = new TileEntityFurnace();
                    this.worldObj.setTileEntity(new BlockPos(this.posX, this.posY, this.posZ), tile);
                    }
                    if(this.worldObj.isRemote)
                    {
                    player.displayGUIChest(tile);
                    return true;
                    }
                    return true;
                    }
                    
                    @Override
                    public void onUpdate()
                    {
                    if(tile != null)
                    {
                    tile.setPos(new BlockPos(this.posX, this.posY, this.posZ));
                    tile.update();
                    }
                    }
                    
                    @Override
                    public void writeToNBT(NBTTagCompound compound)
                    {
                    super.writeToNBT(compound);
                    if(tile != null)
                    {
                    NBTTagCompound furnace = new NBTTagCompound();
                    tile.writeToNBT(furnace);
                    compound.setTag("furnace", furnace);
                    }
                    }
                    
                    @Override
                    public void readFromNBT(NBTTagCompound compound)
                    {
                    super.readFromNBT(compound);
                    NBTTagCompound furnace = (NBTTagCompound)compound.getTag("furnace");
                    tile.readFromNBT(furnace);
                    }
                    
                    }
                    
                    

                    Donc dites-moi se que vous en pensez

                    1 réponse Dernière réponse Répondre Citer 0
                    • Ama
                      Ama dernière édition par

                      ça ne fonctionne pas

                      Si je t'ai filé un coup de main n'oublie pas le + / -
                      Par contre évite les demandes d'aides en MP, tu sera sympa'

                      La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

                      Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

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

                        Je sais, je l’ai dit mais je demandais ce que vous en pensiez, si ça pouvait marcher avec des modifications et si c’était juste impossible de faire de cette manière

                        1 réponse Dernière réponse Répondre Citer 0
                        • Snowy_1803
                          Snowy_1803 dernière édition par

                          Moi, pour mon four ambulant, j’ai fait comme dans ton premier code, mais j’ai mis des ItemStack a part (pas dans des Arrays), après cela plus besoin de plein de méthodes en plus. Comme l’a dis BrokenSwing, change le nom de la méthode isBurning, car ce nom est déjà utilisé pour savoir si l’entité brûle. Sinon, je pense que ton entité sera en feu quand tu l’utilise 😄
                          Je n’utilise par contre ni container ni gui, j’ai fait directement un interact. En parlant d’interact, ce qui est peut-être ton seul problème, si tu veut un Gui, dans la méthode interact de ton entité, tu ouvres un gui 🙂

                          Moddeur 1.8

                          Développeur Java

                          1 réponse Dernière réponse Répondre Citer 0
                          • Ama
                            Ama dernière édition par

                            Tu aurais éventuellement un bout de classe à me montrer ?
                            #JeSuisChiant

                            Si je t'ai filé un coup de main n'oublie pas le + / -
                            Par contre évite les demandes d'aides en MP, tu sera sympa'

                            La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

                            Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

                            1 réponse Dernière réponse Répondre Citer 0
                            • Ama
                              Ama dernière édition par

                              Problème résolu !

                              Il manquait une implémentation

                              Si je t'ai filé un coup de main n'oublie pas le + / -
                              Par contre évite les demandes d'aides en MP, tu sera sympa'

                              La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

                              Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

                              1 réponse Dernière réponse Répondre Citer 0
                              • 1 / 1
                              • Premier message
                                Dernier message
                              Design by Woryk
                              Contact / Mentions Légales

                              MINECRAFT FORGE FRANCE © 2018

                              Powered by NodeBB