diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-01-29 18:28:37 +0000 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-01-29 18:28:37 +0000 |
| commit | 73ca377dc01f859dabd7b07738cb7aeb762272b1 (patch) | |
| tree | 9c0acccbfbf78e813fb838ab566c96a40c5f36bb /java/darkknight/jewelrycraft/block | |
| parent | 06f62473f0622efe6decc32b70516a7c5d3d3572 (diff) | |
Made lots of changes
Diffstat (limited to 'java/darkknight/jewelrycraft/block')
8 files changed, 464 insertions, 174 deletions
diff --git a/java/darkknight/jewelrycraft/block/BlockDisplayer.java b/java/darkknight/jewelrycraft/block/BlockDisplayer.java index 333cc94..6b029b9 100644 --- a/java/darkknight/jewelrycraft/block/BlockDisplayer.java +++ b/java/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -61,35 +61,68 @@ public class BlockDisplayer extends BlockContainer { TileEntityDisplayer te = (TileEntityDisplayer) world.getTileEntity(i, j, k); ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && !world.isRemote) + if (te != null) { - if (!te.hasObject) + if (item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && !world.isRemote) { - te.object = item.copy(); - te.object.stackSize = 1; - te.quantity += item.stackSize; - te.hasObject = true; - if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; - te.isDirty = true; - te.markDirty(); - } - 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())) + if (!te.hasObject) { + te.object = item.copy(); te.quantity += item.stackSize; - te.object.stackSize = 1; + te.hasObject = true; if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; te.isDirty = true; te.markDirty(); } - else if (!te.object.hasTagCompound() && !item.hasTagCompound()) + else if (te.object.getItem() == item.getItem() && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.object.getItemDamage() == item.getItemDamage()) { - te.quantity += item.stackSize; - te.object.stackSize = 1; - if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + 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; + te.markDirty(); + } + 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; + te.markDirty(); + } + } + } + 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; + te.markDirty(); + } + } + } + } + else if(te.hasObject && te.object.getItem() != null) + { + te.quantity += 64; te.isDirty = true; - te.markDirty(); + te.markDirty(); } } } @@ -104,7 +137,7 @@ public class BlockDisplayer extends BlockContainer { if (te.hasObject && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && player.inventory.addItemStackToInventory(te.object)) { - if (player.isSneaking()) + if (!player.isSneaking()) { if (te.quantity > te.object.getMaxStackSize()) { diff --git a/java/darkknight/jewelrycraft/block/BlockHandPedestal.java b/java/darkknight/jewelrycraft/block/BlockHandPedestal.java new file mode 100644 index 0000000..95fecfc --- /dev/null +++ b/java/darkknight/jewelrycraft/block/BlockHandPedestal.java @@ -0,0 +1,124 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; + +public class BlockHandPedestal extends BlockContainer +{ + Random rand = new Random(); + + protected BlockHandPedestal(Material par2Material) + { + super(par2Material); + this.setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityHandPedestal(); + } + + @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 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 (!te.hasObject && item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && !world.isRemote) + { + te.object = item.copy(); + te.object.stackSize = 1; + te.hasObject = true; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize--; + te.isDirty = true; + te.markDirty(); + } + else if(entityPlayer.isSneaking()) + { + if(entityPlayer.inventory.addItemStackToInventory(te.object)) + { + te.hasObject = false; + te.object = new ItemStack(Item.getItemById(0), 0, 0); + } + } + te.isDirty = true; + te.markDirty(); + } + return true; + } + + 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); + } + + 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.hasObject) + { + dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.object); + world.removeTileEntity(i, j, k); + } + + super.breakBlock(world, i, j, k, block, par6); + } + + @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); + } + + @Override + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("minecraft:stonebrick"); + } +} diff --git a/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index 1c65970..f9dfc67 100644 --- a/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -50,94 +50,28 @@ public class BlockJewelrsCraftingTable extends BlockContainer ItemStack item = entityPlayer.inventory.getCurrentItem(); if (te != null && !world.isRemote) { - if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)) - { - if (te.hasModifier && te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("modifier") && item.getTagCompound().hasKey("jewel")) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrymodifiedfull"))); - else if (te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("jewel")) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"))); - else if (te.hasModifier && item.hasTagCompound() && item.getTagCompound().hasKey("modifier")) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"))); - else - { - te.jewelry = item.copy(); - te.hasJewelry = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - entityPlayer.inventory.markDirty(); - world.setTileEntity(i, j, k, te); - te.isDirty = true; - te.markDirty(); - } - } - if (!te.hasEndItem && !te.hasModifier && item != null && JewelrycraftUtil.isModifier(item)) - { - if (te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("modifier")) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"))); - else - { - te.modifier = item.copy(); - te.modifier.stackSize = 1; - te.hasModifier = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - entityPlayer.inventory.markDirty(); - world.setTileEntity(i, j, k, te); - te.isDirty = true; - te.markDirty(); - } - } - if (!te.hasEndItem && !te.hasJewel && item != null && JewelrycraftUtil.isJewel(item)) - { - if (te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("jewel")) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"))); - else - { - te.jewel = item.copy(); - te.jewel.stackSize = 1; - te.hasJewel = true; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - entityPlayer.inventory.markDirty(); - world.setTileEntity(i, j, k, te); - te.isDirty = true; - te.markDirty(); - } - } - if (te.timer <= 0 && !te.hasEndItem && te.hasJewelry && (te.hasModifier || te.hasJewel)) - { - te.timer = ConfigHandler.jewelryCraftingTime; - te.angle = 0; - } if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.hasenditem"))); - - if (te.hasModifier && entityPlayer.isSneaking()) + if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)) { - dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.modifier.copy()); - te.modifier = new ItemStack(Item.getItemById(0), 0, 0); - te.hasModifier = false; - te.timer = 0; - te.angle = 0F; + te.jewelry = item.copy(); + te.hasJewelry = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; te.isDirty = true; - te.markDirty(); - world.markBlockForUpdate(i, j, k); - world.setTileEntity(i, j, k, te); } - if (te.hasJewelry && entityPlayer.isSneaking()) + if (!te.hasEndItem && !te.hasGem && item != null && JewelrycraftUtil.isGem(item)) { - dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy()); - te.jewelry = new ItemStack(Item.getItemById(0), 0, 0); - te.hasJewelry = false; - te.timer = 0; - te.angle = 0F; + te.gem = item.copy(); + te.gem.stackSize = 1; + te.hasGem = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; te.isDirty = true; - te.markDirty(); - world.markBlockForUpdate(i, j, k); - world.setTileEntity(i, j, k, te); } - if (te.hasJewel && entityPlayer.isSneaking()) + if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting) { - dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewel.copy()); - te.jewel = new ItemStack(Item.getItemById(0), 0, 0); - te.hasJewel = false; - te.timer = 0; - te.angle = 0F; + te.carving = ConfigHandler.jewelryCraftingTime; + te.angle = 0; + te.crafting = true; te.isDirty = true; - te.markDirty(); - world.markBlockForUpdate(i, j, k); - world.setTileEntity(i, j, k, te); } } return true; @@ -157,9 +91,8 @@ public class BlockJewelrsCraftingTable extends BlockContainer TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); if (te != null) { - if (te.hasModifier) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.modifier.copy()); if (te.hasJewelry) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy()); - if (te.hasJewel) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewel.copy()); + if (te.hasGem) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.gem.copy()); if (te.hasEndItem) dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); world.removeTileEntity(i, j, k); } @@ -179,20 +112,42 @@ public class BlockJewelrsCraftingTable extends BlockContainer TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); if (te != null && !world.isRemote) { - if (te.hasEndItem) + if (player.isSneaking()) { - dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); - te.endItem = new ItemStack(Item.getItemById(0), 0, 0); - te.hasEndItem = false; - te.isDirty = true; - te.markDirty(); - world.markBlockForUpdate(i, j, k); - world.setTileEntity(i, j, k, te); + if (te.hasJewelry) + { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy()); + te.jewelry = new ItemStack(Item.getItemById(0), 0, 0); + te.hasJewelry = false; + te.carving = -1; + te.crafting = false; + te.angle = 0F; + te.isDirty = true; + } + if (te.hasGem) + { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.gem.copy()); + te.gem = new ItemStack(Item.getItemById(0), 0, 0); + te.hasGem = false; + te.carving = -1; + te.crafting = false; + te.angle = 0F; + te.isDirty = true; + } + } + else + { + if (te.hasEndItem) + { + dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); + te.endItem = new ItemStack(Item.getItemById(0), 0, 0); + te.hasEndItem = false; + te.isDirty = true; + } + else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.table.iscrafting", te.jewelry.getDisplayName()) + " (" + ((ConfigHandler.jewelryCraftingTime - te.carving) * 100 / ConfigHandler.jewelryCraftingTime) + "%)")); + else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missinggem"))); + else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelry"))); } - else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.table.iscrafting", te.jewelry.getDisplayName()) + " (" + ((ConfigHandler.jewelryCraftingTime - te.timer) * 100 / ConfigHandler.jewelryCraftingTime) + "%)")); - else if ((!te.hasModifier || !te.hasJewel) && !te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelryandmodifierorjewel"))); - else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelry"))); - else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingmodifierorjewel"))); } } diff --git a/java/darkknight/jewelrycraft/block/BlockList.java b/java/darkknight/jewelrycraft/block/BlockList.java index 75efbaa..b244a19 100644 --- a/java/darkknight/jewelrycraft/block/BlockList.java +++ b/java/darkknight/jewelrycraft/block/BlockList.java @@ -10,20 +10,16 @@ import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.tileentity.TileEntityAltar; import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; +import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; public class BlockList { - public static Block shadowOre; - public static Block glow; - public static Block smelter; - public static Block molder; - public static Block displayer; - public static Block jewelCraftingTable; - public static Block shadowBlock; - public static Block jewelAltar; + public static Block shadowOre, glow, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, jewelAltar, handPedestal, shadowHand; public static BlockMoltenMetal moltenMetal; public static Fluid moltenMetalFluid; @@ -33,14 +29,17 @@ public class BlockList { if (!isInitialized) { - shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("jewelrycraft:oreShadow").setBlockName("Jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockTextureName("jewelrycraft:oreShadow").setBlockName("Jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); glow = new BlockGlow().setBlockName("Jewelrycraft.glow").setLightLevel(1F); - smelter = new BlockSmelter(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); - molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + smelter = new BlockSmelter().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); + molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName("Jewelrycraft.displayer").setCreativeTab(JewelrycraftMod.jewelrycraft); - jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); + jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("jewelrycraft:blockShadow").setBlockName("Jewelrycraft.blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); jewelAltar = new BlockJewelAltar().setHardness(5.0F).setResistance(2.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("jewelrycraft:altar").setBlockName("Jewelrycraft.altar").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft); + handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName("Jewelrycraft.shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable(); GameRegistry.registerBlock(shadowOre, "shadowOre"); GameRegistry.registerBlock(shadowBlock, "shadowBlock"); @@ -49,13 +48,19 @@ public class BlockList GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable"); GameRegistry.registerBlock(displayer, "Displayer"); GameRegistry.registerBlock(jewelAltar, "Altar"); + GameRegistry.registerBlock(shadowEye, "Shadow Eye"); + GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal"); + GameRegistry.registerBlock(shadowHand, "Shadow Hand"); - GameRegistry.registerTileEntity(TileEntitySmelter.class, "30"); - GameRegistry.registerTileEntity(TileEntityMolder.class, "31"); - GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, "32"); - GameRegistry.registerTileEntity(TileEntityDisplayer.class, "33"); - GameRegistry.registerTileEntity(TileEntityBlockShadow.class, "34"); - GameRegistry.registerTileEntity(TileEntityAltar.class, "35"); + GameRegistry.registerTileEntity(TileEntitySmelter.class, "jewelrycraft:smelter"); + GameRegistry.registerTileEntity(TileEntityMolder.class, "jewelrycraft:molder"); + GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, "jewelrycraft:table"); + GameRegistry.registerTileEntity(TileEntityDisplayer.class, "jewelrycraft:displayer"); + GameRegistry.registerTileEntity(TileEntityBlockShadow.class, "jewelrycraft:blockShadow"); + GameRegistry.registerTileEntity(TileEntityAltar.class, "jewelrycraft:altar"); + GameRegistry.registerTileEntity(TileEntityShadowEye.class, "jewelrycraft:shadowEye"); + GameRegistry.registerTileEntity(TileEntityHandPedestal.class, "jewelrycraft:handPedestal"); + GameRegistry.registerTileEntity(TileEntityShadowHand.class, "jewelrycraft:shadowHand"); moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000); if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten"); diff --git a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java index 9c1daea..f005e04 100644 --- a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -43,6 +43,7 @@ public class BlockMoltenMetal extends BlockFluidClassic super(fluid, material); setBlockName("Jewelrycraft.moltenMetal"); this.setQuantaPerBlock(5); + this.setRenderPass(1); setLightLevel(15f); } @@ -247,7 +248,6 @@ public class BlockMoltenMetal extends BlockFluidClassic { itemID = Integer.parseInt(splitData[0]); itemDamage = Integer.parseInt(splitData[1]); - JewelryNBT.addMetal(item, new ItemStack(Item.getItemById(itemID), 1, itemDamage)); } catch (Exception e) diff --git a/java/darkknight/jewelrycraft/block/BlockShadowEye.java b/java/darkknight/jewelrycraft/block/BlockShadowEye.java new file mode 100644 index 0000000..94ece2a --- /dev/null +++ b/java/darkknight/jewelrycraft/block/BlockShadowEye.java @@ -0,0 +1,81 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +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.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; + +public class BlockShadowEye extends BlockContainer +{ + Random rand = new Random(); + + protected BlockShadowEye() + { + super(Material.rock); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityShadowEye(); + } + + @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 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); + tile.active = true; + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + } + + @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 registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("minecraft:stonebrick"); + } +} diff --git a/java/darkknight/jewelrycraft/block/BlockShadowHand.java b/java/darkknight/jewelrycraft/block/BlockShadowHand.java new file mode 100644 index 0000000..2af6d02 --- /dev/null +++ b/java/darkknight/jewelrycraft/block/BlockShadowHand.java @@ -0,0 +1,92 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; + +public class BlockShadowHand extends BlockContainer +{ + Random rand = new Random(); + + protected BlockShadowHand(Material par2Material) + { + super(par2Material); + this.setBlockBounds(0.2F, 0F, 0.2F, 0.8F, 1.0F, 0.8F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityShadowHand(); + } + + @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 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); + } + + public void breakBlock(World world, int i, int j, int k, Block block, int par6) + { + TileEntityShadowHand te = (TileEntityShadowHand) world.getTileEntity(i, j, k); + + if (te != null && te.hasObject) + { + dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.object); + world.removeTileEntity(i, j, k); + } + + super.breakBlock(world, i, j, k, block, par6); + } + + @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); + } + + @Override + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("minecraft:coal_block"); + } +} diff --git a/java/darkknight/jewelrycraft/block/BlockSmelter.java b/java/darkknight/jewelrycraft/block/BlockSmelter.java index b64f142..71ba64b 100644 --- a/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -9,6 +9,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -31,9 +32,9 @@ public class BlockSmelter extends BlockContainer { Random rand = new Random(); - protected BlockSmelter(Material par2Material) + public BlockSmelter() { - super(par2Material); + super(Material.rock); } @Override @@ -90,12 +91,14 @@ public class BlockSmelter extends BlockContainer { TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); ItemStack item = entityPlayer.inventory.getCurrentItem(); - if(te != null && te.hasMoltenMetal && te.quantity >= 0.9f && !te.pouring && item != null && item.getItem() == Items.bucket) + if (te != null && te.hasMoltenMetal && te.quantity >= 0.9f && !te.pouring && item != null && item.getItem() == Items.bucket) { te.quantity = 0f; te.hasMoltenMetal = false; ItemStack metalBucket = new ItemStack(ItemList.bucket, 1); - JewelryNBT.addMetal(metalBucket, te.moltenMetal); + ItemStack ingot = te.moltenMetal; + if (Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_glass_pane) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(ingot.getItem()) == Block.getIdFromBlock(Blocks.carpet)) ingot.setItemDamage(15 - ingot.getItemDamage()); + JewelryNBT.addMetal(metalBucket, ingot); --item.stackSize; entityPlayer.inventory.addItemStackToInventory(metalBucket); te.isDirty = true; @@ -106,56 +109,53 @@ public class BlockSmelter extends BlockContainer int index = -1; for (int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) if (entityPlayer.getDisplayName().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; - boolean canPlace = item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index != -1); + boolean canPlace = (item != null && (JewelrycraftUtil.isMetal(item) || JewelrycraftUtil.isOre(item) || index >= 0)); boolean isOre = false; boolean oreCoincidesWithMetal = false; - if(item != null && Item.getIdFromItem(item.getItem()) != 0) isOre = JewelrycraftUtil.isOre(item); - if(isOre && te.moltenMetal != null && item != null && Item.getIdFromItem(te.moltenMetal.getItem()) != 0) - oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item.getItem()).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item.getItem()).getItemDamage(); - if (!te.hasMetal && !te.hasMoltenMetal && !te.pouring && item != null && canPlace) + boolean itemCoincidesWithMetal = false; + boolean itemCoincidesWithMoltenMetal = false; + boolean overflow = false; + if (item != null && item.getItem() != null) { - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()))); - te.metal = item.copy(); - te.metal.stackSize = 1; - te.hasMetal = true; - te.melting = ConfigHandler.ingotMeltingTime; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - else if (te.hasMetal && !te.hasMoltenMetal && item != null && canPlace && item.getUnlocalizedName().equals(te.metal.getUnlocalizedName()) && (!isOre && te.metal.stackSize < 9 || isOre && te.metal.stackSize < 4)) - { - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); - te.metal.stackSize++; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; - } - else if (!te.hasMetal && te.hasMoltenMetal && item != null && canPlace && ((!isOre && item.getUnlocalizedName().equals(te.moltenMetal.getUnlocalizedName()) && te.moltenMetal.stackSize < 9) || (isOre && oreCoincidesWithMetal && te.moltenMetal.stackSize < 8))) - { - entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ore" : "ingot") + "."))); - te.metal = item.copy(); - te.metal.stackSize = 1; - te.hasMetal = true; - te.melting = ConfigHandler.ingotMeltingTime; - if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - te.isDirty = true; + isOre = JewelrycraftUtil.isOre(item); + if (te.metal != null && te.metal.getItem() != null) itemCoincidesWithMetal = item.getItem().equals(te.metal.getItem()) && item.getItemDamage() == te.metal.getItemDamage(); + if (te.moltenMetal != null && te.moltenMetal.getItem() != null) + { + itemCoincidesWithMoltenMetal = item.getItem().equals(te.moltenMetal.getItem()) && item.getItemDamage() == te.moltenMetal.getItemDamage(); + if (isOre) oreCoincidesWithMetal = te.moltenMetal.getItem().equals(JewelrycraftUtil.getIngotFromOre(item.getItem()).getItem()) && te.moltenMetal.getItemDamage() == JewelrycraftUtil.getIngotFromOre(item.getItem()).getItemDamage(); + } + overflow = isOre ? (te.metal.stackSize * 0.2f + te.quantity < 0.8f) : (te.metal.stackSize * 0.1f + te.quantity < 0.9f); } - else if (te.hasMetal && te.hasMoltenMetal && item != null && canPlace && item.getUnlocalizedName().equals(te.moltenMetal.getUnlocalizedName())) + boolean isValid = te.hasMoltenMetal ? itemCoincidesWithMoltenMetal : true; + if (te.quantity < 0.9f && !te.pouring && canPlace && isValid) { - if ((!isOre && te.moltenMetal.stackSize < 9 && te.metal.stackSize < 9 && (te.metal.stackSize + te.moltenMetal.stackSize) < 9) || (isOre && oreCoincidesWithMetal && te.metal.stackSize*2 < 9 && (te.metal.stackSize*2 + te.moltenMetal.stackSize) < 9)) + 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.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()))); + te.metal = item.copy(); + te.metal.stackSize = 1; + te.hasMetal = true; + te.melting = ConfigHandler.ingotMeltingTime; + 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 ingots (" + (te.metal.stackSize + 1) + ")"))); + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); te.metal.stackSize++; te.hasMetal = true; te.melting = ConfigHandler.ingotMeltingTime; if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; te.isDirty = true; } + te.isDirty = true; } - else if ((te.hasMetal || te.hasMoltenMetal) && item != null && canPlace && ((te.moltenMetal != null && te.moltenMetal.stackSize > 0 && item.getUnlocalizedName().equals(te.moltenMetal.getUnlocalizedName())) || (te.metal != null && te.metal.stackSize > 0 && item.getUnlocalizedName().equals(te.metal.getUnlocalizedName()))) && ((te.moltenMetal != null && te.moltenMetal.stackSize >= 9) || (te.metal != null && te.metal.stackSize >= 9))) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Smelter is at full capacity."))); - else if (te.hasMetal && !te.hasMoltenMetal && item != null && canPlace) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.alreadyhasingot", te.metal.getDisplayName()))); - else if (te.hasMoltenMetal && Item.getIdFromItem(te.moltenMetal.getItem()) > 0) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName()))); - else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && canPlace) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot"))); - else if (item != null && (!item.getUnlocalizedName().toLowerCase().contains("ingot") || item.getUnlocalizedName().toLowerCase().contains("mold"))) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemneedstobeingot"))); + else if (item == null && te.hasMoltenMetal && te.moltenMetal.getItem() != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName()))); + else if (item != null && (te.hasMetal || te.hasMoltenMetal) && !itemCoincidesWithMoltenMetal && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Item does not match contents!"))); + else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && te.quantity < 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot"))); + else if (item != null && te.quantity >= 0.9f) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("Smelter is at full capacity."))); if (te.hasMetal && entityPlayer.isSneaking()) { @@ -164,7 +164,7 @@ public class BlockSmelter extends BlockContainer te.melting = -1; te.isDirty = true; } - if (te != null) world.setTileEntity(i, j, k, te); + world.setTileEntity(i, j, k, te); } return true; } |
