Résolu Problème de texture du Gui de mon four
-
Bonjour/Bonsoir, je reviens vers vous pour vous demander de l’aide car j’ai un problème que je n’arrive pas à résoudre concernant le Gui de mon four.
En effet ce bloc ma posé pas mal de problème que j’ai réussi à résoudre soit à l’aide du tuto soit tout seul mais malheureusement un problème continue de persister :
Quand je met un item à cuir, la texture des flammes n’apparaissent pas et la texture de la flèche est beaucoup trop large et en plus ne prend pas en compte le "cookTime mais le “burnTime” c’est à dire qu’elle indique ce que la flamme devrait indiquer.
Quand je sors de mon four et que je reviens dedans la flamme apparait et à le même bug que la flèche c’est à dire qu’elle est la texture est trop grande mais au moins elle prend bien en compte le “burnTime”
Je ne sais pas du tout d’où viens mon problème du coup je vais vous mettre toute les class de mon four :
package fr.nk.battleforsurvivemod.common; import java.util.Random; 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.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import fr.nk.battleforsurvivemod.common.BFS1Mod; import fr.nk.battleforsurvivemod.common.OreFurnaceTileEntity; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class OreFurnace extends BlockContainer { private final boolean isActive; @SideOnly(Side.CLIENT) private IIcon iconFront; @SideOnly(Side.CLIENT) private IIcon iconTop; private static boolean keepInventory; private Random rand = new Random(); public OreFurnace(boolean isActive) { super(Material.rock); this.isActive = isActive; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(BFS1Mod.modid + ":" + "ore_furnaceSide"); this.iconFront = iconRegister.registerIcon(BFS1Mod.modid + ":" + (this.isActive ? "ore_furnaceFrontOn" : "ore_furnaceFrontOff")); this.iconTop = iconRegister.registerIcon(BFS1Mod.modid + ":" + "ore_furnaceTop"); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon)); } public Item getItemDropped(int i, Random random, int j) { return Item.getItemFromBlock(BFS1Mod.oreFurnaceIdle); } public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); this.setDefaultDirection(world, x, y, z); } private void setDefaultDirection(World world, int x, int y, int z) { if(!world.isRemote) { Block b1 = world.getBlock(x, y, z - 1); Block b2 = world.getBlock(x, y, z + 1); Block b3 = world.getBlock(x - 1, y, z); Block b4 = world.getBlock(x + 1, y, z); byte b0 = 3; if(b1.func_149730_j() && !b2.func_149730_j()) { b0 = 3; } if(b2.func_149730_j() && !b1.func_149730_j()) { b0 = 2; } if(b3.func_149730_j() && !b4.func_149730_j()) { b0 = 5; } if(b4.func_149730_j() && !b3.func_149730_j()) { b0 = 4; } world.setBlockMetadataWithNotify(x, y, z, b0, 2); } } @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random) { if(this.isActive) { int direction = world.getBlockMetadata(x, y, z); float x1 = (float)x + 0.5F; float y1 = (float)y + random.nextFloat(); float z1 = (float)z + 0.5F; float f = 0.52F; float f1 = random.nextFloat() * 0.6F - 0.3F; if(direction == 4) { world.spawnParticle("smoke", (double)(x1 - f), (double)(y1), (double)(z1 + f1), 0D, 0D, 0D); world.spawnParticle("flame", (double)(x1 - f), (double)(y1), (double)(z1 + f1), 0D, 0D, 0D); } if(direction == 5) { world.spawnParticle("smoke", (double)(x1 + f), (double)(y1), (double)(z1 + f1), 0D, 0D, 0D); world.spawnParticle("flame", (double)(x1 + f), (double)(y1), (double)(z1 + f1), 0D, 0D, 0D); } if(direction == 2) { world.spawnParticle("smoke", (double)(x1 + f1), (double)(y1), (double)(z1 - f), 0D, 0D, 0D); world.spawnParticle("flame", (double)(x1 + f1), (double)(y1), (double)(z1 - f), 0D, 0D, 0D); } if(direction == 3) { world.spawnParticle("smoke", (double)(x1 + f1), (double)(y1), (double)(z1 + f), 0D, 0D, 0D); world.spawnParticle("flame", (double)(x1 + f1), (double)(y1), (double)(z1 + f), 0D, 0D, 0D); } } } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { FMLNetworkHandler.openGui(player, BFS1Mod.instance, BFS1Mod.guiIDOreFurnace, world, x, y, z); } return true; } @Override public TileEntity createNewTileEntity(World world, int i) { return new OreFurnaceTileEntity(); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) { int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3; if(l == 0) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if(l == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if(l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if(l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } if(itemstack.hasDisplayName()) { ((OreFurnaceTileEntity)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName()); } } public static void updateOreFurnaceBlockState(boolean active, World worldObj, int xCoord, int yCoord, int zCoord) { int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); TileEntity tileentity = worldObj.getTileEntity(xCoord, yCoord, zCoord); keepInventory = true; if(active) { worldObj.setBlock(xCoord, yCoord, zCoord, BFS1Mod.oreFurnaceActive); } else { worldObj.setBlock(xCoord, yCoord, zCoord, BFS1Mod.oreFurnaceIdle); } keepInventory = false; worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2); if(tileentity !=null) { tileentity.validate(); worldObj.setTileEntity(xCoord, yCoord, zCoord, tileentity); } } public void breakBlock(World world, int x, int y, int z, Block oldblock, int oldMetadata) { if(!keepInventory) { OreFurnaceTileEntity tileentity = (OreFurnaceTileEntity) world.getTileEntity(x, y, z); if(tileentity != null) { for(int i = 0; i < tileentity.getSizeInventory(); i++) { ItemStack itemstack = tileentity.getStackInSlot(i); if(itemstack != null) { float f = this.rand.nextFloat() * 0.8F + 0.1F; float f1 = this.rand.nextFloat() * 0.8F + 0.1F; float f2 = this.rand.nextFloat() * 0.8F + 0.1F; while(itemstack.stackSize > 0) { int j = this.rand.nextInt(21) + 10; if(j > itemstack.stackSize) { j = itemstack.stackSize; } itemstack.stackSize -= j; EntityItem item = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); if(itemstack.hasTagCompound()) { item.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } world.spawnEntityInWorld(item); } } } world.func_147453_f(x, y, z, oldblock); } } super.breakBlock(world, x, y, z, oldblock, oldMetadata); } public Item getItem(World world, int x, int y, int z) { return Item.getItemFromBlock(BFS1Mod.oreFurnaceIdle); } } ``` ::: ::: ```java package fr.nk.battleforsurvivemod.common; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; 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.TileEntity; import fr.nk.battleforsurvivemod.common.OreFurnace; public class OreFurnaceTileEntity extends TileEntity implements ISidedInventory { private String localizedName; private static final int[] slots_top = new int[]{0}; private static final int[] slots_bottom = new int[]{2, 1}; private static final int[] slots_side = new int[]{1}; private ItemStack[] slots = new ItemStack [3]; public int furnaceSpeed = 100; public int burnTime; public int currentItemBurnTime; public int cookTime; public void setGuiDisplayName(String displayName) { this.localizedName = displayName; } public String getInventoryName() { return this.hasCustomInventoryName() ? this.localizedName : "container.oreFurnace"; } public boolean hasCustomInventoryName() { return this.localizedName != null && this.localizedName.length() > 0; } public int getSizeInventory() { return this.slots.length; } @Override public ItemStack getStackInSlot(int r) { return this.slots[r]; } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null) { ItemStack itemstack; if(this.slots[var1].stackSize <= var2) { itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; } else { itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0) { this.slots[var1] = null; } return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int r) { if(this.slots[r] != null) { ItemStack itemstack = this.slots[r]; this.slots[r] = null; return itemstack; } return null; } @Override public void setInventorySlotContents(int r, ItemStack itemstack) { this.slots[r] = itemstack; if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord +0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } public void openInventory(){} public void closeInventory(){} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2 ? false : (i == 1 ? isItemFuel(itemstack) : true); } public static boolean isItemFuel (ItemStack itemstack) { return getItemBurnTime(itemstack) > 0; } private static int getItemBurnTime(ItemStack itemstack) { if(itemstack == null) { return 0; } else { Item item = itemstack.getItem(); if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { Block block = Block.getBlockFromItem(item); if(block == Blocks.coal_block) return 3600; if(block == BFS1Mod.denseCoalBlock) return 32400; } if(item == Items.coal) return 400; if(item == Items.lava_bucket) return 5000; if(item == BFS1Mod.denseCoal) return 3600; } return GameRegistry.getFuelValue(itemstack); } public boolean isBurning() { return this.burnTime > 0; } public void updateEntity() { boolean flag = this.burnTime > 0; boolean flag1 = false; if(this.isBurning()) { this.burnTime–; } if(!this.worldObj.isRemote) { if(this.burnTime == 0 && this.canSmelt()) { this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]); if(this.isBurning()) { flag1 = true; if(this.slots[1] != null) { this.slots[1].stackSize–; if(this.slots[1].stackSize == 0) { this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]); } } } } if(this.isBurning() && this.canSmelt()) { this.cookTime++; if(this.cookTime == this.furnaceSpeed) { this.cookTime =0; this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } if(flag != this.isBurning()) { flag1 = true; OreFurnace.updateOreFurnaceBlockState(this.burnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if(flag1) { this.markDirty(); } } public boolean canSmelt() { if (this.slots[0] == null) { return false; } else { ItemStack itemstack = OreFurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if(itemstack == null) return false; if(this.slots[2] == null) return true; if(!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public void smeltItem() { if(this.canSmelt()) { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]); if(this.slots[2] == null) { this.slots[2] = itemstack.copy(); } else if(this.slots[2].isItemEqual(itemstack)) { this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize–; if(this.slots[0].stackSize <= 0) { this.slots[0] = null; } } } @Override public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ?slots_bottom : (var1 == 1 ?slots_top : slots_side); } @Override public boolean canInsertItem(int i, ItemStack itemstack, int var3) { return this.isItemValidForSlot(i, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getBurnTimeRemainingScaled(int i) { if(this.currentItemBurnTime == 0) { this.currentItemBurnTime = this.furnaceSpeed; } return this.burnTime * i / this.currentItemBurnTime; } public int getCookProgressScaled(int i) { return this.cookTime * i / this.furnaceSpeed; } public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[this.getSizeInventory()]; for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = (NBTTagCompound) list.getCompoundTagAt(i); byte b = compound.getByte("Slot"); if(b >= 0 && b < this.slots.length) { this.slots** = ItemStack.loadItemStackFromNBT(compound); } } this.burnTime = (int)nbt.getShort("BurnTime"); this.cookTime = (int)nbt.getShort("CookTime"); this.currentItemBurnTime = (int)nbt.getShort("CurrentBurnTime"); if(nbt.hasKey("CustomName")) { this.localizedName = nbt.getString("CustomName"); } } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("BurnTime", (short)this.burnTime); nbt.setShort("CookTime", (short)this.cookTime); nbt.setShort("CurrentBurnTime", (short)this.currentItemBurnTime); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.slots.length; i++) { if(this.slots* != null) { NBTTagCompound compound = new NBTTagCompound(); compound.setByte("Slot", (byte)i); this.slots*.writeToNBT(compound); list.appendTag(compound); } } nbt.setTag("Items", list); if (this.hasCustomInventoryName()) { nbt.setString("CustomName", this.localizedName); } } } ``` ::: ::: ```java package fr.nk.battleforsurvivemod.common; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; import fr.nk.battleforsurvivemod.common.OreFurnaceTileEntity; public class ContainerOreFurnace extends Container { private OreFurnaceTileEntity oreFurnace; public int lastBurnTime; public int lastCurrentItemBurnTime; public int lastCookTime; public ContainerOreFurnace(InventoryPlayer inventory, OreFurnaceTileEntity tileentity) { this.oreFurnace = tileentity; this.addSlotToContainer(new Slot(tileentity, 0, 56, 17)); this.addSlotToContainer(new Slot(tileentity, 1, 56, 53)); this.addSlotToContainer(new SlotFurnace(inventory.player, tileentity, 2, 116, 17)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; j++) { this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } } public void addCraftingToCrafters (ICrafting icrafting) { super.addCraftingToCrafters(icrafting); icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.cookTime); icrafting.sendProgressBarUpdate(this, 1, this.oreFurnace.burnTime); icrafting.sendProgressBarUpdate(this, 2, this.oreFurnace.currentItemBurnTime); } public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); i++) { ICrafting icrafting = (ICrafting) this.crafters.get(i); if(this.lastCookTime != this.oreFurnace.cookTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.cookTime); } if(this.lastBurnTime != this.oreFurnace.burnTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.burnTime); } if(this.lastCurrentItemBurnTime != this.oreFurnace.currentItemBurnTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.currentItemBurnTime); } } this.lastCookTime = this.oreFurnace.cookTime; this.lastBurnTime = this.oreFurnace.burnTime; this.lastCurrentItemBurnTime = this.oreFurnace.currentItemBurnTime; } @SideOnly(Side.CLIENT) public void updateProgressBar(int slot, int newValue) { if (slot == 0) { this.oreFurnace.cookTime = newValue; } if (slot == 1) { this.oreFurnace.burnTime = newValue; } if (slot == 3) { this.oreFurnace.currentItemBurnTime = newValue; } } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 2) { if (!this.mergeItemStack(itemstack1, 3, 39, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 != 1 && par2 != 0) { if (FurnaceRecipes.smelting().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 (par2 >= 3 && par2 < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (par2 >= 30 && par2 < 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(par1EntityPlayer, itemstack1); } return itemstack; } @Override public boolean canInteractWith(EntityPlayer var1) { return true; } } ``` ::: Je pense que le problème viens plus de là que dans les autres class mais bon à chaque fois que je tente un truc ça reviens eu même ::: ```java package fr.nk.battleforsurvivemod.common; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import fr.nk.battleforsurvivemod.common.BFS1Mod; import fr.nk.battleforsurvivemod.common.OreFurnaceTileEntity; import fr.nk.battleforsurvivemod.common.ContainerOreFurnace; public class GuiOreFurnace extends GuiContainer { public static final ResourceLocation bground = new ResourceLocation(BFS1Mod.modid + ":" + "textures/gui/oreFurnaceGui.png"); public OreFurnaceTileEntity oreFurnace; public GuiOreFurnace(InventoryPlayer inventoryPlayer, OreFurnaceTileEntity entity) { super(new ContainerOreFurnace(inventoryPlayer, entity)); this.oreFurnace = entity; this.xSize = 176; this.ySize = 166; } public void drawGuiContainerForegroundLayer(int par1, int par2) { String name = "Ore Furnace"; this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int l) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().getTextureManager().bindTexture(bground); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int il; if(this.oreFurnace.isBurning()) { il = this.oreFurnace.getBurnTimeRemainingScaled(14); this.drawTexturedModalRect(guiLeft + 56, guiTop + 36 + 14 - il, 176, 14 - il, 14, il + 2); } il = this.oreFurnace.getCookProgressScaled(24); this.drawTexturedModalRect(guiLeft + 81, guiTop + 16, 176, 14, il + 1, 16); } } ``` ::: ::: ```java package fr.nk.battleforsurvivemod.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.ItemFishFood; import net.minecraft.item.ItemStack; public class OreFurnaceRecipes { private static final OreFurnaceRecipes smeltingBase = new OreFurnaceRecipes(); private Map smeltingList = new HashMap(); private Map experienceList = new HashMap(); private static final String __OBFID = "CL_00000085"; public static OreFurnaceRecipes smelting() { return smeltingBase; } private OreFurnaceRecipes() { this.func_151393_a(Blocks.iron_ore, new ItemStack(Items.iron_ingot), 0.7F); this.func_151393_a(Blocks.gold_ore, new ItemStack(Items.gold_ingot), 1.0F); this.func_151393_a(Blocks.diamond_ore, new ItemStack(Items.diamond), 1.0F); this.func_151393_a(Blocks.cobblestone, new ItemStack(Blocks.stone), 0.1F); this.func_151393_a(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35F); this.func_151393_a(Blocks.emerald_ore, new ItemStack(Items.emerald), 1.0F); this.func_151393_a(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.1F); this.func_151393_a(Blocks.coal_ore, new ItemStack(Items.coal), 0.1F); this.func_151393_a(Blocks.redstone_ore, new ItemStack(Items.redstone), 0.7F); this.func_151393_a(Blocks.lapis_ore, new ItemStack(Items.dye, 1, 4), 0.2F); this.func_151393_a(Blocks.quartz_ore, new ItemStack(Items.quartz), 0.2F); } public void func_151393_a(Block p_151393_1_, ItemStack p_151393_2_, float p_151393_3_) { this.func_151396_a(Item.getItemFromBlock(p_151393_1_), p_151393_2_, p_151393_3_); } public void func_151396_a(Item p_151396_1_, ItemStack p_151396_2_, float p_151396_3_) { this.func_151394_a(new ItemStack(p_151396_1_, 1, 32767), p_151396_2_, p_151396_3_); } public void func_151394_a(ItemStack p_151394_1_, ItemStack p_151394_2_, float p_151394_3_) { this.smeltingList.put(p_151394_1_, p_151394_2_); this.experienceList.put(p_151394_2_, Float.valueOf(p_151394_3_)); } public ItemStack getSmeltingResult(ItemStack p_151395_1_) { Iterator iterator = this.smeltingList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) { return null; } entry = (Entry)iterator.next(); } while (!this.func_151397_a(p_151395_1_, (ItemStack)entry.getKey())); return (ItemStack)entry.getValue(); } private boolean func_151397_a(ItemStack p_151397_1_, ItemStack p_151397_2_) { return p_151397_2_.getItem() == p_151397_1_.getItem() && (p_151397_2_.getItemDamage() == 32767 || p_151397_2_.getItemDamage() == p_151397_1_.getItemDamage()); } public Map getSmeltingList() { return this.smeltingList; } public float func_151398_b(ItemStack p_151398_1_) { float ret = p_151398_1_.getItem().getSmeltingExperience(p_151398_1_); if (ret != -1) return ret; Iterator iterator = this.experienceList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) { return 0.0F; } entry = (Entry)iterator.next(); } while (!this.func_151397_a(p_151398_1_, (ItemStack)entry.getKey())); return ((Float)entry.getValue()).floatValue(); } }
Et enfin la texture du Gui de mon four :
Il ne me reste plus qu’à corriger ce bug et de créé le craft de mon four pour qu’il soit 100% opérationnel, si vous arrivez à trouver la solution je vous en serrez éternellement reconnaissant
-
Pour la flèche, le rendu est géré par :
il = this.oreFurnace.getCookProgressScaled(24); this.drawTexturedModalRect(guiLeft + 81, guiTop + 16, 176, 14, il + 1, 16);
-
J’ai remarqué que pendant un bref instant au moment où j’ouvre le Gui de mon four, je vois le flèche tel qu’elle devrait fonctionner puis elle devient bugger.
-
Regarde si tu n’a pas deux fois la même fonction. Une première normale et la seconde qui prend le dessus et fait bug
-
Dans ton gui :
il = this.oreFurnace.getBurnTimeRemainingScaled(14);
Ici moi j’ai 12, pas 14.Après si tu veux comparé d’autre truc, mon four est opérationnel :
https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/client/GuiPrivateFurnace.java
https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/common/ContainerPrivateFurnace.java
https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/common/TileEntityPrivateFurnace.java
Par contre je préviens tout de suite qu’il est en metadata et utilise un seul id de bloc. -
c’est bon ça marche, l’erreur venait de la class ContainerOreFurnace
le code avec l’erreur :
public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); i++) { ICrafting icrafting = (ICrafting) this.crafters.get(i); if(this.lastCookTime != this.oreFurnace.furnaceCookTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.furnaceCookTime); } if(this.lastBurnTime != this.oreFurnace.furnaceBurnTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.furnaceBurnTime); } if(this.lastCurrentItemBurnTime != this.oreFurnace.currentItemBurnTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.currentItemBurnTime); } } this.lastCookTime = this.oreFurnace.furnaceCookTime; this.lastBurnTime = this.oreFurnace.furnaceBurnTime; this.lastCurrentItemBurnTime = this.oreFurnace.currentItemBurnTime; }
Et la version sans bug :
public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.crafters.size(); ++i) { ICrafting icrafting = (ICrafting)this.crafters.get(i); if(this.lastCookTime != this.oreFurnace.furnaceCookTime) { icrafting.sendProgressBarUpdate(this, 0, this.oreFurnace.furnaceCookTime); } if(this.lastBurnTime != this.oreFurnace.furnaceBurnTime) { icrafting.sendProgressBarUpdate(this, 1, this.oreFurnace.furnaceBurnTime); } if(this.lastBurnTime != this.oreFurnace.currentItemBurnTime) { icrafting.sendProgressBarUpdate(this, 2, this.oreFurnace.currentItemBurnTime); } } this.lastCookTime = this.oreFurnace.furnaceCookTime; this.lastBurnTime = this.oreFurnace.furnaceBurnTime; this.lastBurnTime = this.oreFurnace.currentItemBurnTime; }
Dans “for(int i = 0; i < this.crafters.size(); i++)” ce n’est pas i++ mais ++i
et j’avais oublié de determiner dans quel slot la flèche et le feu devait se référencer, du coup j’avais tous mis à 0 et c’est pour ça que la flèche donnait la valeur “burnTime” au lieu de “cookTime”
Cependant j’ai un nouveau problème : quand la flèche arrive à la moitié elle s’arrète au lieu d’aller jusqu’au bout.
Je vais essayer de résoudre le problème moi même et quand j’aurai réussi je vous préviendrais pour déplacer le sujet.
C’est bon tout fonctionne à la perfection !
Merci ! Problème Résolu ! -
Juste :
@‘NicoKing60’:Dans “for(int i = 0; i < this.crafters.size(); i++)” ce n’est pas i++ mais ++i
ça ne change rien, c’est juste une syntaxe différente.
-
ah d’accord autant pour moi XD
-
Du-coup si c’est résolu tu peux mettre la balise résolu.