Non résolu Four qui ne cuit pas
-
Bonjour à tous et à toutes, j’ai aujourd’hui un soucis assez conséquent et très ennuyant.
Mon four ne cuit pas les items qui s’y trouvent. J’ai déjà éssayé avec le charbon vanilla, de baisser l’xp reçue…
Je met mes items, mon charbon et rien ne se passe, rien ne cuit, pas d’animation, rien.
Ca ne fonctionne toujours pas, pas de crash, pas d’erreur dans la console, cela fait plus de 3 semaines que je galère.Voici :
Mon Block :package fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace; import fr.flowarg.gunsofchickens.Main; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenFurnace; import fr.flowarg.gunsofchickens.init.BlockInit; import fr.flowarg.gunsofchickens.templates.BlockBase; import fr.flowarg.gunsofchickens.utils.handlers.ConfigHandler; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import java.util.Random; public class ChickenFurnace extends BlockBase implements ITileEntityProvider { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static final PropertyBool BURNING = PropertyBool.create("burning"); public ChickenFurnace(String name) { super(name, Material.IRON, 40f, 40f, "pickaxe", 2); setSoundType(SoundType.METAL); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(BURNING, false)); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockInit.CHICKEN_FURNACE); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(BlockInit.CHICKEN_FURNACE); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { playerIn.openGui(Main.instance, ConfigHandler.GUI_CHICKEN_FURNACE, worldIn, pos.getX(), pos.getY(), pos.getZ()); } return true; } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState north = worldIn.getBlockState(pos.north()); IBlockState south = worldIn.getBlockState(pos.south()); IBlockState west = worldIn.getBlockState(pos.west()); IBlockState east = worldIn.getBlockState(pos.east()); EnumFacing face = (EnumFacing) state.getValue(FACING); if (face == EnumFacing.NORTH && north.isFullBlock() && !south.isFullBlock()) face = EnumFacing.SOUTH; else if (face == EnumFacing.SOUTH && south.isFullBlock() && !north.isFullBlock()) face = EnumFacing.NORTH; else if (face == EnumFacing.WEST && west.isFullBlock() && !east.isFullBlock()) face = EnumFacing.EAST; else if (face == EnumFacing.EAST && east.isFullBlock() && !west.isFullBlock()) face = EnumFacing.WEST; worldIn.setBlockState(pos, state.withProperty(FACING, face), 2); } } public static void setState(boolean active, World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if(active) worldIn.setBlockState(pos, BlockInit.CHICKEN_FURNACE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, true), 3); else worldIn.setBlockState(pos, BlockInit.CHICKEN_FURNACE.getDefaultState().withProperty(FACING, state.getValue(FACING)).withProperty(BURNING, false), 3); if (tileentity != null) { tileentity.validate(); worldIn.setTileEntity(pos, tileentity); } } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityChickenFurnace(); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntityChickenFurnace tileEntity = (TileEntityChickenFurnace)worldIn.getTileEntity(pos); InventoryHelper.dropInventoryItems(worldIn, pos, tileEntity); super.breakBlock(worldIn, pos, state); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {BURNING, FACING}); } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getFront(meta); if (facing.getAxis() == EnumFacing.Axis.Y) facing = EnumFacing.NORTH; return this.getDefaultState().withProperty(FACING, facing); } @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getIndex(); } }
Ma TileEntity :
package fr.flowarg.gunsofchickens.blocks.tileentities; import fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace.ChickenFurnace; import fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace.ChickenFurnaceRecipes; import fr.flowarg.gunsofchickens.items.ChickenCoal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityChickenFurnace extends TileEntity implements IInventory,ITickable { private NonNullList<ItemStack> inventory = NonNullList.<ItemStack>withSize(4, ItemStack.EMPTY); private String customName; private int burnTime; private int currentBurnTime; private int cookTime; private int totalCookTime; @Override public String getName() { return this.hasCustomName() ? this.customName : "container.chicken_furnace"; } @Override public boolean hasCustomName() { return this.customName != null && !this.customName.isEmpty(); } public void setCustomName(String customName) { this.customName = customName; } @Override public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName()); } @Override public int getSizeInventory() { return this.inventory.size(); } @Override public boolean isEmpty() { for (ItemStack stack : this.inventory) { if (!stack.isEmpty()) return false; } return true; } @Override public ItemStack getStackInSlot(int index) { return (ItemStack)this.inventory.get(index); } @Override public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(this.inventory, index, count); } @Override public ItemStack removeStackFromSlot(int index) { return ItemStackHelper.getAndRemove(this.inventory, index); } @Override public void setInventorySlotContents(int index, ItemStack stack) { ItemStack itemStack = (ItemStack)this.inventory.get(index); boolean flag = !stack.isEmpty() && stack.isItemEqual(itemStack) && ItemStack.areItemStacksEqualUsingNBTShareTag(stack, itemStack); this.inventory.set(index, stack); if (stack.getCount() > this.getInventoryStackLimit()) stack.setCount(this.getInventoryStackLimit()); if (index == 0 && !flag) { ItemStack stack1 = (ItemStack)this.inventory.get(index + 1); this.totalCookTime = this.getCookTime(stack, stack1); this.cookTime = 0; this.markDirty(); } } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.inventory = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY); ItemStackHelper.loadAllItems(compound, this.inventory); this.burnTime = compound.getInteger("BurnTime"); this.cookTime = compound.getInteger("CookTime"); this.totalCookTime = compound.getInteger("TotalCookTime"); this.currentBurnTime = getItemBurnTime((ItemStack)this.inventory.get(2)); if (compound.hasKey("CustomChickenFurnaceName", 8)) this.setCustomName(compound.getString("CustomChickenFurnaceName")); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("BurnTime", (short)this.burnTime); compound.setInteger("CookTime", (short)this.cookTime); compound.setInteger("TotalCookTime", (short)this.totalCookTime); ItemStackHelper.saveAllItems(compound, this.inventory); if (this.hasCustomName()) compound.setString("CustomChickenFurnaceName", this.customName); return compound; } @Override public int getInventoryStackLimit() { return 64; } public boolean isBurning() { return this.burnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(IInventory inventory) { return inventory.getField(0) > 0; } @Override public void update() { boolean flag = this.isBurning(); boolean flag1 = false; if (this.isBurning()) --this.burnTime; if (!this.world.isRemote) { ItemStack stack = (ItemStack)this.inventory.get(2); if (this.isBurning() || !stack.isEmpty() && ((((ItemStack)this.inventory.get(0)).isEmpty()) || ((ItemStack)this.inventory.get(1)).isEmpty())) { if (!this.isBurning() && this.canSmelt()) { this.burnTime = getItemBurnTime(stack); this.currentBurnTime = this.burnTime; if (this.isBurning()) { flag1 = true; if (!stack.isEmpty()) { Item item = stack.getItem(); stack.shrink(1); if (stack.isEmpty()) { ItemStack item1 = item.getContainerItem(stack); this.inventory.set(2, item1); } } } } if (this.isBurning() && this.canSmelt()) { ++this.cookTime; if (this.cookTime == this.totalCookTime) { this.cookTime = 0; this.totalCookTime = this.getCookTime((ItemStack)this.inventory.get(0), (ItemStack)this.inventory.get(2)); this.smeltItem(); flag1 = true; } } else this.cookTime = 0; } else if (!this.isBurning() && this.cookTime > 0) { this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime); } if (flag != this.isBurning()) { flag1 = true; ChickenFurnace.setState(this.isBurning(), this.world, this.pos); } if (flag1) { this.markDirty(); } } } public int getCookTime(ItemStack input1, ItemStack input2) { return 200; } private boolean canSmelt() { if (((ItemStack)this.inventory.get(0)).isEmpty() || ((ItemStack)this.inventory.get(1)).isEmpty()) return false; else { ItemStack result = ChickenFurnaceRecipes.getInstance().getSmeltingResult((ItemStack)this.inventory.get(0), (ItemStack)this.inventory.get(1)); if (result.isEmpty()) return false; else { ItemStack output = (ItemStack)this.inventory.get(3); if (output.isEmpty()) return true; if (!output.isItemEqual(result)) return false; int res = output.getCount() + result.getCount(); return res <= getInventoryStackLimit() && res <= output.getMaxStackSize(); } } } public void smeltItem() { if (this.canSmelt()) { ItemStack input1 = (ItemStack)this.inventory.get(0); ItemStack input2 = (ItemStack)this.inventory.get(1); ItemStack result = ChickenFurnaceRecipes.getInstance().getSmeltingResult(input1, input2); ItemStack output = (ItemStack)this.inventory.get(3); if (output.isEmpty()) this.inventory.set(3, result.copy()); else if(output.getItem() == result.getItem()) output.grow(result.getCount()); input1.shrink(1); input2.shrink(1); } } public static int getItemBurnTime(ItemStack fuel) { if (fuel.isEmpty()) return 0; else return ForgeEventFactory.getItemBurnTime(fuel); } public static boolean isItemFuel(ItemStack fuel) { return getItemBurnTime(fuel) > 0; } @Override public boolean isUsableByPlayer(EntityPlayer player) { return getWorld().getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)getPos().getX() + 0.5d, (double)getPos().getY() + 0.5d, (double)getPos().getZ() + 0.5d) <= 64; } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 3) return false; else if (index != 2) return true; else return isItemFuel(stack); } @Override public int getField(int id) { switch (id) { case 0: return this.burnTime; case 1: return this.currentBurnTime; 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.burnTime = value; break; case 1: this.currentBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; break; } } @Override public int getFieldCount() { return 4; } @Override public void clear() { this.inventory.clear(); } }
Mon Container :
package fr.flowarg.gunsofchickens.blocks.containers; import fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace.ChickenFurnaceRecipes; import fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace.slots.SlotChickenFurnaceFuel; import fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace.slots.SlotChickenFurnaceOutput; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerChickenFurnace extends Container { private final TileEntityChickenFurnace tileentity; private int cookTime, totalCookTime, burnTime, currentBurnTime; public ContainerChickenFurnace(InventoryPlayer playerInv, TileEntityChickenFurnace tileentity) { this.tileentity = tileentity; this.addSlotToContainer(new Slot(tileentity, 0, 26, 11)); this.addSlotToContainer(new Slot(tileentity, 1, 26, 59)); this.addSlotToContainer(new SlotChickenFurnaceFuel(tileentity, 2, 7, 35)); this.addSlotToContainer(new SlotChickenFurnaceOutput(playerInv.player, tileentity,3, 81, 36)); for(int y = 0; y < 3; y++) { for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } for(int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142)); } } @Override public void addListener(IContainerListener listener) { super.addListener(listener); listener.sendAllWindowProperties(this, this.tileentity); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for(int i = 0; i < this.listeners.size(); ++i) { IContainerListener listener = (IContainerListener)this.listeners.get(i); if(this.cookTime != this.tileentity.getField(2)) listener.sendWindowProperty(this, 2, this.tileentity.getField(2)); if(this.burnTime != this.tileentity.getField(0)) listener.sendWindowProperty(this, 0, this.tileentity.getField(0)); if(this.currentBurnTime != this.tileentity.getField(1)) listener.sendWindowProperty(this, 1, this.tileentity.getField(1)); if(this.totalCookTime != this.tileentity.getField(3)) listener.sendWindowProperty(this, 3, this.tileentity.getField(3)); } this.cookTime = this.tileentity.getField(2); this.burnTime = this.tileentity.getField(0); this.currentBurnTime = this.tileentity.getField(1); this.totalCookTime = this.tileentity.getField(3); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int data) { this.tileentity.setField(id, data); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.tileentity.isUsableByPlayer(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack stack = ItemStack.EMPTY; Slot slot = (Slot)this.inventorySlots.get(index); if(slot != null && slot.getHasStack()) { ItemStack stack1 = slot.getStack(); stack = stack1.copy(); if(index == 3) { if(!this.mergeItemStack(stack1, 4, 40, true)) return ItemStack.EMPTY; slot.onSlotChange(stack1, stack); } else if(index != 2 && index != 1 && index != 0) { Slot slot1 = (Slot)this.inventorySlots.get(index + 1); if(!ChickenFurnaceRecipes.getInstance().getSmeltingResult(stack1, slot1.getStack()).isEmpty()) { if(!this.mergeItemStack(stack1, 0, 2, false)) { return ItemStack.EMPTY; } else if(TileEntityChickenFurnace.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(TileEntityChickenFurnace.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(TileEntityChickenFurnace.isItemFuel(stack1)) { if(!this.mergeItemStack(stack1, 2, 3, false)) return ItemStack.EMPTY; } else if(index >= 4 && index < 31) { if(!this.mergeItemStack(stack1, 31, 40, false)) return ItemStack.EMPTY; } else if(index >= 31 && index < 40 && !this.mergeItemStack(stack1, 4, 31, false)) { return ItemStack.EMPTY; } } } else if(!this.mergeItemStack(stack1, 4, 40, false)) { return ItemStack.EMPTY; } if(stack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if(stack1.getCount() == stack.getCount()) return ItemStack.EMPTY; slot.onTake(playerIn, stack1); } return stack; } }
Mon GUI :
package fr.flowarg.gunsofchickens.blocks.gui; import fr.flowarg.gunsofchickens.blocks.containers.ContainerChickenFurnace; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenFurnace; import fr.flowarg.gunsofchickens.utils.References; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GUIChickenFurnace extends GuiContainer { private static final ResourceLocation TEXTURES = new ResourceLocation(References.MODID + ":textures/gui/container/chicken_furnace.png"); private final InventoryPlayer playerInv; private final TileEntityChickenFurnace tileentity; public GUIChickenFurnace(InventoryPlayer playerInv, TileEntityChickenFurnace tileentity) { super(new ContainerChickenFurnace(playerInv, tileentity)); this.tileentity = tileentity; this.playerInv = playerInv; } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String tileName = this.tileentity.getDisplayName().getUnformattedText(); this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) + 3, 8, 4210752); this.fontRenderer.drawString(this.playerInv.getDisplayName().getUnformattedText(), 122, 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(TEXTURES); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); if(TileEntityChickenFurnace.isBurning(tileentity)) { int k = this.getBurnLeftScaled(13); this.drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 54 + 12 - k, 176, 12 - k, 14, k + 1); } int l = this.getCookProgressScaled(24); this.drawTexturedModalRect(this.guiLeft + 44, this.guiTop + 36, 176, 14, l + 1, 16); } private int getBurnLeftScaled(int pixels) { int i = this.tileentity.getField(1); if(i == 0) i = 200; return this.tileentity.getField(0) * pixels / i; } private int getCookProgressScaled(int pixels) { int i = this.tileentity.getField(2); int j = this.tileentity.getField(3); return j != 0 && i != 0 ? i * pixels / j : 0; } }
Mes recettes :
package fr.flowarg.gunsofchickens.blocks.machines.chickenfurnace; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; import fr.flowarg.gunsofchickens.init.BlockInit; import fr.flowarg.gunsofchickens.init.ItemInit; import net.minecraft.item.ItemStack; import java.util.Map; import static java.util.Map.Entry; public class ChickenFurnaceRecipes { private static final ChickenFurnaceRecipes INSTANCE = new ChickenFurnaceRecipes(); public static ChickenFurnaceRecipes getInstance() { return INSTANCE; } private final Table<ItemStack, ItemStack, ItemStack> smeltingList = HashBasedTable.create(); private final Map<ItemStack, Float> experienceList = Maps.newHashMap(); public ChickenFurnaceRecipes() { addSmeltingRecipe(new ItemStack(ItemInit.CHICKEN_DIAMOND), new ItemStack(ItemInit.CHICKEN_INGOT), new ItemStack(ItemInit.ULTIMATE_INGOT), 999f); addSmeltingRecipe(new ItemStack(ItemInit.CHICKEN_INGOT), new ItemStack(ItemInit.CHICKEN_DIAMOND), new ItemStack(ItemInit.ULTIMATE_INGOT), 999f); addSmeltingRecipe(new ItemStack(BlockInit.CHICKEN_DIAMOND_BLOCK), new ItemStack(BlockInit.CHICKEN_BLOCK), new ItemStack(BlockInit.ULTIMATE_BLOCK), 999f); addSmeltingRecipe(new ItemStack(BlockInit.CHICKEN_BLOCK), new ItemStack(BlockInit.CHICKEN_DIAMOND_BLOCK), new ItemStack(BlockInit.ULTIMATE_BLOCK), 999f); } public void addSmeltingRecipe(ItemStack input1, ItemStack input2, ItemStack result, float experience) { if (this.getSmeltingResult(input1, input2) != ItemStack.EMPTY) return; this.smeltingList.put(input1, input2, result); this.experienceList.put(result, Float.valueOf(experience)); } public ItemStack getSmeltingResult(ItemStack input1, ItemStack input2) { for (Entry<ItemStack, Map<ItemStack, ItemStack>> entry : this.smeltingList.columnMap().entrySet()) { if (this.compareItemStacks(input1, entry.getKey())) { for (Entry<ItemStack, ItemStack> ent : entry.getValue().entrySet()) { if (this.compareItemStacks(input2, entry.getKey())) { return ent.getValue(); } } } } return ItemStack.EMPTY; } private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) { return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata()); } public Table<ItemStack, ItemStack, ItemStack> getDualSmeltingList() { return this.smeltingList; } public float getSmeltingExperience(ItemStack stack) { for (Entry<ItemStack, Float> entry : this.experienceList.entrySet()) { if (this.compareItemStacks(stack, entry.getKey())) { return entry.getValue().floatValue(); } } return 0.0f; } }
Mon GUIHandler :
package fr.flowarg.gunsofchickens.utils.handlers; import fr.flowarg.gunsofchickens.blocks.containers.ContainerChickenChest; import fr.flowarg.gunsofchickens.blocks.containers.ContainerChickenFurnace; import fr.flowarg.gunsofchickens.blocks.gui.GUIChickenChest; import fr.flowarg.gunsofchickens.blocks.gui.GUIChickenFurnace; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenChest; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GUIHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == ConfigHandler.GUI_CHICKEN_FURNACE) return new ContainerChickenFurnace(player.inventory, (TileEntityChickenFurnace)world.getTileEntity(new BlockPos(x, y, z))); if (ID == ConfigHandler.GUI_CHICKEN_CHEST) return new ContainerChickenChest(player.inventory, (TileEntityChickenChest)world.getTileEntity(new BlockPos(x, y, z))); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == ConfigHandler.GUI_CHICKEN_FURNACE) return new GUIChickenFurnace(player.inventory, (TileEntityChickenFurnace)world.getTileEntity(new BlockPos(x, y, z))); if (ID == ConfigHandler.GUI_CHICKEN_CHEST) return new GUIChickenChest(player.inventory, (TileEntityChickenChest)world.getTileEntity(new BlockPos(x, y, z))); return null; } }
Mon TileEntityHandler
package fr.flowarg.gunsofchickens.utils.handlers; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenChest; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenFurnace; import fr.flowarg.gunsofchickens.utils.References; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.GameRegistry; public class TileEntityHandler { public static void registerTileEntities() { GameRegistry.registerTileEntity(TileEntityChickenChest.class, new ResourceLocation(References.MODID + ":chicken_chest")); GameRegistry.registerTileEntity(TileEntityChickenFurnace.class, new ResourceLocation(References.MODID + ":chicken_furnace")); } }
Mon RegistryHandler :
package fr.flowarg.gunsofchickens.utils.handlers; import fr.flowarg.gunsofchickens.Main; import fr.flowarg.gunsofchickens.blocks.animation.chickenchest.RenderChickenChest; import fr.flowarg.gunsofchickens.blocks.tileentities.TileEntityChickenChest; import fr.flowarg.gunsofchickens.commands.*; import fr.flowarg.gunsofchickens.entity.EntityChickenTNTPrimed; import fr.flowarg.gunsofchickens.init.*; import fr.flowarg.gunsofchickens.utils.IHasModel; import fr.flowarg.gunsofchickens.utils.References; import fr.flowarg.gunsofchickens.utils.compat.OreDictionnaryCompat; import fr.flowarg.gunsofchickens.utils.util.UtilLocation; import fr.flowarg.gunsofchickens.world.gen.GenOres; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import static net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(modid = References.MODID) public class RegistryHandler { public static void preInitRegistriesCOP(FMLPreInitializationEvent event) { EntityInit.registerEntities(); Main.LOGGER.debug("Entities registered."); Main.LOGGER.debug("Registering config..."); ConfigHandler.registerConfig(event); Main.LOGGER.debug("Config registered."); BiomeInit.registerBiomes(); Main.LOGGER.debug("Registered biomes."); DimensionInit.registerDimensions(); Main.LOGGER.debug("Registered dimensions."); } public static void postInitRegistriesCLP() { //RenderHandler.registerEntitiesRenders(); EntityInit.registerEntitiesRender(); Main.LOGGER.debug("Registered entities renders."); } @SubscribeEvent public static void onItemRegister(RegistryEvent.Register<Item> event) { Main.LOGGER.debug("Registering Items..."); event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0])); Main.LOGGER.debug("Registered Items."); } @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { Main.LOGGER.debug("Registering Blocks..."); event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0])); Main.LOGGER.debug("Registered Blocks."); Main.LOGGER.debug("Registering TileEntities..."); TileEntityHandler.registerTileEntities(); Main.LOGGER.debug("Registered TileEntities."); } public static void initRegistriesCOP() { Main.LOGGER.debug("Registering TNT in Dispenser..."); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Item.getItemFromBlock(BlockInit.CHICKEN_TNT), new BehaviorDefaultDispenseItem() { public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); BlockPos blockpos = source.getBlockPos().offset(source.getBlockState().getValue(BlockDispenser.FACING)); EntityChickenTNTPrimed entityChickenTNTPrimed = new EntityChickenTNTPrimed(world, (double)blockpos.getX() + 0.5D, blockpos.getY(), (double)blockpos.getZ() + 0.5D, null); world.spawnEntity(entityChickenTNTPrimed); world.playSound(null, entityChickenTNTPrimed.posX, entityChickenTNTPrimed.posY, entityChickenTNTPrimed.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); stack.shrink(1); return stack; } }); Main.LOGGER.debug("Registered TNT in Dispenser."); RecipesInit.instance.initRecipes(); Main.LOGGER.debug("Recipes registered."); NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GUIHandler()); Main.LOGGER.debug("GUIs registered."); OreDictionnaryCompat.registerOres(); Main.LOGGER.debug("Ores registered."); } @SideOnly(Side.CLIENT) @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { Main.proxy.registerItemRenderer(Item.getItemFromBlock(BlockInit.CHICKEN_CHEST), 0); Main.LOGGER.debug("Registering TileEntities rendered..."); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChickenChest.class, new RenderChickenChest()); Main.LOGGER.debug("Registered TileEntities rendered."); Main.LOGGER.debug("Model registered for : " + BlockInit.CHICKEN_CHEST.getLocalizedName()); for (Item item : ItemInit.ITEMS) { if (item instanceof IHasModel) { ((IHasModel)item).registerModels(); Main.LOGGER.debug("Model registered for : " + item.getItemStackDisplayName(new ItemStack(item))); } } Main.LOGGER.debug("Models registered for Items."); for (Block block : BlockInit.BLOCKS) { if (block instanceof IHasModel) { ((IHasModel)block).registerModels(); Main.LOGGER.debug("Model registered for : " + block.getLocalizedName()); } } Main.LOGGER.debug("Models registered for Blocks."); Main.LOGGER.debug("Models registered."); } @SubscribeEvent public static void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.getModID().equals(References.MODID)) { if (ConfigHandler.config.hasChanged()) { ConfigHandler.config.save(); } } }
C’est assez long, j’en convient, mais je juge nécéssaire pour pouvoir m’aider au maximum.
(J’ai retiré dans le RegistryHandler des events, des fonctions inutiles qui prenaient bcp de place, normal qu’ils y aient certans imports non utilisés ^^ ) .Voilà le tout, je souhaite infiniment que quelqu’un aura la foi et la gentillesse de m’aider.
Flow
-
Ce message a été supprimé ! -
up ?