From 0ef6a00aa79f022e5bd56b3f77e6861bbecf6d94 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 13 Aug 2015 21:12:11 +0100 Subject: Added a new structure, a new curse, achievements, challenges, curses entry in the guide; reworked liquids to be tile entities, cleaned the structures code, potion code and... you know what? I improved and changed so much stuff that I literally forgot what I did... --- .../block/BlockJewelrsCraftingTable.java | 350 ++++++----------- .../darkknight/jewelrycraft/block/BlockList.java | 150 ++++---- .../jewelrycraft/block/BlockMoltenMetal.java | 411 ++++++++------------ .../jewelrycraft/block/BlockSmelter.java | 428 ++++++++++----------- .../block/render/BlockCrystalRenderer.java | 294 +++++++------- 5 files changed, 686 insertions(+), 947 deletions(-) (limited to 'src/main/java/darkknight/jewelrycraft/block') diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index a5d058b..7a6bf38 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -1,231 +1,119 @@ -package darkknight.jewelrycraft.block; - -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.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; - -public class BlockJewelrsCraftingTable extends BlockContainer -{ - Random rand = new Random(); - - /** - * @param par2Material - */ - protected BlockJewelrsCraftingTable(Material par2Material) - { - super(par2Material); - setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityJewelrsCraftingTable(); - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param entityPlayer - * @param par6 - * @param par7 - * @param par8 - * @param par9 - * @return - */ - @Override - public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) - { - TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && !world.isRemote){ - if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.hasenditem"))); - if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)){ - te.jewelry = item.copy(); - te.hasJewelry = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - if (!te.hasEndItem && !te.hasGem && item != null && JewelrycraftUtil.isGem(item)){ - te.gem = item.copy(); - te.gem.stackSize = 1; - te.hasGem = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting){ - te.carving = ConfigHandler.GEM_PLACEMENT_TIME; - te.angle = 0; - te.crafting = true; - te.isDirty = true; - } - } - return true; - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param stack - */ - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.21000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param par5 - * @param par6 - */ - @Override - public void breakBlock(World world, int i, int j, int k, Block par5, int par6) - { - TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k); - if (te != null){ - if (te.hasJewelry) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy()); - if (te.hasGem) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy()); - if (te.hasEndItem) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy()); - world.removeTileEntity(i, j, k); - } - super.breakBlock(world, i, j, k, par5, par6); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param entityLiving - * @param par6ItemStack - */ - @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) - { - int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - world.setBlockMetadataWithNotify(i, j, k, rotation, 2); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param player - */ - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - { - TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable)world.getTileEntity(i, j, k); - if (te != null && !world.isRemote) if (player.isSneaking()){ - if (te.hasJewelry){ - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy()); - te.jewelry = new ItemStack(Item.getItemById(0), 0, 0); - te.hasJewelry = false; - te.carving = -1; - te.crafting = false; - te.angle = 0F; - te.isDirty = true; - } - if (te.hasGem){ - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy()); - te.gem = new ItemStack(Item.getItemById(0), 0, 0); - te.hasGem = false; - te.carving = -1; - te.crafting = false; - te.angle = 0F; - te.isDirty = true; - } - }else if (te.hasEndItem){ - dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy()); - te.endItem = new ItemStack(Item.getItemById(0), 0, 0); - te.hasEndItem = false; - te.isDirty = true; - }else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.GEM_PLACEMENT_TIME - te.carving) * 100 / ConfigHandler.GEM_PLACEMENT_TIME + "%)")); - else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missinggem"))); - else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missingjewelry"))); - } - - /** - * @param iblockaccess - * @param i - * @param j - * @param k - * @param l - * @return - */ - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) - { - return false; - } - - /** - * @return - */ - @Override - public boolean isOpaqueCube() - { - return false; - } - - /** - * @return - */ - @Override - public int getRenderType() - { - return -1; - } - - /** - * @param icon - */ - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon(Variables.MODID + ":jewelrsCraftingTable"); - } -} +package darkknight.jewelrycraft.block; + +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.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; + +public class BlockJewelrsCraftingTable extends BlockContainer { + Random rand = new Random(); + + protected BlockJewelrsCraftingTable(Material par2Material) { + super(par2Material); + setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityJewelrsCraftingTable(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) { + if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.hasenditem"))); + if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)) { + te.setJewelryItemStack(item); + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + } + if (!te.hasEndItem && !te.hasGem && item != null && JewelrycraftUtil.isGem(item)) { + te.setGemItemStack(item); + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + } + if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting) te.setCrafting(); + } + return true; + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.21000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + @Override + public void breakBlock(World world, int i, int j, int k, Block par5, int par6) { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + if (te != null) { + if (te.hasJewelry) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.jewelry.copy()); + if (te.hasGem) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.gem.copy()); + if (te.hasEndItem) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.endItem.copy()); + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, par5, par6); + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + if (te != null && !world.isRemote) if (player.isSneaking()) { + if (te.hasJewelry) te.removeJewelry(); + if (te.hasGem) te.removeGem(); + } + else if (te.hasEndItem) te.removeResult(); + else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.GEM_PLACEMENT_TIME - te.carving) * 100 / ConfigHandler.GEM_PLACEMENT_TIME + "%)")); + else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missinggem"))); + else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missingjewelry"))); + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon(Variables.MODID + ":jewelrsCraftingTable"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockList.java b/src/main/java/darkknight/jewelrycraft/block/BlockList.java index 990a77f..032797c 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockList.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockList.java @@ -1,74 +1,76 @@ -package darkknight.jewelrycraft.block; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; -import darkknight.jewelrycraft.tileentity.TileEntityCrystal; -import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; -import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; -import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; -import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; -import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; -import darkknight.jewelrycraft.util.Variables; - -public class BlockList -{ - public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, handPedestal, shadowHand, midasTouchBlock, crystal; - public static BlockMoltenMetal moltenMetal; - public static Fluid moltenMetalFluid; - private static boolean isInitialized = false; - - public static void preInit(FMLPreInitializationEvent e) - { - shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockTextureName(Variables.MODID + ":oreShadow").setBlockName(Variables.MODID + ".oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - smelter = new BlockSmelter().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); - molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".molder").setCreativeTab(JewelrycraftMod.jewelrycraft); - displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".displayer").setCreativeTab(JewelrycraftMod.jewelrycraft); - jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName(Variables.MODID + ":blockShadow").setBlockName(Variables.MODID + ".blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft); - handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable(); - midasTouchBlock = new BlockMidasTouch(Material.iron).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".midasTouchBlock"); - moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000); - if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten"); - moltenMetal = new BlockMoltenMetal(moltenMetalFluid, Material.lava); - crystal = new BlockCrystal().setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeGlass).setBlockTextureName(Variables.MODID + ":blockCrystal").setBlockName(Variables.MODID + ".blockCrystal").setCreativeTab(JewelrycraftMod.jewelrycraft); - - GameRegistry.registerBlock(shadowOre, "shadowOre"); - GameRegistry.registerBlock(shadowBlock, "shadowBlock"); - GameRegistry.registerBlock(smelter, "Smelter"); - GameRegistry.registerBlock(molder, "Molder"); - GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable"); - GameRegistry.registerBlock(displayer, "Displayer"); - GameRegistry.registerBlock(shadowEye, "Shadow Eye"); - GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal"); - GameRegistry.registerBlock(shadowHand, "Shadow Hand"); - GameRegistry.registerBlock(midasTouchBlock, "Midas Touch Block"); - GameRegistry.registerBlock(moltenMetal, "moltenMetalLiquid"); - GameRegistry.registerBlock(crystal, BlockItemCrystal.class, "crystalBlock"); - - GameRegistry.registerTileEntity(TileEntitySmelter.class, Variables.MODID + ":smelter"); - GameRegistry.registerTileEntity(TileEntityMolder.class, Variables.MODID + ":molder"); - GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, Variables.MODID + ":table"); - GameRegistry.registerTileEntity(TileEntityDisplayer.class, Variables.MODID + ":displayer"); - GameRegistry.registerTileEntity(TileEntityBlockShadow.class, Variables.MODID + ":blockShadow"); - GameRegistry.registerTileEntity(TileEntityShadowEye.class, Variables.MODID + ":shadowEye"); - GameRegistry.registerTileEntity(TileEntityHandPedestal.class, Variables.MODID + ":handPedestal"); - GameRegistry.registerTileEntity(TileEntityShadowHand.class, Variables.MODID + ":shadowHand"); - GameRegistry.registerTileEntity(TileEntityMidasTouch.class, Variables.MODID + ":midsaTouch"); - GameRegistry.registerTileEntity(TileEntityCrystal.class, Variables.MODID + ":crystalBlock"); - - OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); - } -} +package darkknight.jewelrycraft.block; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; +import darkknight.jewelrycraft.tileentity.TileEntityCrystal; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal; +import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; +import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; + +public class BlockList +{ + public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, handPedestal, shadowHand, midasTouchBlock, crystal; + public static BlockMoltenMetal moltenMetal; + public static Fluid moltenMetalFluid; + private static boolean isInitialized = false; + + public static void preInit(FMLPreInitializationEvent e) + { + shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockTextureName(Variables.MODID + ":oreShadow").setBlockName(Variables.MODID + ".oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + smelter = new BlockSmelter().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); + molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".displayer").setCreativeTab(JewelrycraftMod.jewelrycraft); + jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName(Variables.MODID + ":blockShadow").setBlockName(Variables.MODID + ".blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft); + handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable(); + midasTouchBlock = new BlockMidasTouch(Material.iron).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".midasTouchBlock"); + moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000); + if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten"); + moltenMetal = new BlockMoltenMetal(moltenMetalFluid, Material.lava); + crystal = new BlockCrystal().setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeGlass).setBlockTextureName(Variables.MODID + ":blockCrystal").setBlockName(Variables.MODID + ".blockCrystal").setCreativeTab(JewelrycraftMod.jewelrycraft); + + GameRegistry.registerBlock(shadowOre, "shadowOre"); + GameRegistry.registerBlock(shadowBlock, "shadowBlock"); + GameRegistry.registerBlock(smelter, "Smelter"); + GameRegistry.registerBlock(molder, "Molder"); + GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable"); + GameRegistry.registerBlock(displayer, "Displayer"); + GameRegistry.registerBlock(shadowEye, "Shadow Eye"); + GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal"); + GameRegistry.registerBlock(shadowHand, "Shadow Hand"); + GameRegistry.registerBlock(midasTouchBlock, "Midas Touch Block"); + GameRegistry.registerBlock(moltenMetal, "moltenMetalLiquid"); + GameRegistry.registerBlock(crystal, BlockItemCrystal.class, "crystalBlock"); + + GameRegistry.registerTileEntity(TileEntitySmelter.class, Variables.MODID + ":smelter"); + GameRegistry.registerTileEntity(TileEntityMolder.class, Variables.MODID + ":molder"); + GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, Variables.MODID + ":table"); + GameRegistry.registerTileEntity(TileEntityDisplayer.class, Variables.MODID + ":displayer"); + GameRegistry.registerTileEntity(TileEntityBlockShadow.class, Variables.MODID + ":blockShadow"); + GameRegistry.registerTileEntity(TileEntityShadowEye.class, Variables.MODID + ":shadowEye"); + GameRegistry.registerTileEntity(TileEntityHandPedestal.class, Variables.MODID + ":handPedestal"); + GameRegistry.registerTileEntity(TileEntityShadowHand.class, Variables.MODID + ":shadowHand"); + GameRegistry.registerTileEntity(TileEntityMidasTouch.class, Variables.MODID + ":midsaTouch"); + GameRegistry.registerTileEntity(TileEntityCrystal.class, Variables.MODID + ":crystalBlock"); + GameRegistry.registerTileEntity(TileEntityMoltenMetal.class, Variables.MODID + ":moltenMetalTE"); + + OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java index 2525dd3..0995cc3 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -2,276 +2,167 @@ package darkknight.jewelrycraft.block; import java.io.IOException; import java.util.Random; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.network.PacketRequestLiquidData; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; -public class BlockMoltenMetal extends BlockFluidClassic -{ - @SideOnly (Side.CLIENT) - protected IIcon stillIcon; - @SideOnly (Side.CLIENT) - protected IIcon flowingIcon; - - /** - * @param fluid - * @param material - */ - public BlockMoltenMetal(Fluid fluid, Material material) - { - super(fluid, material); - setBlockName(Variables.MODID + ".moltenMetal"); - setQuantaPerBlock(5); - setRenderPass(1); - setLightLevel(15f); - } - - /** - * @param side - * @param meta - * @return - */ - @Override - public IIcon getIcon(int side, int meta) - { - return side == 0 || side == 1 ? stillIcon : flowingIcon; - } - - /** - * @param register - */ - @Override - @SideOnly (Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill"); - flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow"); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public boolean canDisplace(IBlockAccess world, int x, int y, int z) - { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.canDisplace(world, x, y, z); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public boolean displaceIfPossible(World world, int x, int y, int z) - { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; - return super.displaceIfPossible(world, x, y, z); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) - { - if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; - Block block = world.getBlock(x, y, z); - if (block == this) return false; - if (displacements.containsKey(block)) return displacements.get(block); - Material material = block.getMaterial(); - if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false; - int density = getDensity(world, x, y, z); - if (density == Integer.MAX_VALUE) return true; - if (this.density > density) return true; - else return false; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public int colorMultiplier(IBlockAccess world, int i, int j, int k) - { - try{ - return color(world, i, j, k, false, null); - } - catch(IOException e){ - e.printStackTrace(); - } - return 0; - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param rand - */ - @Override - public void updateTick(World world, int x, int y, int z, Random rand) - { - int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); - int expQuanta = -101; - // check adjacent block levels if non-source - if (quantaRemaining < quantaPerBlock){ - int y2 = y - densityDir; - if (world.getBlock(x, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x - 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x + 1, y2, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y2, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z - 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))) || world.getBlock(x, y2, z + 1) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y2, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) expQuanta = quantaPerBlock - 1; - else{ - int maxQuanta = -100; - if (JewelrycraftMod.saveData.getString(stringFromLocation(x - 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x + 1, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z - 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta); - if (JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z + 1, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)))) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta); - expQuanta = maxQuanta - 1; - } - // decay calculation - if (expQuanta != quantaRemaining){ - quantaRemaining = expQuanta; - if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air); - else{ - world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); - world.scheduleBlockUpdate(x, y, z, this, tickRate); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - } - } - // This is a "source" block, set meta to zero, and send a server only - // update - else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2); - String originData = JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)); - // Flow vertically if possible - if (canDisplace(world, x, y + densityDir, z)){ - JewelrycraftMod.saveData.setString(stringFromLocation(x, y + densityDir, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y + densityDir, z, 1, originData); - return; - } - // Flow outward if possible - int flowMeta = quantaPerBlock - quantaRemaining + 1; - if (flowMeta >= quantaPerBlock) return; - if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)){ - if (world.getBlock(x, y - densityDir, z) == this && JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId)).equals(JewelrycraftMod.saveData.getString(stringFromLocation(x, y - densityDir, z, world.provider.dimensionId)))) flowMeta = 1; - boolean flowTo[] = getOptimalFlowDirections(world, x, y, z); - if (flowTo[0]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x - 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x - 1, y, z).isAir(world, x - 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x - 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x - 1, y, z, flowMeta, originData); - } - if (flowTo[1]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x + 1, y, z, world.provider.dimensionId)) == null || world.getBlock(x + 1, y, z).isAir(world, x + 1, y, z)) JewelrycraftMod.saveData.setString(stringFromLocation(x + 1, y, z, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x + 1, y, z, flowMeta, originData); - } - if (flowTo[2]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z - 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z - 1).isAir(world, x, y, z - 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z - 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y, z - 1, flowMeta, originData); - } - if (flowTo[3]){ - if (JewelrycraftMod.saveData.getTag(stringFromLocation(x, y, z + 1, world.provider.dimensionId)) == null || world.getBlock(x, y, z + 1).isAir(world, x, y, z + 1)) JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z + 1, world.provider.dimensionId), JewelrycraftMod.saveData.getString(stringFromLocation(x, y, z, world.provider.dimensionId))); - flowIntoBlock(world, x, y, z + 1, flowMeta, originData); - } - } - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param meta - * @param originData - */ - public void flowIntoBlock(World world, int x, int y, int z, int meta, String originData) - { - if (meta < 0 || world.isRemote) return; - if (displaceIfPossible(world, x, y, z)){ - world.setBlock(x, y, z, this, meta, 3); - JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData); - String[] data = originData.split(":"); - try{ - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]))); - } - catch(Exception e){ - System.out.println("The liquids file is either corrupt, missing or the metal for the liquid simply doesn't exist!"); - } - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param forcecolor - * @param itemC - * @return - * @throws IOException - */ - @SideOnly (Side.CLIENT) - public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException - { - String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId); - if (ingotData == ""){ - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestLiquidData(Minecraft.getMinecraft().theWorld.provider.dimensionId, i, j, k)); - return 0xFFFFFF; - }else{ - String[] splitData = ingotData.split(":"); - if (splitData.length == 2){ - int color; - try{ - Integer.parseInt(splitData[0]); - Integer.parseInt(splitData[1]); - return JewelrycraftUtil.getColor(new ItemStack(Item.getItemById(Integer.parseInt(splitData[0])), 1, Integer.parseInt(splitData[1]))); - } - catch(Exception e){ - e.printStackTrace(); - } - } - } - return 16777215; - } - - /** - * @param x - * @param y - * @param z - * @param dimID - * @return - */ - public static String stringFromLocation(int x, int y, int z, int dimID) - { - return x + " " + y + " " + z + " " + dimID; - } +public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityProvider { + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockMoltenMetal(Fluid fluid, Material material) { + super(fluid, material); + setBlockName(Variables.MODID + ".moltenMetal"); + setQuantaPerBlock(5); + setRenderPass(1); + setLightLevel(15f); + } + + @Override + public IIcon getIcon(int side, int meta) { + return side == 0 || side == 1 ? stillIcon : flowingIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill"); + flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow"); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + + @Override + protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; + Block block = world.getBlock(x, y, z); + if (block == this) return false; + if (displacements.containsKey(block)) return displacements.get(block); + Material material = block.getMaterial(); + if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal) return false; + int density = getDensity(world, x, y, z); + if (density == Integer.MAX_VALUE) return true; + if (this.density > density) return true; + else return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int i, int j, int k) { + try { + return color(world, i, j, k, false, null); + } + catch (IOException e) { + e.printStackTrace(); + } + return 0; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + if (getTileEntity(world, x, y, z) == null || (getTileEntity(world, x, y, z).getMetal() == null)) world.setBlockToAir(x, y, z); + else { + int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); + int expQuanta = -101; + // check adjacent block levels if non-source + if (quantaRemaining < quantaPerBlock) { + int y2 = y - densityDir; + if ((world.getBlock(x, y2, z) == this && getTileEntity(world, x, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z, x, y, z)) || (world.getBlock(x - 1, y2, z) == this && getTileEntity(world, x - 1, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x - 1, y2, z, x, y, z)) || (world.getBlock(x + 1, y2, z) == this && getTileEntity(world, x + 1, y2, z) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x + 1, y2, z, x, y, z)) || (world.getBlock(x, y2, z - 1) == this && getTileEntity(world, x, y2, z - 1) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z - 1, x, y, z)) || (world.getBlock(x, y2, z + 1) == this && getTileEntity(world, x, y2, z + 1) != null && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z + 1, x, y, z))) expQuanta = quantaPerBlock - 1; + else { + int maxQuanta = -100; + if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x - 1, y, z) != null && areMetalsEqual(world, x, y, z, x - 1, y, z)) maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta); + if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x + 1, y, z) != null && areMetalsEqual(world, x, y, z, x + 1, y, z)) maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta); + if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z - 1) != null && areMetalsEqual(world, x, y, z, x, y, z - 1)) maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta); + if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z + 1) != null && areMetalsEqual(world, x, y, z, x, y, z + 1)) maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta); + expQuanta = maxQuanta - 1; + } + // decay calculation + if (expQuanta != quantaRemaining) { + quantaRemaining = expQuanta; + if (expQuanta <= 0) world.setBlock(x, y, z, Blocks.air); + else { + world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); + world.scheduleBlockUpdate(x, y, z, this, tickRate); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } + } + } + // This is a "source" block, set meta to zero, and send a server only update + else if (quantaRemaining >= quantaPerBlock) world.setBlockMetadataWithNotify(x, y, z, 0, 2); + // Flow vertically if possible + if (canDisplace(world, x, y + densityDir, z)) { + if (getTileEntity(world, x, y + densityDir, z) != null && getTileEntity(world, x, y, z) != null) this.getTileEntity(world, x, y + densityDir, z).setMetal(getTileEntity(world, x, y, z).getMetal()); + flowIntoBlock(world, x, y + densityDir, z, 1, getTileEntity(world, x, y, z).getMetal()); + return; + } + // Flow outward if possible + int flowMeta = quantaPerBlock - quantaRemaining + 1; + if (flowMeta >= quantaPerBlock) return; + if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) { + if (world.getBlock(x, y - densityDir, z) == this && getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y - densityDir, z) != null && areMetalsEqual(world, x, y, z, x, y - densityDir, z)) flowMeta = 1; + boolean flowTo[] = getOptimalFlowDirections(world, x, y, z); + if (flowTo[0]) flowIntoBlock(world, x - 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal()); + if (flowTo[1]) flowIntoBlock(world, x + 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal()); + if (flowTo[2]) flowIntoBlock(world, x, y, z - 1, flowMeta, getTileEntity(world, x, y, z).getMetal()); + if (flowTo[3]) flowIntoBlock(world, x, y, z + 1, flowMeta, getTileEntity(world, x, y, z).getMetal()); + } + } + } + + public void flowIntoBlock(World world, int x, int y, int z, int meta, ItemStack metal) { + if (meta < 0 || world.isRemote) return; + if (displaceIfPossible(world, x, y, z)) { + world.setBlock(x, y, z, this, meta, 3); + if (getTileEntity(world, x, y, z) != null) getTileEntity(world, x, y, z).setMetal(metal); + } + } + + public static TileEntityMoltenMetal getTileEntity(World world, int x, int y, int z) { + TileEntity moltenLiquid = world.getTileEntity(x, y, z); + if (moltenLiquid != null && moltenLiquid instanceof TileEntityMoltenMetal) return (TileEntityMoltenMetal) moltenLiquid; + return null; + } + + public static boolean areMetalsEqual(World world, int x1, int y1, int z1, int x2, int y2, int z2) { + return ItemStack.areItemStacksEqual(getTileEntity(world, x1, y1, z1).getMetal(), getTileEntity(world, x2, y2, z2).getMetal()); + } + + @SideOnly(Side.CLIENT) + public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException { + TileEntity te = world.getTileEntity(i, j, k); + if (te instanceof TileEntityMoltenMetal && ((TileEntityMoltenMetal) te).getMetal() != null) return JewelrycraftUtil.getColor(((TileEntityMoltenMetal) te).getMetal().copy()); + return 16777215; + } + + @Override + public TileEntity createNewTileEntity(World world, int value) { + return new TileEntityMoltenMetal(); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java index 1e68e34..cd24deb 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -1,7 +1,15 @@ package darkknight.jewelrycraft.block; import java.util.Random; - +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntityMoltenMetal; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -13,246 +21,196 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; -public class BlockSmelter extends BlockContainer -{ - Random rand = new Random(); - - public BlockSmelter() - { - super(Material.rock); - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntitySmelter(); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * Spawns an item in the world at the specified location - * - * @param world - * @param x - * @param y - * @param z - * @param stack - */ - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - entityitem.delayBeforeCanPickup = 0; - world.spawnEntityInWorld(entityitem); - } - - @Override - public void breakBlock(World world, int i, int j, int k, Block par5, int par6) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - if (te != null){ - if (te.hasMetal) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); - if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0){ - ItemStack metal = te.moltenMetal; - ItemStack item = te.moltenMetal; - if (Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) metal.setItemDamage(15 - metal.getItemDamage()); - JewelryNBT.addMetal(item, metal); - JewelrycraftMod.saveData.setString(i + " " + j + " " + k + " " + world.provider.dimensionId, Item.getIdFromItem(metal.getItem()) + ":" + metal.getItemDamage()); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, i, j, k, Item.getIdFromItem(metal.getItem()), metal.getItemDamage())); - world.setBlock(i, j, k, BlockList.moltenMetal, 0, 3); - int quant = (int)(te.quantity * 10); - if (quant == 1) world.setBlockMetadataWithNotify(i, j, k, 4, 3); - if (quant == 2) world.setBlockMetadataWithNotify(i, j, k, 4, 3); - if (quant == 3) world.setBlockMetadataWithNotify(i, j, k, 3, 3); - if (quant == 4) world.setBlockMetadataWithNotify(i, j, k, 3, 3); - if (quant == 5) world.setBlockMetadataWithNotify(i, j, k, 2, 3); - if (quant == 6) world.setBlockMetadataWithNotify(i, j, k, 2, 3); - if (quant == 7) world.setBlockMetadataWithNotify(i, j, k, 1, 3); - if (quant == 8) world.setBlockMetadataWithNotify(i, j, k, 1, 3); - if (quant == 9) world.setBlockMetadataWithNotify(i, j, k, 0, 3); - } - world.removeTileEntity(i, j, k); - } - super.breakBlock(world, i, j, k, par5, par6); - } - - @Override - public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket){ - te.quantity = 0f; - te.hasMoltenMetal = false; - ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); - ItemStack ingot = te.moltenMetal.copy(); - if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); - JewelryNBT.addMetal(metalBucket, ingot); - --item.stackSize; - entityPlayer.inventory.addItemStackToInventory(metalBucket); - te.isDirty = true; - return true; - } - if (te != null && !world.isRemote){ - if (te.hasMetal && entityPlayer.isSneaking()){ - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); - te.hasMetal = false; - te.melting = -1; - te.isDirty = true; - } - if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)){ - int index = -1; - for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) - if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; - if(entityPlayer.capabilities.isCreativeMode) index = 1; - boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null); - boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false; - isOre = JewelrycraftUtil.isOre(item); - if (te.metal != null && te.metal.getItem() != null) { - if(JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); - else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage(); - } - if (te.moltenMetal != null && te.moltenMetal.getItem() != null){ - if(JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage(); - else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage(); - if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage(); - } - overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize*0.1f + te.quantity < 0.9f; - boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true; - if (te.quantity < 0.9f && !te.pouring && canPlace && isValid){ - boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal; - boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; - if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check){ - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName()))); - te.metal = item.copy(); - // if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage()); - te.metal.stackSize = 1; - te.hasMetal = true; - te.melting = ConfigHandler.INGOT_MELTING_TIME; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - }else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow){ - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); - te.metal.stackSize++; - te.hasMetal = true; - te.melting += ConfigHandler.INGOT_MELTING_TIME; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - te.isDirty = true; - }else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch"))); - else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot"))); - else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full"))); - else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt"))); - }else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal){ - te.hasMoltenMetal = true; - ItemStack ingot = JewelryNBT.ingot(item); - if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); - te.moltenMetal = ingot; - te.quantity = .9f; - te.isDirty = true; - if (!entityPlayer.capabilities.isCreativeMode){ - --item.stackSize; - dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); - } - } - else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot","")))); - world.setTileEntity(i, j, k, te); - } - return true; - } - - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - { - TileEntitySmelter te = (TileEntitySmelter)world.getTileEntity(i, j, k); - TileEntityMolder me = null; - if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k - 1); - else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i + 1, j, k); - else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i, j, k + 1); - else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder)world.getTileEntity(i - 1, j, k); - if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase){ - te.pouring = true; - te.isDirty = true; - }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)")); - else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing"))); - else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold"))); - else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal"))); - else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem"))); - else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty"))); - } - - /** - * Determines if a molder is placed in front of this - * - * @param world - * @param i - * @param j - * @param k - * @return true if a molder is attached, false otherwise - */ - public boolean isConnectedToMolder(World world, int i, int j, int k) - { - int blockMeta = world.getBlockMetadata(i, j, k); - if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true; - else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true; - else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true; - else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true; - return false; - } - - @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) - { - int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - world.setBlockMetadataWithNotify(i, j, k, rotation, 2); - } +public class BlockSmelter extends BlockContainer { + Random rand = new Random(); + + public BlockSmelter() { + super(Material.rock); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntitySmelter(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + entityitem.delayBeforeCanPickup = 0; + world.spawnEntityInWorld(entityitem); + } + + @Override + public void breakBlock(World world, int i, int j, int k, Block block, int meta) { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + if (te != null) { + if (te.hasMetal) dropItem(world, i, j, k, te.metal.copy()); + if (te.hasMoltenMetal && te.moltenMetal != null && Item.getIdFromItem(te.moltenMetal.getItem()) > 0) { + int quant = (int) (te.quantity * 10); + ItemStack metalBucket = new ItemStack(ItemList.bucket); + JewelryNBT.addMetal(metalBucket, te.moltenMetal.copy()); + if (quant == 9){ + dropItem(world, i, j, k, new ItemStack(Blocks.cobblestone, 6)); + dropItem(world, i, j, k, new ItemStack(Items.lava_bucket)); + dropItem(world, i, j, k, metalBucket); + } + } + world.removeTileEntity(i, j, k); + } + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && te.hasMoltenMetal && te.quantity >= .9f && !te.pouring && item != null && item.getItem() == Items.bucket) { + te.quantity = 0f; + te.hasMoltenMetal = false; + ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); + ItemStack ingot = te.moltenMetal.copy(); + JewelryNBT.addMetal(metalBucket, ingot); + --item.stackSize; + entityPlayer.inventory.addItemStackToInventory(metalBucket); + te.isDirty = true; + return true; + } + if (te != null && !world.isRemote) { + if (te.hasMetal && entityPlayer.isSneaking()) { + dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); + te.hasMetal = false; + te.melting = -1; + te.isDirty = true; + } + if (item != null && item.getItem() != null && !(item.getItem() instanceof ItemMoltenMetalBucket)) { + int index = -1; + for (int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) + if (entityPlayer.getUniqueID().toString().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; + if (entityPlayer.capabilities.isCreativeMode) index = 1; + boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0 || JewelryNBT.ingot(item) != null); + boolean isOre = false, oreCoincidesWithMetal = false, itemCoincidesWithMetal = false, itemCoincidesWithMoltenMetal = false, overflow = false; + isOre = JewelrycraftUtil.isOre(item); + if (te.metal != null && te.metal.getItem() != null) { + if (JewelryNBT.ingot(item) == null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); + else itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage() && JewelryNBT.ingot(item).getItem().equals(JewelryNBT.ingot(te.metal).getItem()) && JewelryNBT.ingot(item).getItemDamage() == JewelryNBT.ingot(te.metal).getItemDamage(); + } + if (te.moltenMetal != null && te.moltenMetal.getItem() != null) { + if (JewelryNBT.ingot(item) == null) itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage(); + else itemCoincidesWithMoltenMetal = JewelryNBT.ingot(item).getItem().equals(te.moltenMetal.getItem()) && JewelryNBT.ingot(item).getItemDamage() == te.moltenMetal.getItemDamage(); + if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item).getItemDamage(); + } + overflow = isOre ? te.metal.stackSize * 0.2f + te.quantity < 0.8f : te.metal.stackSize * 0.1f + te.quantity < 0.9f; + boolean isValid = te.hasMoltenMetal ? isOre ? oreCoincidesWithMetal : itemCoincidesWithMoltenMetal : true; + if (te.quantity < 0.9f && !te.pouring && canPlace && isValid) { + boolean check = isOre ? oreCoincidesWithMetal && te.quantity < 0.8f : itemCoincidesWithMoltenMetal; + boolean check2 = isOre ? oreCoincidesWithMetal : itemCoincidesWithMetal; + if (!te.hasMetal && !te.hasMoltenMetal || !te.hasMetal && te.hasMoltenMetal && check) { + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.nowsmeltingingot", item.getDisplayName()))); + te.metal = item.copy(); + te.metal.stackSize = 1; + te.hasMetal = true; + te.melting = ConfigHandler.INGOT_MELTING_TIME; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + } + else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow) { + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); + te.metal.stackSize++; + te.hasMetal = true; + te.melting += ConfigHandler.INGOT_MELTING_TIME; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + } + te.isDirty = true; + } + else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.contentdoesnotmatch"))); + else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().toLowerCase().contains("ingot") && te.quantity < .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.itemrenamedtoingot"))); + else if (item != null && te.quantity >= .9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.full"))); + else entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.cannotsmelt"))); + } + else if (item != null && item.getItem() != null && item.getItem() instanceof ItemMoltenMetalBucket && !te.hasMoltenMetal && !te.hasMetal) { + te.hasMoltenMetal = true; + ItemStack ingot = JewelryNBT.ingot(item); + te.moltenMetal = ingot; + te.quantity = .9f; + te.isDirty = true; + if (!entityPlayer.capabilities.isCreativeMode) { + --item.stackSize; + dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); + } + } + else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.hasmolteningot", te.moltenMetal.getDisplayName().replace(" Ingot", "")))); + world.setTileEntity(i, j, k, te); + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + TileEntityMolder me = null; + if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i, j, k - 1); + else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i + 1, j, k); + else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i, j, k + 1); + else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) me = (TileEntityMolder) world.getTileEntity(i - 1, j, k); + if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase) { + te.pouring = true; + te.isDirty = true; + } + else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)")); + else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing"))); + else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold"))); + else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal"))); + else if (me.hasJewelBase && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.modlerhasitem"))); + else player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.empty"))); + } + + public boolean isConnectedToMolder(World world, int i, int j, int k) { + int blockMeta = world.getBlockMetadata(i, j, k); + if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) return true; + else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) return true; + else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) return true; + else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) return true; + return false; + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return -1; + } - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public int getRenderType() - { - return -1; - } - - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon(Variables.MODID + ":smelter"); - } + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon(Variables.MODID + ":smelter"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java index 0fc2f37..3582c5a 100644 --- a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java +++ b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java @@ -1,147 +1,147 @@ -/** - * - */ -package darkknight.jewelrycraft.block.render; - -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import darkknight.jewelrycraft.block.BlockCrystal; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.proxy.ClientProxy.BlockRenderIDs; -import darkknight.jewelrycraft.tileentity.TileEntityCrystal; - -/** - * @author Sorin - */ -@SideOnly (Side.CLIENT) -public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler -{ - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - Tessellator tessellator = Tessellator.instance; - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - tessellator.startDrawingQuads(); - if (metadata < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[metadata], 100); - GL11.glTranslatef(-0.5f, 0f, -0.5f); - this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer); - tessellator.draw(); - GL11.glTranslatef(0.5f, 0f, 0.5f); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) - { - int crystals = 5; - Random rnd = new Random(); - Tessellator tessellator = Tessellator.instance; - IIcon icon = ((BlockCrystal)block).getIcon(0, 0); - double umin = icon.getMinU(); - double vmin = icon.getMinV(); - double umax = icon.getMaxU(); - double vmax = icon.getMaxV(); - tessellator.addTranslation(x, y, z); - if (world != null && world.getTileEntity(x, y, z) != null && ConfigHandler.CRYSTAL_GLOW) tessellator.setBrightness(((TileEntityCrystal)world.getTileEntity(x, y, z)).shine); - else tessellator.setBrightness(230); - // 37435, 76464 - if (world != null) rnd.setSeed(2 * x * 3 * y * z * 5); - else rnd.setSeed(76464); - if (world != null && world.getBlockMetadata(x, y, z) < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[world.getBlockMetadata(x, y, z)], 100); - crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D, 0D, 0D, 0D, 0.0D, 0.0D); - for(int i = 0; i < crystals; i++){ - double rotation = Math.PI * 2.0f / (float)crystals * (float)i; - double xp1 = Math.sin(rotation) * 0.2f; - double zp1 = Math.cos(rotation) * 0.2f; - double height = 0.2f + rnd.nextFloat(); - double topHeight = 0.1f + rnd.nextFloat() / 2f; - crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, -xp1, 0D, zp1, xp1, zp1); - } - if (world != null){ - crystals = 4; - for(int i = 0; i < crystals; i++){ - double rotation = Math.PI * 2.0f / (float)crystals * (float)i; - double xp1 = Math.sin(rotation) * 0.2f; - double zp1 = Math.cos(rotation) * 0.2f; - double height = 0.2f + rnd.nextFloat(); - double topHeight = 0.1f + rnd.nextFloat() / 2f; - float xOff = (rnd.nextFloat() * 1.5f - 0.5f) * 0.2f; - float zOff = (rnd.nextFloat() * 1.5f - 0.5f) * 0.2f; - crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, xOff, 0D, zOff, xp1, zp1); - } - } - tessellator.addTranslation(-x, -y, -z); - return true; - } - - private void crystal(Tessellator tessellator, double umin, double vmin, double umax, double vmax, double height, double topHeight, double posX, double posY, double posZ, double rotX, double rotZ) - { - // Negative X - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin); - // Positive X - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); - // Negative Z - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin); - // Positive Z - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); - // Top -X - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin); - // Top +X - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin); - // Top +Z - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin); - // Top -Z - tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin); - // Bottom - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); - tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmax); - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmax); - tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); - } - - @Override - public boolean shouldRender3DInInventory(int modelId) - { - return true; - } - - @Override - public int getRenderId() - { - return BlockRenderIDs.CRYSTAL.id(); - } -} +/** + * + */ +package darkknight.jewelrycraft.block.render; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import org.lwjgl.opengl.GL11; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.block.BlockCrystal; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.proxy.ClientProxy.BlockRenderIDs; +import darkknight.jewelrycraft.tileentity.TileEntityCrystal; + +/** + * @author Sorin + */ +@SideOnly (Side.CLIENT) +public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler +{ + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) + { + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + tessellator.startDrawingQuads(); + if (metadata < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[metadata], 100); + GL11.glTranslatef(-0.5f, 0f, -0.5f); + this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer); + tessellator.draw(); + GL11.glTranslatef(0.5f, 0f, 0.5f); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + int crystals = 5; + Random rnd = new Random(); + Tessellator tessellator = Tessellator.instance; + IIcon icon = ((BlockCrystal)block).getIcon(0, 0); + double umin = icon.getMinU(); + double vmin = icon.getMinV(); + double umax = icon.getMaxU(); + double vmax = icon.getMaxV(); + tessellator.addTranslation(x, y, z); + if (world != null && world.getTileEntity(x, y, z) != null && ConfigHandler.CRYSTAL_GLOW) tessellator.setBrightness(((TileEntityCrystal)world.getTileEntity(x, y, z)).shine); + else tessellator.setBrightness(230); + // 37435, 76464 + if (world != null) rnd.setSeed(2 * x * 3 * y * z * 5); + else rnd.setSeed(76464); + if (world != null && world.getBlockMetadata(x, y, z) < 16) tessellator.setColorRGBA_I(((BlockCrystal)block).colors[world.getBlockMetadata(x, y, z)], 100); + crystal(tessellator, umin, vmin, umax, vmax, 0.8D, 0.2D, 0D, 0D, 0D, 0.0D, 0.0D); + for(int i = 0; i < crystals; i++){ + double rotation = Math.PI * 2.0f / (float)crystals * (float)i; + double xp1 = Math.sin(rotation) * (rnd.nextFloat()/2f); + double zp1 = Math.cos(rotation) * (rnd.nextFloat()/2f); + double height = 0.2f + rnd.nextFloat(); + double topHeight = 0.1f + rnd.nextFloat() / 2f; + crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, -xp1, 0D, zp1, xp1, zp1); + } + if (world != null){ + crystals = 4; + for(int i = 0; i < crystals; i++){ + double rotation = Math.PI * 2.0f / (float)crystals * (float)i; + double xp1 = Math.sin(rotation) * (rnd.nextFloat()/2f); + double zp1 = Math.cos(rotation) * (rnd.nextFloat()/2f); + double height = 0.2f + rnd.nextFloat(); + double topHeight = 0.1f + rnd.nextFloat() / 2f; + float xOff = (rnd.nextFloat() * 1.5f - 0.5f) * (rnd.nextFloat()/2f); + float zOff = (rnd.nextFloat() * 1.5f - 0.5f) * (rnd.nextFloat()/2f); + crystal(tessellator, umin, vmin, umax, vmax, height, topHeight, xOff, 0D, zOff, xp1, zp1); + } + } + tessellator.addTranslation(-x, -y, -z); + return true; + } + + private void crystal(Tessellator tessellator, double umin, double vmin, double umax, double vmax, double height, double topHeight, double posX, double posY, double posZ, double rotX, double rotZ) + { + // Negative X + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin); + // Positive X + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); + // Negative Z + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmin); + // Positive Z + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); + // Top -X + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin); + // Top +X + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin); + // Top +Z + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.6 + rotZ + posZ, umax, vmin); + // Top -Z + tessellator.addVertexWithUV(0.4 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.5 - rotX - rotX + posX, height + topHeight + posY, 0.5 + rotZ + rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.6 - rotX + posX, height + posY, 0.4 + rotZ + posZ, umax, vmin); + // Bottom + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umin, vmin); + tessellator.addVertexWithUV(0.4 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umin, vmax); + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.4 - rotZ + posZ, umax, vmax); + tessellator.addVertexWithUV(0.6 + rotX + posX, 0.0 + posY, 0.6 - rotZ + posZ, umax, vmin); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) + { + return true; + } + + @Override + public int getRenderId() + { + return BlockRenderIDs.CRYSTAL.id(); + } +} -- cgit v1.2.3