pauljoda Posted February 10, 2014 Posted February 10, 2014 I have had an issue getting my furnace to work. I have registered all the blocks correctly and I know the function I'm using will work (world.setBlock(..)) however when I use it in the "updateFurnaceBlockState" method which is basically a copy of minecraft's one, when the furnace updates to active it just disappears. Registering in the preInit through this class package com.pauljoda.modularfurnace.blocks; import java.util.HashMap; import java.util.Map; import com.pauljoda.modularfurnace.GeneralSettings; import com.pauljoda.modularfurnace.lib.Reference; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.util.RegistryNamespaced; public class BlockManager { public static Block furnaceCore; public static Block furnaceDummy; public static Block furnaceDummyRedstone; public static Block furnaceDummyGlowStone; public static Block furnaceDummyDiamond; public static Block crafterInactive; public static Block crafterActive; public static Block furnaceDummyEmerald; public static Block furnaceCoreActive; public static Block lavaCore; public static Block furnaceDummyIO; public static Block furnaceDummyActiveIO; public static Block furnaceCoreSmeltery; public static Block furnaceCoreSmelteryActive; public static Block furnaceDummySmeltery; public static Block furnaceSmelteryBrick; public static Block furnaceCoreMulti; public static Block furnaceCoreMultiActive; public static Block furnaceMultiDummy; public static Block furnaceDummyMultiRedstone; public static Block furnaceDummyMultiIron; public static Block furnaceDummyMultiEmerald; //OverLays public static Block overLayTexture; public static Block smelterOverlay; //Items public static Item copperIngot; public static Item aluminiumIngot; public static Item tinIngot; public static void registerBlocks() { //Creation furnaceCore = new BlockFurnaceCore(false).setBlockName("blockFurnaceCore"); furnaceCoreActive = new BlockFurnaceCore(true).setLightLevel(.875F).setBlockName("blockFurnaceCoreActive"); furnaceDummy = new BlockFurnaceDummy(); furnaceDummyRedstone = new BlockFurnaceDummy(); furnaceDummyGlowStone = new BlockFurnaceDummy(); furnaceDummyDiamond = new BlockFurnaceDummy(); crafterInactive = new BlockCrafterInactive(Material.wood); crafterActive = new BlockCrafterActive(); furnaceDummyEmerald = new BlockFurnaceDummy(); lavaCore = new BlockLavaCore(Material.iron); furnaceDummyIO = new BlockFurnaceDummyIO(Material.rock); furnaceDummyActiveIO = new BlockFurnaceDummyIOActive(); furnaceCoreSmeltery = new BlockFurnaceCoreSmeltery(false); furnaceCoreSmelteryActive = new BlockFurnaceCoreSmeltery(true); furnaceDummySmeltery = new BlockFurnaceDummySmeltery(); furnaceSmelteryBrick = new BlockFurnaceSmelteryBrick(); furnaceCoreMulti = new BlockMultiFurnaceCore(false); furnaceCoreMultiActive = new BlockMultiFurnaceCore(true); furnaceMultiDummy = new BlockMultiFurnaceDummy(); furnaceDummyMultiRedstone = new BlockMultiFurnaceDummy(); furnaceDummyMultiIron = new BlockMultiFurnaceDummy(); furnaceDummyMultiEmerald = new BlockMultiFurnaceDummy(); copperIngot = new MetalCopperIngot(); aluminiumIngot = new MetalAluminiumIngot(); tinIngot = new MetalTinIngot(); if(GeneralSettings.useTextures) overLayTexture = new BlockTextureOverlay(GeneralSettings.textureName, "overLayTexture", true); else overLayTexture = new BlockTextureOverlay("custom_overlay", "overLayTexture", true); smelterOverlay = new BlockTextureOverlay("smelterOverlay","smelterOverlay", false); } public static void register() { //Register GameRegistry.registerBlock(furnaceCore, "blockFurnaceCore"); GameRegistry.registerBlock(furnaceDummy, "blockFurnaceDummy"); GameRegistry.registerBlock(furnaceDummyRedstone, "blockFurnaceDummyRedstone"); GameRegistry.registerBlock(furnaceDummyGlowStone, "blockFurnaceDummyGlowStone"); GameRegistry.registerBlock(crafterInactive, "crafterInactive"); GameRegistry.registerBlock(crafterActive, "crafterActive"); GameRegistry.registerBlock(furnaceDummyDiamond, "blockFurnaceDummyDiamond"); GameRegistry.registerBlock(furnaceDummyEmerald, "blockFurnaceDummyEmerald"); GameRegistry.registerBlock(lavaCore, "blockLavaCore"); GameRegistry.registerBlock(furnaceDummyIO, "furnaceDummyIO"); GameRegistry.registerBlock(furnaceDummyActiveIO, "furnaceDummyActiveIO"); GameRegistry.registerBlock(furnaceCoreSmeltery, "furnaceCoreSmeltery"); GameRegistry.registerBlock(furnaceDummySmeltery, "blockFurnaceDummySmeltery"); GameRegistry.registerBlock(furnaceSmelteryBrick, "furnaceSmelteryBrick"); GameRegistry.registerBlock(furnaceCoreMulti, "furnaceCoreMulti"); GameRegistry.registerBlock(furnaceMultiDummy, "furnaceMultiDummy"); GameRegistry.registerBlock(furnaceDummyMultiRedstone, "furnaceDummyMultiRedstone"); GameRegistry.registerBlock(furnaceDummyMultiIron, "furnaceDummyMultiIron"); GameRegistry.registerBlock(furnaceDummyMultiEmerald, "furnaceDummyMultiEmerald"); GameRegistry.registerItem(copperIngot, "copperIngot"); GameRegistry.registerItem(aluminiumIngot, "aluminiumIngot"); GameRegistry.registerItem(tinIngot, "tinIngot"); GameRegistry.registerBlock(overLayTexture, "overLayTexture"); GameRegistry.registerBlock(smelterOverlay, "smelterOverlay"); /* //Add Name LanguageRegistry.addName(furnaceCore, "Modular Furnace Core"); LanguageRegistry.addName(furnaceDummy, "Modular Furnace Dummy CobbleStone"); LanguageRegistry.addName(furnaceDummyRedstone, "Modular Furnace Dummy Redstone"); LanguageRegistry.addName(furnaceDummyGlowStone, "Modular Furnace Dummy Iron"); LanguageRegistry.addName(crafterInactive, "Crafting Core"); LanguageRegistry.addName(crafterActive, "Crafting Core Active"); LanguageRegistry.addName(furnaceDummyDiamond, "Modular Furnace Dummy Diamond"); LanguageRegistry.addName(furnaceDummyEmerald, "Modular Furance Dummy Emerald"); LanguageRegistry.addName(lavaCore, "Lava Core"); LanguageRegistry.addName(furnaceDummyIO, "Modular Furnace IO"); LanguageRegistry.addName(furnaceDummyActiveIO, "Modular Furnace IO Active"); LanguageRegistry.addName(furnaceCoreSmeltery, "Modular Furnace Core Smeltery"); LanguageRegistry.addName(furnaceDummySmeltery, "Modular Furnace Smeltery Dummy"); LanguageRegistry.addName(furnaceSmelteryBrick, "Modular Furnace Smeltery Brick"); LanguageRegistry.addName(furnaceCoreMulti, "Multi Furnace Core"); LanguageRegistry.addName(copperIngot, "Copper Ingot"); LanguageRegistry.addName(aluminiumIngot, "Aluminium Ingot"); LanguageRegistry.addName(tinIngot, "Tin Ingot"); LanguageRegistry.addName(overLayTexture, "Tough Glass"); LanguageRegistry.addName(smelterOverlay, "Tinted Glass"); LanguageRegistry.addName(paintBrush, "Paint Brush"); */ } public static void registerCraftingRecipes() { CraftingManager.getInstance().addRecipe(new ItemStack(furnaceCore, 1), "XXX", "XxX", "XXX", 'X', Items.iron_ingot, 'x', Blocks.furnace); CraftingManager.getInstance().addRecipe(new ItemStack(furnaceDummyIO, 1), "XXX", "XxX", "XXX", 'X', Blocks.cobblestone, 'x', Blocks.dispenser); CraftingManager.getInstance().addRecipe(new ItemStack(crafterInactive, 1), "XxX", "xCx", "XxX", 'X', Items.iron_ingot, 'x', new ItemStack(Items.dye, 9, 4), 'C', Blocks.crafting_table); CraftingManager.getInstance().addRecipe(new ItemStack(lavaCore, 1), "OXO", "XCX", "OXO", 'X', Blocks.iron_bars, 'C', Items.lava_bucket, 'O', Blocks.obsidian); CraftingManager.getInstance().addRecipe(new ItemStack(furnaceCoreSmeltery, 1), "XXX", "XxX", "XXX", 'X', BlockManager.furnaceSmelteryBrick, 'x', BlockManager.furnaceCore); CraftingManager.getInstance().addRecipe(new ItemStack(furnaceCoreMulti, 1), "XXX", "XxX", "XXX", 'X', Blocks.furnace, 'x', BlockManager.furnaceCore); CraftingManager.getInstance().addRecipe(new ItemStack(furnaceSmelteryBrick, 1), "OXO", "XOX", "OXO", 'X', Blocks.stonebrick, 'O', Blocks.stone); CraftingManager.getInstance().addRecipe(new ItemStack(overLayTexture, , "XXX", "XOX", "XXX", 'X', Items.iron_ingot, 'O', Blocks.glass); ItemStack ink = new ItemStack(Items.dye, 1, 0); CraftingManager.getInstance().addShapelessRecipe(new ItemStack(smelterOverlay, 1), ink, new ItemStack(Blocks.glass, 1)); } } TileEntity package com.pauljoda.modularfurnace.tileentity; import java.util.Random; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.pauljoda.modularfurnace.lib.Reference; import com.pauljoda.modularfurnace.blocks.BlockFurnaceCore; import com.pauljoda.modularfurnace.blocks.BlockManager; import net.minecraft.block.Block; import net.minecraft.block.material.Material; 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.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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; public class TileEntityFurnaceCore extends TileEntity implements ISidedInventory { //Automation related private static final int[] slots_top = new int[] {0}; private static final int[] slots_bottom = new int[] {2, 1}; private static final int[] slots_sides = new int[] {1}; private static final int[] slots_output_only = new int [] {2}; //Storage for blocks if they have meaning public int redstoneBlocksInFurnace = 0; public int redstoneMultiplier = 6; public int cookSpeed = 175; public int ironBlocksInFurnace = 0; public boolean emeralds; //Furnace related things private ItemStack[] furnaceItems = new ItemStack[3]; public int furnaceBurnTime; public int currentItemBurnTime; public int furnaceCookTime; private String field_94130_e; //Booleans public boolean isValidMultiblock = false; public boolean diamonds = false; public boolean crafterEnabled = false; //Randomizer Random r = new Random(); public TileEntityFurnaceCore() { } //Turns dummies back to their respective blocks public void invalidateMultiblock() { int metadata = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); ironBlocksInFurnace = 0; redstoneBlocksInFurnace = 0; diamonds = false; crafterEnabled = false; emeralds = false; revertDummies(); isValidMultiblock = false; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 2); } //Called to check if this is already formed public boolean getIsValid() { return isValidMultiblock; } //Checks to see if the structure is valid public boolean checkIfProperlyFormed() { int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); Block blockId = worldObj.getBlock(x, y, z); if(horiz == 0 && vert == 0) { if(depth == 0) // Looking at self, move on! continue; if(depth == 1) // Center must be air! { if(blockId != Blocks.air) { return false; } else continue; } } //if(blockId != Block.cobblestone.blockID && blockId != Block.blockRedstone.blockID && blockId != Block.blockIron.blockID && blockId != Block.blockDiamond.blockID && blockId != ModularFurnace.crafterInactiveID && blockId != Block.blockEmerald.blockID && blockId != ModularFurnace.furnaceDummyIOID) if(!Reference.isValidBlock(blockId.getUnlocalizedName())) { if(Reference.isModularTile(blockId.getUnlocalizedName())) return true; return false; } } } } return true; } //Converts blocks into their respective dummies public void convertDummies() { int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); if(horiz == 0 && vert == 0 && depth == 1) { continue; } if(horiz == 0 && vert == 0) if(depth == 0) continue; if(worldObj.getBlock(x, y, z) == Blocks.redstone_block) { this.redstoneBlocksInFurnace = this.redstoneBlocksInFurnace + 1; Block icon = worldObj.getBlock(x, y, z); int metadata = worldObj.getBlockMetadata(x, y, z); worldObj.setBlock(x, y, z, BlockManager.furnaceDummyRedstone); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); if(icon == BlockManager.furnaceDummyRedstone) { icon = Block.getBlockFromName(dummyTE.icon); metadata = dummyTE.metadata; } else { dummyTE.icon = icon.getUnlocalizedName(); dummyTE.metadata = metadata; } dummyTE.setCore(this); } else if(worldObj.getBlock(x, y, z) == Blocks.iron_block) { this.ironBlocksInFurnace = ironBlocksInFurnace + 1; Block icon = worldObj.getBlock(x, y, z); int metadata = worldObj.getBlockMetadata(x, y, z); worldObj.setBlock(x, y, z, BlockManager.furnaceDummyGlowStone); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); if(icon == BlockManager.furnaceDummyGlowStone) { icon = Block.getBlockFromName(dummyTE.icon); metadata = dummyTE.metadata; } else { dummyTE.icon = icon.getUnlocalizedName(); dummyTE.metadata = metadata; } dummyTE.setCore(this); } else if(worldObj.getBlock(x, y, z) == Blocks.diamond_block) { diamonds = true; Block icon = worldObj.getBlock(x, y, z); int metadata = worldObj.getBlockMetadata(x, y, z); worldObj.setBlock(x, y, z, BlockManager.furnaceDummyDiamond); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); if(icon == BlockManager.furnaceDummyDiamond) { icon = Block.getBlockFromName(dummyTE.icon); metadata = dummyTE.metadata; } else { dummyTE.icon = icon.getUnlocalizedName(); dummyTE.metadata = metadata; } dummyTE.setCore(this); } else if(worldObj.getBlock(x, y, z) == Blocks.emerald_block) { emeralds = true; Block icon = worldObj.getBlock(x, y, z); int metadata = worldObj.getBlockMetadata(x, y, z); worldObj.setBlock(x, y, z, BlockManager.furnaceDummyEmerald); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); if(icon == BlockManager.furnaceDummyEmerald) { icon = Block.getBlockFromName(dummyTE.icon); metadata = dummyTE.metadata; } else { dummyTE.icon = icon.getUnlocalizedName(); dummyTE.metadata = metadata; } dummyTE.setCore(this); } else if(worldObj.getBlock(x, y, z) == BlockManager.crafterInactive) { crafterEnabled = true; worldObj.setBlock(x, y, z, BlockManager.crafterActive); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); dummyTE.setCore(this); } else if(worldObj.getBlock(x, y, z) == BlockManager.furnaceDummyIO) { worldObj.setBlock(x, y, z, BlockManager.furnaceDummyActiveIO); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); dummyTE.setCore(this); } else if(!Reference.isModularTile(worldObj.getBlock(x, y, z).getUnlocalizedName()) && worldObj.getBlock(x, y, z) != null) { Block icon = worldObj.getBlock(x, y, z); int metadata = worldObj.getBlockMetadata(x, y, z); worldObj.setBlock(x, y, z, BlockManager.furnaceDummy); worldObj.markBlockForUpdate(x, y, z); TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); if(icon == BlockManager.furnaceDummy) { icon = Block.getBlockFromName(dummyTE.icon); metadata = dummyTE.metadata; } else { dummyTE.icon = icon.getUnlocalizedName(); dummyTE.metadata = metadata; } dummyTE.setCore(this); } } } isValidMultiblock = true; } } //Turns dummies back to their blocks private void revertDummies() { int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); isValidMultiblock = false; /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); Block blockId = worldObj.getBlock(x, y, z); if(horiz == 0 && vert == 0 && depth == 1) { continue; } if(horiz == 0 && vert == 0) if(depth == 0) continue; if(blockId == BlockManager.furnaceDummy) { TileEntityFurnaceDummy dummyTE = (TileEntityFurnaceDummy)worldObj.getTileEntity(x, y, z); worldObj.setBlock(x, y, z, dummyTE.getBlock()); worldObj.setBlockMetadataWithNotify(x, y, z, dummyTE.metadata, 2); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.crafterActive) { worldObj.setBlock(x, y, z, BlockManager.crafterInactive); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.furnaceDummyRedstone) { worldObj.setBlock(x, y, z, Blocks.redstone_block); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.furnaceDummyGlowStone) { worldObj.setBlock(x, y, z, Blocks.iron_block); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.furnaceDummyDiamond) { worldObj.setBlock(x, y, z, Blocks.diamond_block); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.furnaceDummyEmerald) { worldObj.setBlock(x, y, z, Blocks.emerald_block); worldObj.markBlockForUpdate(x, y, z); continue; } if(blockId == BlockManager.furnaceDummyActiveIO) { worldObj.setBlock(x, y, z, BlockManager.furnaceDummyIO); worldObj.markBlockForUpdate(x, y, z); continue; } worldObj.markBlockForUpdate(x, y, z); } } } isValidMultiblock = false; } //See if crafting core is in the structure public boolean checkIfCrafting() { int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); Block blockId = worldObj.getBlock(x, y, z); if(horiz == 0 && vert == 0) { if(depth == 0) // Looking at self, move on! continue; if(depth == 1) // Center must be air! { if(blockId != null) return false; else continue; } } if(blockId == BlockManager.crafterActive || blockId == BlockManager.crafterInactive) { return true; } } } } return false; } //Furnace stuff @Override public void updateEntity() { boolean flag = this.furnaceBurnTime > 0; boolean flag1 = false; if (this.furnaceBurnTime > 0) { --this.furnaceBurnTime; } if (!this.worldObj.isRemote) { if (this.furnaceBurnTime == 0 && this.canSmelt()) { this.currentItemBurnTime = this.furnaceBurnTime = this.scaledBurnTime(); if (this.furnaceBurnTime > 0) { flag1 = true; if (this.furnaceItems[1] != null) { --this.furnaceItems[1].stackSize; if (this.furnaceItems[1].stackSize == 0) { this.furnaceItems[1] = this.furnaceItems[1].getItem().getContainerItem(furnaceItems[1]); } } } } if (this.isBurning() && this.canSmelt()) { ++this.furnaceCookTime; if (this.furnaceCookTime == this.getSpeedMultiplier()) { this.furnaceCookTime = 0; this.smeltItem(); flag1 = true; } } else { this.furnaceCookTime = 0; } if (flag != this.furnaceBurnTime > 0) { flag1 = true; BlockFurnaceCore.updateFurnaceBlockState(this.furnaceBurnTime > 0, worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } } //Furnace stuff @Override public int getSizeInventory() { return furnaceItems.length; } @Override public ItemStack getStackInSlot(int slot) { return furnaceItems[slot]; } @Override public ItemStack decrStackSize(int slot, int count) { if(this.furnaceItems[slot] != null) { ItemStack itemStack; itemStack = furnaceItems[slot].splitStack(count); if(furnaceItems[slot].stackSize <= 0) furnaceItems[slot] = null; return itemStack; } return null; } @Override public ItemStack getStackInSlotOnClosing(int slot) { if(furnaceItems[slot] != null) { ItemStack stack = furnaceItems[slot]; furnaceItems[slot] = null; return stack; } return null; } @Override public void setInventorySlotContents(int slot, ItemStack itemStack) { furnaceItems[slot] = itemStack; if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) itemStack.stackSize = getInventoryStackLimit(); } public void setGuiDisplayName(String par1Str) { this.field_94130_e = par1Str; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer entityPlayer) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : entityPlayer.getDistanceSq((double)xCoord + 0.5, (double)yCoord + 0.5, (double)zCoord + 0.5) <= 64.0; } //Re-writen for the I/O block @Override public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) { if(par1 == 2) return false; if(par1 == 1 && isItemFuel(par2ItemStack)) return true; if(par1 == 0) return true; else return false; } public static boolean isItemFuel(ItemStack par0ItemStack) { return getItemBurnTime(par0ItemStack) > 0; } 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).getToolMaterialName().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 GameRegistry.getFuelValue(p_145952_0_); } } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); tagCompound.getInteger("BlockMeta"); isValidMultiblock = tagCompound.getBoolean("isValidMultiblock"); NBTTagList itemsTag = tagCompound.getTagList("Items", 10); furnaceItems = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < itemsTag.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = itemsTag.getCompoundTagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.furnaceItems.length) { this.furnaceItems[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } this.furnaceBurnTime = tagCompound.getShort("BurnTime"); this.furnaceCookTime = tagCompound.getShort("CookTime"); this.currentItemBurnTime = this.scaledBurnTime(); this.redstoneBlocksInFurnace = tagCompound.getShort("RedstoneBlock"); this.ironBlocksInFurnace = tagCompound.getShort("IronStoneBlocks"); this.diamonds = tagCompound.getBoolean("Diamonds"); this.crafterEnabled = tagCompound.getBoolean("Enabled"); this.emeralds = tagCompound.getBoolean("Emeralds"); if (tagCompound.hasKey("CustomName")) { this.field_94130_e = tagCompound.getString("CustomName"); } } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setBoolean("isValidMultiblock", isValidMultiblock); tagCompound.setShort("BurnTime", (short)this.furnaceBurnTime); tagCompound.setShort("CookTime", (short)this.furnaceCookTime); tagCompound.setShort("RedstoneBlock", (short)this.redstoneBlocksInFurnace); tagCompound.setShort("IronStoneBlocks", (short)this.ironBlocksInFurnace); tagCompound.setBoolean("Diamonds", (boolean)this.diamonds); tagCompound.setBoolean("Enabled", (boolean)this.crafterEnabled); tagCompound.setBoolean("Emeralds",(boolean)this.emeralds); NBTTagList itemsList = new NBTTagList(); for (int i = 0; i < this.furnaceItems.length; ++i) { if (this.furnaceItems != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.furnaceItems.writeToNBT(nbttagcompound1); itemsList.appendTag(nbttagcompound1); } } tagCompound.setTag("Items", itemsList); if (this.hasCustomInventoryName()) { tagCompound.setString("CustomName", this.field_94130_e); } } @SideOnly(Side.CLIENT) public int getCookProgressScaled(int scaleVal) { int scale = this.getSpeedMultiplier(); return this.furnaceCookTime * scaleVal / scale; } @SideOnly(Side.CLIENT) public int getBurnTimeRemainingScaled(int scaleVal) { if(currentItemBurnTime == 0) { currentItemBurnTime = getSpeedMultiplier(); } return furnaceBurnTime * scaleVal / this.currentItemBurnTime; } public boolean isBurning() { return furnaceBurnTime > 0; } private boolean canSmelt() { if(furnaceItems[0] == null) return false; else { ItemStack itemStack = FurnaceRecipes.smelting().getSmeltingResult(furnaceItems[0]); if(itemStack == null) return false; if(furnaceItems[2] == null) return true; if(!furnaceItems[2].isItemEqual(itemStack)) return false; int resultingStackSize = furnaceItems[2].stackSize + itemStack.stackSize; return (resultingStackSize <= getInventoryStackLimit() && resultingStackSize <= itemStack.getMaxStackSize()); } } public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItems[0]); if (this.furnaceItems[2] == null) { this.furnaceItems[2] = itemstack.copy(); } else if (this.furnaceItems[2].isItemEqual(itemstack)) { furnaceItems[2].stackSize += itemstack.stackSize; } --this.furnaceItems[0].stackSize; if (this.furnaceItems[0].stackSize <= 0) { this.furnaceItems[0] = null; } } } //Used in cook progress public int getSpeedMultiplier() { int red = countRedstone(); return (cookSpeed - (red * redstoneMultiplier)); } //Counts redstone blocks in structure public int countRedstone() { int output = 0; int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); Block blockId = worldObj.getBlock(x, y, z); if(horiz == 0 && vert == 0) { if(depth == 0) // Looking at self, move on! continue; if(depth == 1) // Center must be air! { continue; } } if(blockId == BlockManager.furnaceDummyRedstone || blockId == Blocks.redstone_block) { output++; } } } } return output; } //Counts Iron Blocks in structure public int countIron() { int output = 0; int dir = (worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)); int depthMultiplier = ((dir == 2 || dir == 4) ? 1 : -1); boolean forwardZ = ((dir == 2) || (dir == 3)); /* * FORWARD BACKWARD * North: -z +z * South: +z -z * East: +x -x * West: -x +x * * Should move BACKWARD for depth (facing = direction of block face, not direction of player looking at face) */ for(int horiz = -1; horiz <= 1; horiz++) // Horizontal (X or Z) { for(int vert = -1; vert <= 1; vert++) // Vertical (Y) { for(int depth = 0; depth <= 2; depth++) // Depth (Z or X) { int x = xCoord + (forwardZ ? horiz : (depth * depthMultiplier)); int y = yCoord + vert; int z = zCoord + (forwardZ ? (depth * depthMultiplier) : horiz); Block blockId = worldObj.getBlock(x, y, z); if(horiz == 0 && vert == 0) { if(depth == 0) // Looking at self, move on! continue; if(depth == 1) // Center must be air! { continue; } } if(blockId == BlockManager.furnaceDummyGlowStone || blockId == Blocks.iron_block) { output++; } } } } return output; } //Reworked for I/O @Override public int[] getAccessibleSlotsFromSide(int par1) { switch(par1) { case 0 : return slots_bottom; case 1 : return slots_top; case 2 : return slots_output_only; default : return slots_sides; } //return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_sides); } @Override public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) { return this.isItemValidForSlot(par1, par2ItemStack); } @Override public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) { return par3 != 0 || par1 != 1 || par2ItemStack.getItem() == Items.bucket; } //Algorithm Behind the performance of the furnace /*public int scaledBurnTime() { int output = TileEntityFurnace.getItemBurnTime(furnaceItems[1]); output = (output + ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / * this.ironBlocksInFurnace)) - ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / 10) * this.redstoneBlocksInFurnace); return output; } */ public double scaledBurnTimeTest(double input) { double output = input; for(int i = 0; i <= this.countIron(); i++) { output = (input / 4) + output; } for(int j = 0; j <= this.countRedstone(); j++) { if(output > 0) output = output - (input / 25); if(output <= 0) output = 10; } return output; } public double getEfficiency() { double current = this.scaledBurnTimeTest(16000); double output = 0; if(current >= 16000) output = (current / 16000) - 1; else output = -(16000 / current); return output; } public int scaledBurnTime() { if (redstoneBlocksInFurnace > 0 && ironBlocksInFurnace == 0) { return ((TileEntityFurnace.getItemBurnTime(furnaceItems[1])) - ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / 25) * (redstoneBlocksInFurnace - 1))); } if (redstoneBlocksInFurnace == 0 && ironBlocksInFurnace >0) { return (TileEntityFurnace.getItemBurnTime(furnaceItems[1]) + ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / 25) * ironBlocksInFurnace)); } if (redstoneBlocksInFurnace > 0 && ironBlocksInFurnace > 0) { return (((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) + ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / 25) * ironBlocksInFurnace)) - ((TileEntityFurnace.getItemBurnTime(furnaceItems[1]) / 25) * redstoneBlocksInFurnace))); } else return TileEntityFurnace.getItemBurnTime(furnaceItems[1]); } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } public boolean hasCustomInventoryName() { return this.field_94130_e != null && this.field_94130_e.length() > 0; } @Override public void openInventory() { // TODO Auto-generated method stub } @Override public void closeInventory() { // TODO Auto-generated method stub } public void func_145951_a(String p_145951_1_) { this.field_94130_e = p_145951_1_; } } Block package com.pauljoda.modularfurnace.blocks; import java.util.Random; import com.pauljoda.modularfurnace.ModularFurnace; import com.pauljoda.modularfurnace.tileentity.TileEntityFurnaceCore; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.pauljoda.modularfurnace.client.ClientProxy; import com.pauljoda.modularfurnace.lib.Reference; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockFurnaceCore extends BlockContainer { private final boolean isActive; private static boolean keepFurnaceInventory; private final Random furnaceRand = new Random(); @SideOnly(Side.CLIENT) private IIcon furnaceIconTop; @SideOnly(Side.CLIENT) private IIcon furnaceIconFront; public BlockFurnaceCore(boolean par2) { super(Material.rock); this.isActive = par2; setCreativeTab(ModularFurnace.tabModularFurnace); } @Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(this); } @Override public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.func_149930_e(par1World, par2, par3, par4); } private void func_149930_e(World p_149930_1_, int p_149930_2_, int p_149930_3_, int p_149930_4_) { if (!p_149930_1_.isRemote) { Block block = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ - 1); Block block1 = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ + 1); Block block2 = p_149930_1_.getBlock(p_149930_2_ - 1, p_149930_3_, p_149930_4_); Block block3 = p_149930_1_.getBlock(p_149930_2_ + 1, p_149930_3_, p_149930_4_); byte b0 = 3; if (block.func_149730_j() && !block1.func_149730_j()) { b0 = 3; } if (block1.func_149730_j() && !block.func_149730_j()) { b0 = 2; } if (block2.func_149730_j() && !block3.func_149730_j()) { b0 = 5; } if (block3.func_149730_j() && !block2.func_149730_j()) { b0 = 4; } p_149930_1_.setBlockMetadataWithNotify(p_149930_2_, p_149930_3_, p_149930_4_, b0, 2); } } @Override public IIcon getIcon(int par1, int par2) { if(par1 == par2) return this.furnaceIconFront; return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront)); } @SideOnly(Side.CLIENT) /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ public void registerIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("furnace_side"); this.furnaceIconFront = par1IconRegister.registerIcon(this.isActive ? "furnace_front_on" : "furnace_front_off"); this.furnaceIconTop = par1IconRegister.registerIcon("furnace_top"); } @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } if (par6ItemStack.hasDisplayName()) { ((TileEntityFurnaceCore)par1World.getTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } } public static void updateFurnaceBlockState(boolean active, World world, int x, int y, int z) { int l = world.getBlockMetadata(x, y, z); TileEntity tileentity = world.getTileEntity(x, y, z); keepFurnaceInventory = true; if (active) { world.setBlock(x, y, z, BlockManager.furnaceCoreActive); } else { world.setBlock(x, y, z, BlockManager.furnaceCore); } keepFurnaceInventory = false; world.setBlockMetadataWithNotify(x, y, z, l, 2); if (tileentity != null) { tileentity.validate(); world.setTileEntity(x, y, z, tileentity); } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { TileEntityFurnaceCore tileEntity = (TileEntityFurnaceCore)world.getTileEntity(x, y, z); if(player.isSneaking()) { return false; } if(tileEntity != null) { // Determine if the Multiblock is currently known to be valid if(!tileEntity.getIsValid()) { if(tileEntity.checkIfProperlyFormed()) { tileEntity.convertDummies(); } } // Check if the multi-block structure has been formed. if(tileEntity.getIsValid() && tileEntity.checkIfProperlyFormed()) { player.openGui(ModularFurnace.instance, Reference.getGui(world, x, y, z), world, x, y, z); } } return true; } @Override public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (this.isActive) { int l = par1World.getBlockMetadata(par2, par3, par4); float f = (float)par2 + 0.5F; float f1 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; float f2 = (float)par4 + 0.5F; float f3 = 0.52F; float f4 = par5Random.nextFloat() * 0.6F - 0.3F; if (l == 4) { par1World.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 5) { par1World.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); } else if (l == 2) { par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); } else if (l == 3) { par1World.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); par1World.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); } } } @Override public TileEntity createNewTileEntity(World world, int i) { return new TileEntityFurnaceCore(); } @Override public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) { TileEntityFurnaceCore tileentityfurnace = (TileEntityFurnaceCore)par1World.getTileEntity(par2, par3, par4); if (!keepFurnaceInventory) { if (tileentityfurnace != null) { tileentityfurnace.invalidateMultiblock(); for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1) { ItemStack itemstack = tileentityfurnace.getStackInSlot(j1); if (itemstack != null) { float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F; float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; while (itemstack.stackSize > 0) { int k1 = this.furnaceRand.nextInt(21) + 10; if (k1 > itemstack.stackSize) { k1 = itemstack.stackSize; } itemstack.stackSize -= k1; EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage())); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } float f3 = 0.05F; entityitem.motionX = (double)((float)this.furnaceRand.nextGaussian() * f3); entityitem.motionY = (double)((float)this.furnaceRand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)this.furnaceRand.nextGaussian() * f3); par1World.spawnEntityInWorld(entityitem); } } } par1World.func_147453_f(par2, par3, par4, par5); } } super.breakBlock(par1World, par2, par3, par4, par5, par6); } @SideOnly(Side.CLIENT) @Override public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) { return Item.getItemFromBlock(this); } @Override public boolean renderAsNormalBlock() { return false; } @Override public boolean isOpaqueCube() { return false; } @Override public int getRenderType() { return ClientProxy.dummyRenderType; } @Override public boolean canRenderInPass(int pass) { //Set the static var in the client proxy ClientProxy.renderPass = pass; //the block can render in both passes, so return true always return true; } @Override public int getRenderBlockPass() { return 1; } } Any help would be great. I just can't get anything to fix it. Am I registering it wrong? I can make it turn to normal stone but not my blocks Quote
pauljoda Posted February 10, 2014 Author Posted February 10, 2014 Does anyone know if there is some special way to register using the block registry? Just trying everything at this point. Still no luck Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.