From 4f7ad220df0438b6f3382110577b53f29da46453 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 24 May 2018 15:50:07 -0400 Subject: Update of all changes --- .../jewelrycraft/block/BlockCrystal.java | 156 +++---- .../jewelrycraft/block/BlockDisplayer.java | 503 ++++++++++++--------- .../jewelrycraft/block/BlockHandPedestal.java | 307 ++++++------- .../jewelrycraft/block/BlockItemCrystal.java | 27 +- .../darkknight/jewelrycraft/block/BlockJCOre.java | 12 +- .../block/BlockJewelersCraftingTable.java | 168 +++++++ .../block/BlockJewelrsCraftingTable.java | 119 ----- .../darkknight/jewelrycraft/block/BlockList.java | 160 ++++--- .../jewelrycraft/block/BlockMidasTouch.java | 130 +++--- .../darkknight/jewelrycraft/block/BlockMolder.java | 255 ++++++----- .../jewelrycraft/block/BlockMoltenMetal.java | 198 ++++++-- .../darkknight/jewelrycraft/block/BlockShadow.java | 350 +++++++------- .../jewelrycraft/block/BlockShadowEye.java | 237 +++++----- .../jewelrycraft/block/BlockShadowHand.java | 243 +++++----- .../jewelrycraft/block/BlockSmelter.java | 323 ++++++++++--- .../block/render/BlockCrystalRenderer.java | 182 +++++--- 16 files changed, 1953 insertions(+), 1417 deletions(-) mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockHandPedestal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockItemCrystal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java create mode 100755 src/main/java/darkknight/jewelrycraft/block/BlockJewelersCraftingTable.java delete mode 100644 src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockList.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockMolder.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockShadow.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockShadowEye.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockShadowHand.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java mode change 100644 => 100755 src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java (limited to 'src/main/java/darkknight/jewelrycraft/block') diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java b/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java old mode 100644 new mode 100755 index e987c27..3ecbcd6 --- a/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockCrystal.java @@ -5,6 +5,7 @@ package darkknight.jewelrycraft.block; import java.util.List; import java.util.Random; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.config.ConfigHandler; @@ -24,82 +25,85 @@ import net.minecraft.world.World; * @author Sorin * */ -public class BlockCrystal extends Block implements ITileEntityProvider -{ - public static int[] colors = {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; - - protected BlockCrystal() - { - super(Material.glass); - setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); - setHarvestLevel("pickaxe", 0); - this.setTickRandomly(true); - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityCrystal(); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() - { - return 1; - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs tab, List list) - { - for(int i = 0; i < 16; ++i) list.add(new ItemStack(item, 1, i)); - } - - @Override - public int getRenderType() - { - return BlockRenderIDs.CRYSTAL.id(); - } - - @Override - @SideOnly (Side.CLIENT) - public int colorMultiplier(IBlockAccess world, int i, int j, int k) - { - return colors[world.getBlockMetadata(i, j, k)]; - } - - public int damageDropped(int meta) - { - return meta; - } +public class BlockCrystal extends Block implements ITileEntityProvider { + public static int[] colors = { 1973019, 11743532, 3887386, 5320730, + 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, + 4312372, 14602026, 6719955, 12801229, 15435844, 15790320 }; + + protected BlockCrystal() { + super(Material.glass); + setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); + setHarvestLevel("pickaxe", 0); + this.setTickRandomly(true); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityCrystal(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 16; ++i) + list.add(new ItemStack(item, 1, i)); + } + + @Override + public int getRenderType() { + return BlockRenderIDs.CRYSTAL.id(); + } + + @Override + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int i, int j, int k) { + return colors[world.getBlockMetadata(i, j, k)]; + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, + int meta) { + super.breakBlock(world, x, y, z, block, meta); + world.removeTileEntity(x, y, z); + } - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - super.breakBlock(world, x, y, z, block, meta); - world.removeTileEntity(x, y, z); - } + @Override + public boolean onBlockEventReceived(World world, int x, int y, int z, + int eventNo, int arg) { + super.onBlockEventReceived(world, x, y, z, eventNo, arg); + TileEntity tileentity = world.getTileEntity(x, y, z); + return tileentity != null + ? tileentity.receiveClientEvent(eventNo, arg) : false; + } - public boolean onBlockEventReceived(World world, int x, int y, int z, int eventNo, int arg) - { - super.onBlockEventReceived(world, x, y, z, eventNo, arg); - TileEntity tileentity = world.getTileEntity(x, y, z); - return tileentity != null ? tileentity.receiveClientEvent(eventNo, arg) : false; - } - - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random rand) - { - if(ConfigHandler.CRYSTAL_PARTICLES) world.spawnParticle("instantSpell", x + rand.nextFloat(), y + rand.nextFloat(), z + rand.nextFloat(), 0.0D, -1.0D, 0.0D); - } + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, + Random rand) { + if (ConfigHandler.CRYSTAL_PARTICLES) + world.spawnParticle("instantSpell", x + rand.nextFloat(), + y + rand.nextFloat(), z + rand.nextFloat(), 0.0D, + -1.0D, 0.0D); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java b/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java old mode 100644 new mode 100755 index ba8884b..eff1f6d --- a/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.block; import java.util.Random; + import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; @@ -16,229 +17,281 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockDisplayer extends BlockContainer -{ - Random rand = new Random(); - - /** - * @param par2Material - */ - protected BlockDisplayer(Material par2Material) - { - super(par2Material); - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityDisplayer(); - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @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 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) - { - TileEntityDisplayer te = (TileEntityDisplayer)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null){ - if (item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && !world.isRemote){ - if (!te.hasObject){ - te.object = item.copy(); - te.quantity += item.stackSize; - te.object.stackSize = 1; - te.hasObject = true; - if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); - te.isDirty = true; - }else if (te.object.getItem() == item.getItem() && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.object.getItemDamage() == item.getItemDamage()) if (te.object.hasTagCompound() && item.hasTagCompound() && te.object.getTagCompound().equals(item.getTagCompound())){ - te.quantity += item.stackSize; - if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); - te.isDirty = true; - }else if (!te.object.hasTagCompound() && !item.hasTagCompound()){ - te.quantity += item.stackSize; - if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, item.stackSize); - te.isDirty = true; - } - }else if (item == null || item == new ItemStack(Item.getItemById(0), 0, 0)) if (!entityPlayer.capabilities.isCreativeMode) for(int inv = 0; inv < entityPlayer.inventory.getSizeInventory(); inv++){ - item = entityPlayer.inventory.getStackInSlot(inv); - if (item != null && te.object.getItem() == item.getItem() && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.object.getItemDamage() == item.getItemDamage()) if (te.object.hasTagCompound() && item.hasTagCompound() && te.object.getTagCompound().equals(item.getTagCompound())){ - te.quantity += item.stackSize; - if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(inv, item.stackSize); - te.isDirty = true; - te.markDirty(); - }else if (!te.object.hasTagCompound() && !item.hasTagCompound()){ - te.quantity += item.stackSize; - if (!entityPlayer.capabilities.isCreativeMode) entityPlayer.inventory.decrStackSize(inv, item.stackSize); - te.isDirty = true; - } - } - else if (entityPlayer.capabilities.isCreativeMode && te.hasObject && te.object.getItem() != null){ - te.quantity += 64; - te.isDirty = true; - } - te.isDirty = true; - } - return true; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param player - */ - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - { - TileEntityDisplayer te = (TileEntityDisplayer)world.getTileEntity(i, j, k); - if (te != null && !world.isRemote) if (te.hasObject && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && player.inventory.addItemStackToInventory(te.object)) if (!player.isSneaking()){ - if (te.quantity > te.object.getMaxStackSize()){ - te.object.stackSize = te.object.getMaxStackSize() - 1; - player.inventory.addItemStackToInventory(te.object); - te.object.stackSize = 1; - te.quantity -= te.object.getMaxStackSize(); - te.isDirty = true; - }else{ - te.object.stackSize = te.quantity - 1; - player.inventory.addItemStackToInventory(te.object); - te.hasObject = false; - te.object = new ItemStack(Item.getItemById(0), 0, 0); - te.quantity = 0; - te.isDirty = true; - } - te.isDirty = true; - }else{ - if (te.quantity >= 2){ - player.inventory.addItemStackToInventory(te.object); - te.object.stackSize = 1; - te.quantity--; - te.isDirty = true; - }else{ - player.inventory.addItemStackToInventory(te.object); - te.object.stackSize = 1; - te.hasObject = false; - te.object = new ItemStack(Item.getItemById(0), 0, 0); - te.quantity = 0; - te.isDirty = true; - } - te.isDirty = 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 + 1.5D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - * @param par6 - */ - @Override - public void breakBlock(World world, int i, int j, int k, Block block, int par6) - { - TileEntityDisplayer te = (TileEntityDisplayer)world.getTileEntity(i, j, k); - if (te != null && te.hasObject){ - te.object.stackSize = te.quantity; - dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.object); - world.removeTileEntity(i, j, k); - } - super.breakBlock(world, i, j, k, block, 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 icon - */ - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:emerald_block"); - } +public class BlockDisplayer extends BlockContainer { + Random rand = new Random(); + + /** + * @param par2Material + */ + protected BlockDisplayer(Material par2Material) { + super(par2Material); + } + + /** + * @param world + * @param var2 + * @return the tile entity + */ + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityDisplayer(); + } + + /** + * @return whether to render as a normal block + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * @param iblockaccess + * @param i + * @param j + * @param k + * @param l + * @return whether to render the specified side + */ + @Override + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, + int j, int k, int l) { + return false; + } + + /** + * @return whether to render as an opaque cube + */ + @Override + public boolean isOpaqueCube() { + return false; + } + + /** + * @return the render type + */ + @Override + public int getRenderType() { + return -1; + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param entityPlayer + * @param par6 + * @param par7 + * @param par8 + * @param par9 + * @return whether to activate the item on the block + */ + @Override + public boolean onBlockActivated(World world, int i, int j, int k, + EntityPlayer entityPlayer, int par6, float par7, float par8, + float par9) { + TileEntityDisplayer te = + (TileEntityDisplayer) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null) { + if (item != null + && item != new ItemStack(Item.getItemById(0), 0, 0) + && !world.isRemote) { + if (!te.hasObject) { + te.object = item.copy(); + te.quantity += item.stackSize; + te.object.stackSize = 1; + te.hasObject = true; + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize( + entityPlayer.inventory.currentItem, + item.stackSize); + te.isDirty = true; + } else if (te.object.getItem() == item.getItem() + && te.object != null + && te.object != new ItemStack(Item.getItemById(0), + 0, 0) + && te.object.getItemDamage() == item + .getItemDamage()) + if (te.object.hasTagCompound() && item.hasTagCompound() + && te.object.getTagCompound() + .equals(item.getTagCompound())) { + te.quantity += item.stackSize; + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize( + entityPlayer.inventory.currentItem, + item.stackSize); + te.isDirty = true; + } else if (!te.object.hasTagCompound() + && !item.hasTagCompound()) { + te.quantity += item.stackSize; + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize( + entityPlayer.inventory.currentItem, + item.stackSize); + te.isDirty = true; + } + } else if (item == null + || item == new ItemStack(Item.getItemById(0), 0, 0)) + if (!entityPlayer.capabilities.isCreativeMode) + for (int inv = 0; inv < entityPlayer.inventory + .getSizeInventory(); inv++) { + item = entityPlayer.inventory.getStackInSlot(inv); + if (item != null + && te.object.getItem() == item.getItem() + && te.object != null + && te.object != new ItemStack( + Item.getItemById(0), 0, 0) + && te.object.getItemDamage() == item + .getItemDamage()) + if (te.object.hasTagCompound() + && item.hasTagCompound() + && te.object.getTagCompound().equals( + item.getTagCompound())) { + te.quantity += item.stackSize; + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize( + inv, item.stackSize); + te.isDirty = true; + te.markDirty(); + } else if (!te.object.hasTagCompound() + && !item.hasTagCompound()) { + te.quantity += item.stackSize; + if (!entityPlayer.capabilities.isCreativeMode) + entityPlayer.inventory.decrStackSize( + inv, item.stackSize); + te.isDirty = true; + } + } + else if (entityPlayer.capabilities.isCreativeMode + && te.hasObject && te.object.getItem() != null) { + te.quantity += 64; + te.isDirty = true; + } + te.isDirty = true; + } + return true; + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param player + */ + @Override + public void onBlockClicked(World world, int i, int j, int k, + EntityPlayer player) { + TileEntityDisplayer te = + (TileEntityDisplayer) world.getTileEntity(i, j, k); + if (te != null && !world.isRemote) + if (te.hasObject && te.object != null + && te.object != new ItemStack(Item.getItemById(0), 0, + 0) + && player.inventory.addItemStackToInventory(te.object)) + if (!player.isSneaking()) { + if (te.quantity > te.object.getMaxStackSize()) { + te.object.stackSize = + te.object.getMaxStackSize() - 1; + player.inventory + .addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.quantity -= te.object.getMaxStackSize(); + te.isDirty = true; + } else { + te.object.stackSize = te.quantity - 1; + player.inventory + .addItemStackToInventory(te.object); + te.hasObject = false; + te.object = + new ItemStack(Item.getItemById(0), 0, 0); + te.quantity = 0; + te.isDirty = true; + } + te.isDirty = true; + } else { + if (te.quantity >= 2) { + player.inventory + .addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.quantity--; + te.isDirty = true; + } else { + player.inventory + .addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.hasObject = false; + te.object = + new ItemStack(Item.getItemById(0), 0, 0); + te.quantity = 0; + te.isDirty = true; + } + te.isDirty = 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 + 1.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + * @param par6 + */ + @Override + public void breakBlock(World world, int i, int j, int k, Block block, + int par6) { + TileEntityDisplayer te = + (TileEntityDisplayer) world.getTileEntity(i, j, k); + if (te != null && te.hasObject) { + te.object.stackSize = te.quantity; + dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, + te.object); + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, block, 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 icon + */ + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:emerald_block"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockHandPedestal.java b/src/main/java/darkknight/jewelrycraft/block/BlockHandPedestal.java old mode 100644 new mode 100755 index 4059101..e4b8efc --- a/src/main/java/darkknight/jewelrycraft/block/BlockHandPedestal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockHandPedestal.java @@ -14,156 +14,159 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockHandPedestal extends BlockContainer -{ - - /** - * @param material - */ - protected BlockHandPedestal(Material material) - { - super(material); - setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityHandPedestal(); - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @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 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) - { - TileEntityHandPedestal te = (TileEntityHandPedestal)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null){ - if (!world.isRemote && te.getHeldItemStack() == null && item != null){ - te.setHeldItemStack(item.copy()); - if (!entityPlayer.capabilities.isCreativeMode) item.stackSize--; - te.markDirty(); - }else if (entityPlayer.isSneaking()) if (entityPlayer.inventory.addItemStackToInventory(te.getHeldItemStack())){ - te.removeHeldItemStack(); - } - te.markDirty(); - } - 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.5, y + 1.5, z + 0.5, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - * @param par6 - */ - @Override - public void breakBlock(World world, int i, int j, int k, Block block, int par6) - { - TileEntityHandPedestal te = (TileEntityHandPedestal)world.getTileEntity(i, j, k); - if (te != null && te.getHeldItemStack() != null){ - dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.getHeldItemStack()); - world.removeTileEntity(i, j, k); - } - super.breakBlock(world, i, j, k, block, 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 * 8 / 360 + 0.5) & 7; - world.setBlockMetadataWithNotify(i, j, k, rotation, 2); - } - - /** - * @param icon - */ - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:stonebrick"); - } +public class BlockHandPedestal extends BlockContainer { + + /** + * @param material + */ + protected BlockHandPedestal(Material material) { + super(material); + setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); + } + + /** + * @param world + * @param var2 + * @return + */ + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityHandPedestal(); + } + + /** + * @return + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * @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 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) { + TileEntityHandPedestal te = + (TileEntityHandPedestal) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null) { + if (!world.isRemote && te.getHeldItemStack() == null + && item != null) { + te.setHeldItemStack(item.copy()); + if (!entityPlayer.capabilities.isCreativeMode) + item.stackSize--; + te.markDirty(); + } else if (entityPlayer.isSneaking()) + if (entityPlayer.inventory + .addItemStackToInventory(te.getHeldItemStack())) { + te.removeHeldItemStack(); + } + te.markDirty(); + } + 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.5, y + 1.5, z + 0.5, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + * @param par6 + */ + @Override + public void breakBlock(World world, int i, int j, int k, Block block, + int par6) { + TileEntityHandPedestal te = + (TileEntityHandPedestal) world.getTileEntity(i, j, k); + if (te != null && te.getHeldItemStack() != null) { + dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, + te.getHeldItemStack()); + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, block, 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 * 8 / 360 + 0.5) & 7; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + /** + * @param icon + */ + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:stonebrick"); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockItemCrystal.java b/src/main/java/darkknight/jewelrycraft/block/BlockItemCrystal.java old mode 100644 new mode 100755 index ca3490a..6a82701 --- a/src/main/java/darkknight/jewelrycraft/block/BlockItemCrystal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockItemCrystal.java @@ -6,30 +6,27 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class BlockItemCrystal extends ItemBlock -{ +public class BlockItemCrystal extends ItemBlock { public BlockItemCrystal(Block block) { super(block); setHasSubtypes(true); } - + @Override - public int getMetadata (int damageValue) - { + public int getMetadata(int damageValue) { return damageValue; } - + @Override - public String getUnlocalizedName(ItemStack itemstack) - { + public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + itemstack.getItemDamage(); } - - @Override - @SideOnly (Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) - { - return stack.getItemDamage() < 16 ? BlockCrystal.colors[stack.getItemDamage()] : 0; - } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) { + return stack.getItemDamage() < 16 + ? BlockCrystal.colors[stack.getItemDamage()] : 0; + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java b/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java old mode 100644 new mode 100755 index 5265a6a..41b61e5 --- a/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java @@ -2,11 +2,9 @@ package darkknight.jewelrycraft.block; import net.minecraft.block.BlockOre; -public class BlockJCOre extends BlockOre -{ - protected BlockJCOre() - { - super(); - setHarvestLevel("pickaxe", 3); - } +public class BlockJCOre extends BlockOre { + protected BlockJCOre() { + super(); + setHarvestLevel("pickaxe", 3); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelersCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelersCraftingTable.java new file mode 100755 index 0000000..e8a1431 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelersCraftingTable.java @@ -0,0 +1,168 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +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; +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.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; + +public class BlockJewelersCraftingTable extends BlockContainer { + Random rand = new Random(); + + protected BlockJewelersCraftingTable(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("minecraft:planks_spruce"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java deleted file mode 100644 index 71b1a23..0000000 --- a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ /dev/null @@ -1,119 +0,0 @@ -package darkknight.jewelrycraft.block; - -import java.util.Random; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; -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; -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.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; - -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("minecraft:planks_spruce"); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockList.java b/src/main/java/darkknight/jewelrycraft/block/BlockList.java old mode 100644 new mode 100755 index 7f59e7f..cd928b8 --- a/src/main/java/darkknight/jewelrycraft/block/BlockList.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockList.java @@ -22,55 +22,113 @@ 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; - - 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); - moltenMetalFluid.setBlock(moltenMetal); - 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)); - } +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; + + 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 BlockJewelersCraftingTable(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); + moltenMetalFluid.setBlock(moltenMetal); + 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/BlockMidasTouch.java b/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java old mode 100644 new mode 100755 index 337428d..19e0190 --- a/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.block; import java.util.Random; + import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -12,67 +13,70 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockMidasTouch extends BlockContainer -{ - protected BlockMidasTouch(Material mat) - { - super(mat); - setHarvestLevel("pickaxe", 2); - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityMidasTouch(); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @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; - } - - public int quantityDropped(Random rand) - { - return 0; - } - - public Item getItemDropped(int id, Random rand, int size) - { - return Items.gold_nugget; - } - - public void onBlockHarvested(World world, int i, int j, int k, int meta, EntityPlayer player) - { - } - - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (((TileEntityMidasTouch)tile).target != null) this.setBlockBounds(0.5f - ((TileEntityMidasTouch)tile).target.width / 2, 0F, 0.5f - ((TileEntityMidasTouch)tile).target.width / 2, 0.5f + ((TileEntityMidasTouch)tile).target.width / 2, ((TileEntityMidasTouch)tile).target.height, 0.5f + ((TileEntityMidasTouch)tile).target.width / 2); - } - - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:gold_block"); - } +public class BlockMidasTouch extends BlockContainer { + protected BlockMidasTouch(Material mat) { + super(mat); + setHarvestLevel("pickaxe", 2); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityMidasTouch(); + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @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 int quantityDropped(Random rand) { + return 0; + } + + @Override + public Item getItemDropped(int id, Random rand, int size) { + return Items.gold_nugget; + } + + @Override + public void onBlockHarvested(World world, int i, int j, int k, + int meta, EntityPlayer player) { + // Do nothing + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, + int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (((TileEntityMidasTouch) tile).target != null) + this.setBlockBounds( + 0.5f - ((TileEntityMidasTouch) tile).target.width / 2, + 0F, + 0.5f - ((TileEntityMidasTouch) tile).target.width / 2, + 0.5f + ((TileEntityMidasTouch) tile).target.width / 2, + ((TileEntityMidasTouch) tile).target.height, + 0.5f + ((TileEntityMidasTouch) tile).target.width / 2); + } + + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:gold_block"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java old mode 100644 new mode 100755 index 0c58784..7d7b34d --- a/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.block; import java.util.Random; + import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.tileentity.TileEntityMolder; @@ -21,116 +22,146 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockMolder extends BlockContainer -{ - Random rand = new Random(); - - protected BlockMolder(Material par2Material) - { - super(par2Material); - setBlockBounds(0.1F, 0F, 0.1F, 0.9F, 0.2F, 0.9F); - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityMolder(); - } - - @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) - { - TileEntityMolder te = (TileEntityMolder)world.getTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && !world.isRemote){ - if (item != null && !te.hasMold && item.getItem() == ItemList.molds){ - te.mold = item.copy(); - te.hasMold = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".molder.addedmold", te.mold.getDisplayName()))); - te.isDirty = true; - } - if (te.hasMold && entityPlayer.isSneaking() && !te.hasMoltenMetal){ - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.mold.copy()); - te.mold = new ItemStack(Item.getItemById(0), 0, 0); - te.hasMold = false; - te.isDirty = true; - }else if (te.hasMoltenMetal) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.hasmoltenmetal"))); - } - return true; - } - - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - @Override - public void breakBlock(World world, int i, int j, int k, Block par5, int par6) - { - TileEntityMolder te = (TileEntityMolder)world.getTileEntity(i, j, k); - if (te != null){ - if (te.hasJewelBase) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.jewelBase.copy()); - if (te.hasMold) dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.mold.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) - { - TileEntityMolder me = (TileEntityMolder)world.getTileEntity(i, j, k); - if (me != null && !world.isRemote){ - if (me.hasJewelBase){ - dropItem(me.getWorldObj(), me.xCoord, me.yCoord, me.zCoord, me.jewelBase.copy()); - me.jewelBase = new ItemStack(Item.getItemById(0), 0, 0); - me.hasJewelBase = false; - }else if (me.hasMoltenMetal && me.cooling >= 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.metaliscooling") + " (" + (ConfigHandler.INGOT_COOLING_TIME - me.cooling) * 100 / ConfigHandler.INGOT_COOLING_TIME + "%)")); - else if (me.mold.getItem() == ItemList.molds && !me.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.moldisempty"))); - else if (me.mold.getItem() != ItemList.molds) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.moldismissing"))); - me.isDirty = true; - } - } - - @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("minecraft:cobblestone"); - } +public class BlockMolder extends BlockContainer { + Random rand = new Random(); + + protected BlockMolder(Material par2Material) { + super(par2Material); + setBlockBounds(0.1F, 0F, 0.1F, 0.9F, 0.2F, 0.9F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityMolder(); + } + + @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) { + TileEntityMolder te = + (TileEntityMolder) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) { + if (item != null && !te.hasMold + && item.getItem() == ItemList.molds) { + te.mold = item.copy(); + te.hasMold = true; + if (!entityPlayer.capabilities.isCreativeMode) + --item.stackSize; + entityPlayer.addChatMessage(new ChatComponentText( + StatCollector.translateToLocalFormatted( + "chatmessage." + Variables.MODID + + ".molder.addedmold", + te.mold.getDisplayName()))); + te.isDirty = true; + } + if (te.hasMold && entityPlayer.isSneaking() + && !te.hasMoltenMetal) { + dropItem(world, te.xCoord, te.yCoord, te.zCoord, + te.mold.copy()); + te.mold = new ItemStack(Item.getItemById(0), 0, 0); + te.hasMold = false; + te.isDirty = true; + } else if (te.hasMoltenMetal) + entityPlayer.addChatMessage(new ChatComponentText( + StatCollector.translateToLocal( + "chatmessage." + Variables.MODID + + ".molder.hasmoltenmetal"))); + } + return true; + } + + public void dropItem(World world, double x, double y, double z, + ItemStack stack) { + EntityItem entityitem = + new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + @Override + public void breakBlock(World world, int i, int j, int k, Block par5, + int par6) { + TileEntityMolder te = + (TileEntityMolder) world.getTileEntity(i, j, k); + if (te != null) { + if (te.hasJewelBase) + dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, + te.jewelBase.copy()); + if (te.hasMold) + dropItem(world, te.xCoord, te.yCoord, te.zCoord, + te.mold.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) { + TileEntityMolder me = + (TileEntityMolder) world.getTileEntity(i, j, k); + if (me != null && !world.isRemote) { + if (me.hasJewelBase) { + dropItem(me.getWorldObj(), me.xCoord, me.yCoord, me.zCoord, + me.jewelBase.copy()); + me.jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + me.hasJewelBase = false; + } else if (me.hasMoltenMetal && me.cooling >= 0) + player.addChatMessage(new ChatComponentText(StatCollector + .translateToLocal("chatmessage." + Variables.MODID + + ".molder.metaliscooling") + + " (" + + (ConfigHandler.INGOT_COOLING_TIME - me.cooling) + * 100 / ConfigHandler.INGOT_COOLING_TIME + + "%)")); + else if (me.mold.getItem() == ItemList.molds + && !me.hasMoltenMetal) + player.addChatMessage(new ChatComponentText(StatCollector + .translateToLocal("chatmessage." + Variables.MODID + + ".molder.moldisempty"))); + else if (me.mold.getItem() != ItemList.molds) + player.addChatMessage(new ChatComponentText(StatCollector + .translateToLocal("chatmessage." + Variables.MODID + + ".molder.moldismissing"))); + me.isDirty = true; + } + } + + @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("minecraft:cobblestone"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java old mode 100644 new mode 100755 index 0995cc3..088a5e2 --- a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -2,6 +2,7 @@ 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; @@ -21,11 +22,12 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; -public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityProvider { +public class BlockMoltenMetal extends BlockFluidClassic + implements ITileEntityProvider { @SideOnly(Side.CLIENT) - protected IIcon stillIcon; + protected IIcon stillIcon; @SideOnly(Side.CLIENT) - protected IIcon flowingIcon; + protected IIcon flowingIcon; public BlockMoltenMetal(Fluid fluid, Material material) { super(fluid, material); @@ -43,34 +45,48 @@ public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityPr @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) { - stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill"); - flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow"); + 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; + 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; + 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; + 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); + 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; + if (material.blocksMovement() || material == Material.water + || material == Material.lava + || material == Material.portal) + return false; + int densty = getDensity(world, x, y, z); + if (densty == Integer.MAX_VALUE) + return true; + if (this.density > densty) { + return true; + } + return false; } @Override @@ -78,8 +94,7 @@ public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityPr public int colorMultiplier(IBlockAccess world, int i, int j, int k) { try { return color(world, i, j, k, false, null); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } return 0; @@ -87,77 +102,164 @@ public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityPr @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); + 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 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; + 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); + 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); + if (expQuanta <= 0) + world.setBlock(x, y, z, Blocks.air); else { - world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); + 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); + // 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()); + if (getTileEntity(world, x, y + densityDir, z) != null + && getTileEntity(world, x, y, z) != null) + BlockMoltenMetal + .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()); + 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; + 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); + 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) { + 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; + 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()); + 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 { + 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()); + if (te instanceof TileEntityMoltenMetal + && ((TileEntityMoltenMetal) te).getMetal() != null) + return JewelrycraftUtil.getColor( + ((TileEntityMoltenMetal) te).getMetal().copy()); return 16777215; } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java old mode 100644 new mode 100755 index ae9ceaa..a311c1f --- a/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java @@ -14,180 +14,178 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class BlockShadow extends BlockContainer -{ - private IIcon[] iconArray; - - /** - * - */ - public BlockShadow() - { - super(Material.iron); - setHarvestLevel("pickaxe", 3); - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - /** - * @return - */ - @Override - public int getRenderBlockPass() - { - return 1; - } - - /** - * @param worldObj - * @param x - * @param y - * @param z - * @param beaconX - * @param beaconY - * @param beaconZ - * @return - */ - public boolean isBeaconBase(World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) - { - return true; - } - - /** - * @return - */ - @Override - public boolean isOpaqueCube() - { - return false; - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param side - * @return - */ - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) - { - return false; - } - - /** - * @param par0 - * @return - */ - public static boolean isNormalCube(int par0) - { - return true; - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityBlockShadow(); - } - - /** - * @param par1IconRegister - */ - @Override - public void registerBlockIcons(IIconRegister par1IconRegister) - { - iconArray = new IIcon[16]; - for(int i = 0; i < iconArray.length; ++i) - iconArray[i] = par1IconRegister.registerIcon(getTextureName() + (15 - i)); - } - - /** - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { - if (world.getBlockMetadata(x, y, z) == 15) return null; - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } - - /** - * @param par1IBlockAccess - * @param par2 - * @param par3 - * @param par4 - */ - @Override - public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - /** - * @param p_149646_1_ - * @param p_149646_2_ - * @param p_149646_3_ - * @param p_149646_4_ - * @param p_149646_5_ - * @return - */ - @Override - public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) - { - Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); - if (this == BlockList.shadowBlock) if (block == this) return false; - return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); - } - - /** - * @return - */ - @Override - public boolean hasComparatorInputOverride() - { - return true; - } - - /** - * @param world - * @param x - * @param y - * @param z - * @param meta - * @return - */ - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int meta) - { - return world.getBlockMetadata(x, y, z); - } - - /** - * @param side - * @param meta - * @return - */ - @Override - @SideOnly (Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - return (meta < 16) ? iconArray[meta] : iconArray[0]; - } +public class BlockShadow extends BlockContainer { + private IIcon[] iconArray; + + /** + * + */ + public BlockShadow() { + super(Material.iron); + setHarvestLevel("pickaxe", 3); + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + /** + * @return + */ + @Override + public int getRenderBlockPass() { + return 1; + } + + /** + * @param worldObj + * @param x + * @param y + * @param z + * @param beaconX + * @param beaconY + * @param beaconZ + * @return + */ + public boolean isBeaconBase(World worldObj, int x, int y, int z, + int beaconX, int beaconY, int beaconZ) { + return true; + } + + /** + * @return + */ + @Override + public boolean isOpaqueCube() { + return false; + } + + /** + * @return + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * @param world + * @param x + * @param y + * @param z + * @param side + * @return + */ + public boolean isBlockSolidOnSide(World world, int x, int y, int z, + ForgeDirection side) { + return false; + } + + /** + * @param par0 + * @return + */ + public static boolean isNormalCube(int par0) { + return true; + } + + /** + * @param world + * @param var2 + * @return + */ + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityBlockShadow(); + } + + /** + * @param par1IconRegister + */ + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + iconArray = new IIcon[16]; + for (int i = 0; i < iconArray.length; ++i) + iconArray[i] = par1IconRegister + .registerIcon(getTextureName() + (15 - i)); + } + + /** + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, + int x, int y, int z) { + if (world.getBlockMetadata(x, y, z) == 15) + return null; + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + /** + * @param par1IBlockAccess + * @param par2 + * @param par3 + * @param par4 + */ + @Override + public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, + int par2, int par3, int par4) { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + /** + * @param p_149646_1_ + * @param p_149646_2_ + * @param p_149646_3_ + * @param p_149646_4_ + * @param p_149646_5_ + * @return + */ + @Override + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, + int p_149646_2_, int p_149646_3_, int p_149646_4_, + int p_149646_5_) { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, + p_149646_4_); + if (this == BlockList.shadowBlock) + if (block == this) + return false; + return block == this ? false + : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, + p_149646_3_, p_149646_4_, p_149646_5_); + } + + /** + * @return + */ + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + /** + * @param world + * @param x + * @param y + * @param z + * @param meta + * @return + */ + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, + int meta) { + return world.getBlockMetadata(x, y, z); + } + + /** + * @param side + * @param meta + * @return + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return (meta < 16) ? iconArray[meta] : iconArray[0]; + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockShadowEye.java b/src/main/java/darkknight/jewelrycraft/block/BlockShadowEye.java old mode 100644 new mode 100755 index 7a2277e..85c552d --- a/src/main/java/darkknight/jewelrycraft/block/BlockShadowEye.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockShadowEye.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.block; import java.util.Random; + import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -13,123 +14,121 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockShadowEye extends BlockContainer -{ - Random rand = new Random(); - - protected BlockShadowEye() - { - super(Material.rock); - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityShadowEye(); - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @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 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) - { - TileEntityShadowEye tile = (TileEntityShadowEye)world.getTileEntity(i, j, k); - if (!tile.active && tile.opening == 1){ - tile.active = true; - tile.target = entityPlayer; - tile.shouldAddData = true; - } - return true; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param player - */ - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - {} - - /** - * @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 icon - */ - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:stonebrick"); - } +public class BlockShadowEye extends BlockContainer { + Random rand = new Random(); + + protected BlockShadowEye() { + super(Material.rock); + } + + /** + * @param world + * @param var2 + * @return + */ + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityShadowEye(); + } + + /** + * @return + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * @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 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) { + TileEntityShadowEye tile = + (TileEntityShadowEye) world.getTileEntity(i, j, k); + if (!tile.active && tile.opening == 1) { + tile.active = true; + tile.target = entityPlayer; + tile.shouldAddData = true; + } + return true; + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param player + */ + @Override + public void onBlockClicked(World world, int i, int j, int k, + EntityPlayer player) { + // Do nothing + } + + /** + * @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 icon + */ + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:stonebrick"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockShadowHand.java b/src/main/java/darkknight/jewelrycraft/block/BlockShadowHand.java old mode 100644 new mode 100755 index bd33536..6d4cee1 --- a/src/main/java/darkknight/jewelrycraft/block/BlockShadowHand.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockShadowHand.java @@ -13,127 +13,124 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockShadowHand extends BlockContainer -{ - /** - * @param material - */ - protected BlockShadowHand(Material material) - { - super(material); - setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); - } - - /** - * @param world - * @param var2 - * @return - */ - @Override - public TileEntity createNewTileEntity(World world, int var2) - { - return new TileEntityShadowHand(); - } - - /** - * @return - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * @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 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.5D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param block - * @param par6 - */ - @Override - public void breakBlock(World world, int i, int j, int k, Block block, int par6) - { - if (world.getTileEntity(i, j, k) instanceof TileEntityShadowHand){ - TileEntityShadowHand te = (TileEntityShadowHand)world.getTileEntity(i, j, k); - if (te != null && te.getHeldItemStack() != null){ - dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.getHeldItemStack()); - world.removeTileEntity(i, j, k); - } - } - super.breakBlock(world, i, j, k, block, 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 * 8.0F / 360.0F + 0.5D) & 7; - world.setBlockMetadataWithNotify(i, j, k, rotation, 2); - } - - /** - * @param icon - */ - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:coal_block"); - } +public class BlockShadowHand extends BlockContainer { + /** + * @param material + */ + protected BlockShadowHand(Material material) { + super(material); + setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); + } + + /** + * @param world + * @param var2 + * @return + */ + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new TileEntityShadowHand(); + } + + /** + * @return + */ + @Override + public boolean renderAsNormalBlock() { + return false; + } + + /** + * @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 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.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param block + * @param par6 + */ + @Override + public void breakBlock(World world, int i, int j, int k, Block block, + int par6) { + if (world.getTileEntity(i, j, k) instanceof TileEntityShadowHand) { + TileEntityShadowHand te = + (TileEntityShadowHand) world.getTileEntity(i, j, k); + if (te != null && te.getHeldItemStack() != null) { + dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, + te.getHeldItemStack()); + world.removeTileEntity(i, j, k); + } + } + super.breakBlock(world, i, j, k, block, 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 * 8.0F / 360.0F + 0.5D) & 7; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + /** + * @param icon + */ + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:coal_block"); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java old mode 100644 new mode 100755 index db8e254..ea5e991 --- a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.block; import java.util.Random; + import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; @@ -44,8 +45,10 @@ public class BlockSmelter extends BlockContainer { 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); + 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; @@ -54,17 +57,23 @@ public class BlockSmelter extends BlockContainer { } @Override - public void breakBlock(World world, int i, int j, int k, Block block, int meta) { - TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + 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) { + 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, + new ItemStack(Blocks.cobblestone, 6)); + dropItem(world, i, j, k, + new ItemStack(Items.lava_bucket)); dropItem(world, i, j, k, metalBucket); } } @@ -73,10 +82,15 @@ public class BlockSmelter extends BlockContainer { } @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); + 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) { + 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); @@ -89,58 +103,151 @@ public class BlockSmelter extends BlockContainer { } if (te != null && !world.isRemote) { if (te.hasMetal && entityPlayer.isSneaking()) { - dropItem(world, te.xCoord, te.yCoord, te.zCoord, te.metal.copy()); + 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)) { + 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; + 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 = 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 (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(); + 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()))); + 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; + 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) + ")"))); + } 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; + 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) { + } else if ((te.hasMetal || te.hasMoltenMetal) + && !itemCoincidesWithMoltenMetal + && te.quantity < .9f) + entityPlayer.addChatMessage(new ChatComponentText( + StatCollector.translateToLocal("chatmessage." + + Variables.MODID + + ".smelter.contentdoesnotmatch"))); + else if (!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 (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; @@ -148,52 +255,119 @@ public class BlockSmelter extends BlockContainer { te.isDirty = true; if (!entityPlayer.capabilities.isCreativeMode) { --item.stackSize; - dropItem(world, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, new ItemStack(Items.bucket)); + 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", "")))); + } 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); + 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"))); + 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.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; + 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; + 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) { + public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, + int j, int k, int l) { return false; } @@ -206,10 +380,9 @@ public class BlockSmelter extends BlockContainer { public int getRenderType() { return -1; } - - @Override - public void registerBlockIcons(IIconRegister icon) - { - blockIcon = icon.registerIcon("minecraft:iron_block"); - } + + @Override + public void registerBlockIcons(IIconRegister icon) { + blockIcon = icon.registerIcon("minecraft:iron_block"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java old mode 100644 new mode 100755 index a571927..a60c8cc --- a/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java +++ b/src/main/java/darkknight/jewelrycraft/block/render/BlockCrystalRenderer.java @@ -4,7 +4,9 @@ package darkknight.jewelrycraft.block.render; import java.util.Random; + import org.lwjgl.opengl.GL11; + import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -24,12 +26,14 @@ import net.minecraft.world.IBlockAccess; @SideOnly(Side.CLIENT) public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + 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); + if (metadata < 16) + tessellator.setColorRGBA_I(BlockCrystal.colors[metadata], 100); GL11.glTranslatef(-0.5f, -0.5f, -0.5f); this.renderWorldBlock(null, 0, 0, 0, block, modelID, renderer); tessellator.draw(); @@ -39,7 +43,8 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { } @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + 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; @@ -49,84 +54,149 @@ public class BlockCrystalRenderer implements ISimpleBlockRenderingHandler { 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); + 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); + 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.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.15F + rnd.nextFloat()) / 2f); - double zp1 = Math.cos(rotation) * ((0.15F + rnd.nextFloat()) / 2f); + double rotation = Math.PI * 2.0f / crystals * i; + double xp1 = + Math.sin(rotation) * ((0.15F + rnd.nextFloat()) / 2f); + double zp1 = + Math.cos(rotation) * ((0.15F + 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); + 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 * 2F / (float) crystals * (float) i; - double xp1 = Math.sin(rotation) * ((0.15F + rnd.nextFloat()) / 2f); - double zp1 = Math.cos(rotation) * ((0.15F + rnd.nextFloat()) / 2f); + double rotation = Math.PI * 2F / crystals * i; + double xp1 = Math.sin(rotation) + * ((0.15F + rnd.nextFloat()) / 2f); + double zp1 = Math.cos(rotation) + * ((0.15F + rnd.nextFloat()) / 2f); double height = 0.1f + 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); + 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) { + private static 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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 -- cgit v1.2.3