diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-26 00:50:16 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-26 00:50:16 +0200 |
| commit | 1a3455b24d90b0def912c28467cbc51662d660e0 (patch) | |
| tree | 90232ffe1b1a52ab43594b438cfac44ad3c0b60e /common/darkknight/jewelrycraft/block | |
| parent | 1997f4547812121223836dcacfcb31ea63acdda6 (diff) | |
Major changes. Thanks domi for helping me with the chest linking ring :)
Diffstat (limited to 'common/darkknight/jewelrycraft/block')
5 files changed, 42 insertions, 123 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockBase.java b/common/darkknight/jewelrycraft/block/BlockBase.java deleted file mode 100644 index 0378fb5..0000000 --- a/common/darkknight/jewelrycraft/block/BlockBase.java +++ /dev/null @@ -1,19 +0,0 @@ -package darkknight.jewelrycraft.block; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; - -public class BlockBase extends Block -{ - public BlockBase(int par1, Material mat) - { - super(par1, mat); - } - - @Override - public Block setUnlocalizedName(String name) - { - Block r = super.setUnlocalizedName(name); - return r.setTextureName(name.replaceAll("\\.", ":")); - } -} diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index ebbae64..bf1d82f 100644 --- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -1,17 +1,12 @@ package darkknight.jewelrycraft.block; -import java.util.ArrayList; -import java.util.Iterator; 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.IconRegister; 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; @@ -19,44 +14,19 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.util.JewelrycraftUtil; public class BlockJewelrsCraftingTable extends BlockContainer { Random rand = new Random(); - public static ArrayList<ItemStack> modifiers = new ArrayList<ItemStack>(); - public static ArrayList<ItemStack> jewel = new ArrayList<ItemStack>(); - public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>(); - protected BlockJewelrsCraftingTable(int par1, Material par2Material) { super(par1, par2Material); this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); } - public static void addStuff() - { - //Modifiers - modifiers.add(new ItemStack(Item.blazePowder)); - modifiers.add(new ItemStack(Item.sugar)); - modifiers.add(new ItemStack(Block.chest)); - modifiers.add(new ItemStack(Item.pickaxeIron)); - modifiers.add(new ItemStack(Item.bed)); - modifiers.add(new ItemStack(Item.eyeOfEnder)); - - //Jewels - jewel.add(new ItemStack(Item.enderPearl)); - jewel.add(new ItemStack(Item.diamond)); - jewel.add(new ItemStack(Item.emerald)); - jewel.add(new ItemStack(Block.obsidian)); - jewel.add(new ItemStack(Item.netherStar)); - - //Jewelry - jewelry.add(new ItemStack(ItemList.ring)); - } - @Override public TileEntity createNewTileEntity(World world) { @@ -76,14 +46,14 @@ public class BlockJewelrsCraftingTable extends BlockContainer ItemStack item = entityPlayer.inventory.getCurrentItem(); if (te != null && !world.isRemote) { - if (!te.hasEndItem && !te.hasJewelry && item != null && isJewelry(item)) + 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(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrymodifiedfull")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrymodifiedfull")); else if(te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("jewel")) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsjewel")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel")); else if(te.hasModifier && item.hasTagCompound() && item.getTagCompound().hasKey("modifier")) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsmodifier")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier")); else { te.jewelry = item.copy(); @@ -94,10 +64,10 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.isDirty = true; } } - if (!te.hasEndItem && !te.hasModifier && item != null && isModifier(item)) + if (!te.hasEndItem && !te.hasModifier && item != null && JewelrycraftUtil.isModifier(item)) { if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("modifier")) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsmodifier")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier")); else { te.modifier = item.copy(); @@ -109,10 +79,10 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.isDirty = true; } } - if (!te.hasEndItem && !te.hasJewel && item != null && isJewel(item)) + if (!te.hasEndItem && !te.hasJewel && item != null && JewelrycraftUtil.isJewel(item)) { if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("jewel")) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.jewelrycontainsjewel")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel")); else { te.jewel = item.copy(); @@ -125,7 +95,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer } } 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(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.hasenditem")); + if (te.hasEndItem && item != null) entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.hasenditem")); if (te.hasModifier && entityPlayer.isSneaking()) { @@ -134,6 +104,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.hasModifier = false; te.timer = 0; te.angle = 0F; + te.isDirty = true; world.markTileEntityForDespawn(te); world.setBlockTileEntity(i, j, k, te); } @@ -144,6 +115,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.hasJewelry = false; te.timer = 0; te.angle = 0F; + te.isDirty = true; world.markTileEntityForDespawn(te); world.setBlockTileEntity(i, j, k, te); } @@ -154,6 +126,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.hasJewel = false; te.timer = 0; te.angle = 0F; + te.isDirty = true; world.markTileEntityForDespawn(te); world.setBlockTileEntity(i, j, k, te); } @@ -161,45 +134,6 @@ public class BlockJewelrsCraftingTable extends BlockContainer return true; } - public boolean isModifier(ItemStack item) - { - Iterator<ItemStack> i = modifiers.iterator(); - - while (i.hasNext()) - { - ItemStack temp = i.next(); - if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage()) - return true; - } - return false; - } - - public boolean isJewel(ItemStack item) - { - Iterator<ItemStack> i = jewel.iterator(); - - while (i.hasNext()) - { - ItemStack temp = i.next(); - if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage()) - return true; - } - return false; - } - - public boolean isJewelry(ItemStack item) - { - Iterator<ItemStack> i = jewelry.iterator(); - - while (i.hasNext()) - { - ItemStack temp = i.next(); - if (temp.itemID == item.itemID && temp.getItemDamage() == item.getItemDamage()) - return true; - } - return false; - } - 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); @@ -241,13 +175,14 @@ public class BlockJewelrsCraftingTable extends BlockContainer dropItem(te.worldObj, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); te.endItem = new ItemStack(0, 0, 0); te.hasEndItem = false; + te.isDirty = true; world.markTileEntityForDespawn(te); world.setBlockTileEntity(i, j, k, te); } - else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(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(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingjewelryandmodifierorjewel")); - else if (!te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingjewelry")); - else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.table.missingmodifierorjewel")); + else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(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(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelryandmodifierorjewel")); + else if (!te.hasJewelry) player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelry")); + else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingmodifierorjewel")); } } diff --git a/common/darkknight/jewelrycraft/block/BlockList.java b/common/darkknight/jewelrycraft/block/BlockList.java index f094811..10e1cdc 100644 --- a/common/darkknight/jewelrycraft/block/BlockList.java +++ b/common/darkknight/jewelrycraft/block/BlockList.java @@ -23,10 +23,10 @@ public class BlockList { if (!isInitialized) { - shadowOre = new BlockBase(ConfigHandler.idShadowOre, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - smelter = new BlockSmelter(ConfigHandler.idSmelter, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); - molder = new BlockMolder(ConfigHandler.idMolder, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); - jewelCraftingTable = new BlockJewelrsCraftingTable(ConfigHandler.idJewelCraftingTable, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowOre = new Block(ConfigHandler.idShadowOre, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setTextureName("jewelrycraft:oreShadow").setUnlocalizedName("Jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + smelter = new BlockSmelter(ConfigHandler.idSmelter, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); + molder = new BlockMolder(ConfigHandler.idMolder, Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + jewelCraftingTable = new BlockJewelrsCraftingTable(ConfigHandler.idJewelCraftingTable, Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("Jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); GameRegistry.registerBlock(shadowOre, "shadowOre"); GameRegistry.registerBlock(smelter, "Smelter"); diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java index f26c232..f64b122 100644 --- a/common/darkknight/jewelrycraft/block/BlockMolder.java +++ b/common/darkknight/jewelrycraft/block/BlockMolder.java @@ -52,7 +52,7 @@ public class BlockMolder extends BlockContainer te.mold = item.copy(); te.hasMold = true; if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; - entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.molder.addedmold", te.mold.getDisplayName())); + entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.molder.addedmold", te.mold.getDisplayName())); te.isDirty = true; } if (te.hasMold && entityPlayer.isSneaking() && !te.hasMoltenMetal) @@ -62,7 +62,7 @@ public class BlockMolder extends BlockContainer te.hasMold = false; te.isDirty = true; } - else if(te.hasMoltenMetal) entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.hasmoltenmetal")); + else if(te.hasMoltenMetal) entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.hasmoltenmetal")); } return true; } @@ -110,11 +110,11 @@ public class BlockMolder extends BlockContainer me.hasJewelBase = false; } else if (me.hasMoltenMetal && me.cooling > 0) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.metaliscooling") + " (" + ((ConfigHandler.ingotCoolingTime - me.cooling)*100/ConfigHandler.ingotCoolingTime) + "%)"); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.metaliscooling") + " (" + ((ConfigHandler.ingotCoolingTime - me.cooling)*100/ConfigHandler.ingotCoolingTime) + "%)"); else if (me.mold.itemID == ItemList.molds.itemID && !me.hasMoltenMetal) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.moldisempty")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldisempty")); else if (me.mold.itemID != ItemList.molds.itemID) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.molder.moldismissing")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldismissing")); me.isDirty = true; } } diff --git a/common/darkknight/jewelrycraft/block/BlockSmelter.java b/common/darkknight/jewelrycraft/block/BlockSmelter.java index 472d3b8..8716041 100644 --- a/common/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/common/darkknight/jewelrycraft/block/BlockSmelter.java @@ -17,6 +17,7 @@ import net.minecraft.world.World; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelrycraftUtil; public class BlockSmelter extends BlockContainer { @@ -65,9 +66,11 @@ public class BlockSmelter extends BlockContainer ItemStack item = entityPlayer.inventory.getCurrentItem(); if (te != null && !world.isRemote) { - if (!te.hasMetal && !te.hasMoltenMetal && item != null && (item.getUnlocalizedName().toLowerCase().contains("ingot") || entityPlayer.username.equals("sor1n")) && !item.getUnlocalizedName().toLowerCase().contains("mold")) + int index = -1; + for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) if(entityPlayer.username.equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; + if (!te.hasMetal && !te.hasMoltenMetal && item != null && (item.getUnlocalizedName().toLowerCase().contains("ingot") || index != -1) && !item.getUnlocalizedName().toLowerCase().contains("mold")) { - entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName())); + entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName())); te.metal = item.copy(); te.metal.stackSize = 1; te.hasMetal = true; @@ -76,13 +79,13 @@ public class BlockSmelter extends BlockContainer te.isDirty = true; } else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold")) - entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.alreadyhasingot", te.metal.getDisplayName())); + entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.alreadyhasingot", te.metal.getDisplayName())); else if (te.hasMoltenMetal) - entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName())); + entityPlayer.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName())); else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().contains("Ingot")) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.itemrenamedtoingot")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot")); else if (item != null && (!item.getUnlocalizedName().toLowerCase().contains("ingot") || item.getUnlocalizedName().toLowerCase().contains("mold"))) - entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.itemneedstobeingot")); + entityPlayer.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemneedstobeingot")); if (te.hasMetal && entityPlayer.isSneaking()) { @@ -125,17 +128,17 @@ public class BlockSmelter extends BlockContainer world.setBlockTileEntity(i, j, k, te); } else if (te.hasMetal && te.melting > 0) - player.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + ((ConfigHandler.ingotMeltingTime - te.melting)*100/ConfigHandler.ingotMeltingTime) + "%)"); + player.addChatMessage(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + ((ConfigHandler.ingotMeltingTime - te.melting)*100/ConfigHandler.ingotMeltingTime) + "%)"); else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.molderismissing")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderismissing")); else if (!me.hasMold && te.hasMoltenMetal) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.molderhasnomold")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasnomold")); else if (me.hasMoltenMetal && te.hasMoltenMetal) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.molderhasmoltenmetal")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasmoltenmetal")); else if (me.hasJewelBase && te.hasMoltenMetal) - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.modlerhasitem")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.modlerhasitem")); else - player.addChatMessage(StatCollector.translateToLocal("chatmessage.jewelrycraft.smelter.empty")); + player.addChatMessage(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.empty")); } } |
