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 | |
| parent | 1997f4547812121223836dcacfcb31ea63acdda6 (diff) | |
Major changes. Thanks domi for helping me with the chest linking ring :)
22 files changed, 734 insertions, 481 deletions
diff --git a/common/darkknight/jewelrycraft/JewelrycraftMod.java b/common/darkknight/jewelrycraft/JewelrycraftMod.java index b4c9c9d..68d26ec 100644 --- a/common/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/common/darkknight/jewelrycraft/JewelrycraftMod.java @@ -22,41 +22,42 @@ import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.registry.GameRegistry; -import darkknight.jewelrycraft.block.BlockJewelrsCraftingTable; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.client.JewelryCraftClient; import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.container.GuiHandler; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.lib.Reference; import darkknight.jewelrycraft.recipes.CraftingRecipes; import darkknight.jewelrycraft.server.JewelryCraftServer; +import darkknight.jewelrycraft.util.JewelrycraftUtil; import darkknight.jewelrycraft.worldGen.Generation; @Mod(modid = Reference.MODID, name = Reference.MODNAME, version = Reference.VERSION) @NetworkMod(clientSideRequired = false, serverSideRequired = false, - clientPacketHandlerSpec = @SidedPacketHandler(channels = { Reference.PACKET_CHANNEL }, packetHandler = JewelryCraftClient.class), - serverPacketHandlerSpec = @SidedPacketHandler(channels = { Reference.PACKET_CHANNEL }, packetHandler = JewelryCraftServer.class), - connectionHandler = JewelrycraftMod.class) +clientPacketHandlerSpec = @SidedPacketHandler(channels = { Reference.PACKET_CHANNEL }, packetHandler = JewelryCraftClient.class), +serverPacketHandlerSpec = @SidedPacketHandler(channels = { Reference.PACKET_CHANNEL }, packetHandler = JewelryCraftServer.class), +connectionHandler = JewelrycraftMod.class) public class JewelrycraftMod implements IConnectionHandler { @Instance(Reference.MODID) public static JewelrycraftMod instance; - + @Metadata(Reference.MODID) - public static ModMetadata metadata; - + public static ModMetadata metadata; + @SidedProxy(clientSide = "darkknight.jewelrycraft.client.ClientProxy", serverSide = "darkknight.jewelrycraft.CommonProxy") - public static CommonProxy proxy; - - public static CreativeTabs jewelrycraft = new CreativeTabs("JewelryCraft") - { - @Override - public ItemStack getIconItemStack() - { - return new ItemStack(ItemList.shadowIngot, 1, 0); - } - }; - + public static CommonProxy proxy; + + public static CreativeTabs jewelrycraft = new CreativeTabs("JewelryCraft") + { + @Override + public ItemStack getIconItemStack() + { + return new ItemStack(ItemList.ring, 1, 0); + } + }; + @EventHandler public void preInit(FMLPreInitializationEvent e) { @@ -66,60 +67,62 @@ public class JewelrycraftMod implements IConnectionHandler CraftingRecipes.preInit(e); proxy.registerRenderers(); } - + @EventHandler public void init(FMLInitializationEvent e) { OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); GameRegistry.registerWorldGenerator(new Generation()); + new GuiHandler(); } - + @EventHandler public void postInit(FMLPostInitializationEvent e) { - BlockJewelrsCraftingTable.addStuff(); + JewelrycraftUtil.addStuff(); + JewelrycraftUtil.jamcrafters(); } - + @Override // 2) Called when a player logs into the server SERVER SIDE public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { - + } - + @Override // If you don't want the connection to continue, return a non-empty string here SERVER SIDE public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) { return null; } - + @Override // 1) Fired when a remote connection is opened CLIENT SIDE public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { - + } - + @Override // 1) Fired when a local connection is opened CLIENT SIDE public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) { - + } - + @Override // Fired when a connection closes ALL SIDES public void connectionClosed(INetworkManager manager) { - + } - + @Override // 3) Fired when the client established the connection to the server CLIENT SIDE public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { - + } } 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")); } } diff --git a/common/darkknight/jewelrycraft/client/GuiRingChest.java b/common/darkknight/jewelrycraft/client/GuiRingChest.java new file mode 100644 index 0000000..3aa4cf6 --- /dev/null +++ b/common/darkknight/jewelrycraft/client/GuiRingChest.java @@ -0,0 +1,39 @@ +package darkknight.jewelrycraft.client; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.container.ContainerRingChest; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class GuiRingChest extends GuiContainer +{ + public ContainerRingChest container; + + public GuiRingChest(ContainerRingChest container) + { + super(container); + this.container = container; + xSize = 176; + ySize = 166; + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) + { + GL11.glColor3f(1, 1, 1); + + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/chest_ring.png")); + + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } + + @Override + public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString("Linked Chest", 8, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, 72, 0x404040); + } +} diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java index a4b2b27..e4b87f5 100644 --- a/common/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java @@ -9,13 +9,13 @@ public class ConfigHandler public static int idThiefGloves = 17493; public static int idShadowIngot = 17494; public static int idMolds = 17495; - public static int idRing = 17498; + public static int idRing = 17496; public static int idClayMolds = 17497; public static int idShadowOre = 1750; public static int idSmelter = 1751; public static int idMolder = 1752; - public static int idJewelCraftingTable = 1754; + public static int idJewelCraftingTable = 1753; public static int ingotCoolingTime = 200; public static int ingotMeltingTime = 1500; diff --git a/common/darkknight/jewelrycraft/container/ContainerRingChest.java b/common/darkknight/jewelrycraft/container/ContainerRingChest.java new file mode 100644 index 0000000..2728941 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/ContainerRingChest.java @@ -0,0 +1,71 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityChest; + +public class ContainerRingChest extends Container +{ + public TileEntityChest theChest; + + public ContainerRingChest(InventoryPlayer inv, TileEntityChest chest) + { + theChest = chest; + + int x, y; + + for (x = 0; x < 9; x++) + addSlotToContainer(new SlotRingChest(inv, x, 8 + (18 * x), 142, x == inv.currentItem)); + for (y = 0; y < 3; y++) + for (x = 0; x < 9; x++) + addSlotToContainer(new Slot(inv, x + 9 + (y * 9), 8 + (18 * x), 84 + (y * 18))); + + for (y = 0; y < 3; y++) + for (x = 0; x < 9; x++) + addSlotToContainer(new SlotRingChest(chest, 26 - (x + (y * 9)), 8 + (18 * (8 - x)), 17 + ((2 - y) * 18), false)); + } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < 27) + { + if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 0, 27, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } +} diff --git a/common/darkknight/jewelrycraft/container/GuiHandler.java b/common/darkknight/jewelrycraft/container/GuiHandler.java new file mode 100644 index 0000000..a0afc3f --- /dev/null +++ b/common/darkknight/jewelrycraft/container/GuiHandler.java @@ -0,0 +1,30 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.client.GuiRingChest; + +public class GuiHandler implements IGuiHandler +{ + public GuiHandler() + { + NetworkRegistry.instance().registerGuiHandler(JewelrycraftMod.instance, this); + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + return new ContainerRingChest(player.inventory, (TileEntityChest) world.getBlockTileEntity(x, y, z)); + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z)); + } + +} diff --git a/common/darkknight/jewelrycraft/container/SlotRingChest.java b/common/darkknight/jewelrycraft/container/SlotRingChest.java new file mode 100644 index 0000000..576dee7 --- /dev/null +++ b/common/darkknight/jewelrycraft/container/SlotRingChest.java @@ -0,0 +1,39 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotRingChest extends Slot +{ + public boolean locked = false; + + public SlotRingChest(IInventory tile, int slotID, int x, int y, boolean locked) + { + super(tile, slotID, x, y); + this.locked = locked; + } + + @Override + public boolean isItemValid(ItemStack stack) + { + return !locked; + } + + @Override + public ItemStack decrStackSize(int amount) + { + if (!locked) + { + return super.decrStackSize(amount); + } + return null; + } + + @Override + public boolean canTakeStack(EntityPlayer player) + { + return !locked; + } +} diff --git a/common/darkknight/jewelrycraft/item/ItemBase.java b/common/darkknight/jewelrycraft/item/ItemBase.java deleted file mode 100644 index 7f806bf..0000000 --- a/common/darkknight/jewelrycraft/item/ItemBase.java +++ /dev/null @@ -1,18 +0,0 @@ -package darkknight.jewelrycraft.item; - -import net.minecraft.item.Item; - -public class ItemBase extends Item -{ - public ItemBase(int par1) - { - super(par1); - } - - @Override - public Item setUnlocalizedName(String name) - { - Item r = super.setUnlocalizedName(name); - return r.setTextureName(name.replaceAll("\\.", ":")); - } -} diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index 3810d6a..d099836 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -19,11 +19,11 @@ public class ItemList { if (!isInitialized) { - thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves).setUnlocalizedName("jewelrycraft.thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); - shadowIngot = new ItemBase(ConfigHandler.idShadowIngot).setUnlocalizedName("jewelrycraft.ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); - molds = new ItemMolds(ConfigHandler.idMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - clayMolds = new ItemClayMolds(ConfigHandler.idClayMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - ring = new ItemRing(ConfigHandler.idRing).setUnlocalizedName("jewelrycraft.ring").setCreativeTab(JewelrycraftMod.jewelrycraft); + thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves - 256).setUnlocalizedName("Jewelrycraft.thiefGloves").setTextureName("jewelrycraft:thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowIngot = new Item(ConfigHandler.idShadowIngot - 256).setUnlocalizedName("Jewelrycraft.ingotShadow").setTextureName("jewelrycraft:ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + molds = new ItemMolds(ConfigHandler.idMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + clayMolds = new ItemClayMolds(ConfigHandler.idClayMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + ring = new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring").setCreativeTab(JewelrycraftMod.jewelrycraft); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 6f31c4d..92e16cf 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -6,8 +6,10 @@ import java.util.List; import javax.imageio.ImageIO; +import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.util.JewelryNBT; import net.minecraft.block.Block; @@ -15,15 +17,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.resources.ResourceManager; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryEnderChest; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; @@ -31,7 +33,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -public class ItemRing extends ItemBase +public class ItemRing extends Item { public Icon jewel; private int amplifier; @@ -42,14 +44,14 @@ public class ItemRing extends ItemBase this.setMaxStackSize(1); } - public void registerIcons(IconRegister iconRegister) + public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("jewelrycraft:ring"); jewel = iconRegister.registerIcon("jewelrycraft:jewel"); } @Override - public boolean requiresMultipleRenderPasses() + public boolean requiresMultipleRenderPasses() { return true; } @@ -70,170 +72,98 @@ public class ItemRing extends ItemBase public Icon getIcon(ItemStack stack, int pass) { - if (stack.hasTagCompound()) - { - if (stack.getTagCompound().hasKey("jewel")) - { - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - if(pass == 0) return itemIcon; - if(pass == 1) return jewel; - } - } + if (JewelryNBT.jewel(stack) != null) return pass == 0 ? itemIcon : jewel; return itemIcon; } public static int color(ItemStack stack, int pass) throws IOException { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("ingot") && !stack.getTagCompound().hasKey("jewel") && pass == 1) + String domain = "", texture; + ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + if (pass == 1 && JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) == null) { - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - if(ingotStack.getIconIndex().getIconName() != "") - { - String domain = ""; - if(ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = ingotStack.getIconIndex().getIconName().substring(ingotStack.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - if(ingotStack.getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); - else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); - ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); - return bufferedimage.getRGB(9, 9); - } + if (JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + texture = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(JewelryNBT.ingot(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; + ResourceLocation ingot = null; + if (JewelryNBT.ingot(stack).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); + else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); + BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); + return bufferedimage.getRGB(9, 9); } - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel")) + else if (JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) != null) { - if(pass == 1) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack jewel = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - if(jewel != null && jewel != new ItemStack(0, 0, 0) && jewel.getIconIndex().getIconName() != "") - { - String domain = ""; - if(jewel.getIconIndex().getIconName().substring(0, jewel.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = jewel.getIconIndex().getIconName().substring(0, jewel.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = jewel.getIconIndex().getIconName().substring(jewel.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation jewelLoc = null; - if(jewel.getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); - else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); - ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); - return bufferedimage.getRGB(9, 4); - } - } - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - if(ingotStack.getIconIndex().getIconName() != "") - { - String domain = ""; - if(ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = ingotStack.getIconIndex().getIconName().substring(0, ingotStack.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = ingotStack.getIconIndex().getIconName().substring(ingotStack.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - if(ingotStack.getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); - else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); - ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); - return bufferedimage.getRGB(9, 9); - } + if (pass == 1) + { + if (JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + texture = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(JewelryNBT.jewel(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; + ResourceLocation jewelLoc = null; + if (JewelryNBT.jewel(stack).getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); + else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); + BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); + return bufferedimage.getRGB(9, 4); + } + if (JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + texture = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(JewelryNBT.ingot(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; + ResourceLocation ingot = null; + if (JewelryNBT.ingot(stack).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); + else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); + BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); + return bufferedimage.getRGB(9, 9); } return 16777215; } public String getItemDisplayName(ItemStack stack) { - if (stack.hasTagCompound()) - { - if (stack.getTagCompound().hasKey("ingot")) - { - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - if (stack.getTagCompound().hasKey("jewel")) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack jewel = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - if(jewel.itemID == Item.diamond.itemID && ingotStack.itemID == Item.ingotGold.itemID) return "Wedding Ring"; - } - return ingotStack.getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); - } - } + if (JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) != null && JewelryNBT.isJewelX(stack, new ItemStack(Item.diamond)) && JewelryNBT.isIngotX(stack, new ItemStack(Item.ingotGold))) return "Wedding Ring"; + else if(JewelryNBT.ingot(stack) != null) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (!world.isRemote && stack.hasTagCompound()) - { - if(stack.getTagCompound().hasKey("x") && stack.getTagCompound().hasKey("y") && stack.getTagCompound().hasKey("z")) - { - NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("x"); - NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("y"); - NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("z"); - double posX = 0, posY = 0, posZ = 0; - posX = x.getDouble("x"); - posY = y.getDouble("y"); - posZ = z.getDouble("z"); - if(stack.getTagCompound().hasKey("dimension") && stack.getTagCompound().hasKey("dimName")) - { - NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimension"); - int dimension = 0; - dimension = dim.getInteger("dimension"); - for(int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); - if(player.dimension != dimension) player.travelToDimension(dimension); + if (!world.isRemote){ + if (JewelryNBT.playerPosX(stack) != -1 && JewelryNBT.playerPosY(stack) != -1 && JewelryNBT.playerPosZ(stack) != -1){ + double posX = JewelryNBT.playerPosX(stack), posY = JewelryNBT.playerPosY(stack), posZ = JewelryNBT.playerPosZ(stack); + if (JewelryNBT.dimension(stack) != -2 && JewelryNBT.dimName(stack) != null){ + int dimension = JewelryNBT.dimension(stack); + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + if (!JewelryNBT.isDimensionX(stack, player.dimension)) player.travelToDimension(dimension); player.setPositionAndUpdate(posX, posY, posZ); - for(int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); } - else - { - for(int i = 1; i <= 20; i++) - world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + else{ + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); player.setPositionAndUpdate(posX, posY, posZ); - for(int i = 1; i <= 300; i++) - world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); } } - if(stack.getTagCompound().hasKey("jewel")) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack jewel = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - if(stack.getTagCompound().hasKey("modifier")) - { - NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); - ItemStack modifier = new ItemStack(0, 0, 0); - modifier.readFromNBT(modifierNBT); - if(jewel.itemID == Item.enderPearl.itemID && modifier.itemID == Item.bed.itemID && !stack.getTagCompound().hasKey("x") && !stack.getTagCompound().hasKey("y") && !stack.getTagCompound().hasKey("z") && !stack.getTagCompound().hasKey("dimension")) - { - JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); - JewelryNBT.addEnchantment(stack); - } - if(jewel.itemID == Block.obsidian.blockID && modifier.itemID == Item.eyeOfEnder.itemID) - { - InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); - player.displayGUIChest(inventoryenderchest); + else if(JewelryNBT.isJewelX(stack, new ItemStack(Item.enderPearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Item.bed)) && JewelryNBT.dimension(stack) == -2 && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); + JewelryNBT.addEnchantment(stack); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Block.obsidian)) && JewelryNBT.isModifierX(stack, new ItemStack(Item.eyeOfEnder))){ + InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); + player.displayGUIChest(inventoryenderchest); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Item.enderPearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Block.chest))){ + int i = JewelryNBT.blockCoordX(stack), j = JewelryNBT.blockCoordY(stack), k = JewelryNBT.blockCoordZ(stack); + if (player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) <= 128 && i != -1 && j != -1 && k != -1){ + int id = world.getBlockId(i, j, k); + if (id != 0 && Block.blocksList[id] != null && Block.blocksList[id].blockID == Block.chest.blockID){ + TileEntity tile = world.getBlockTileEntity(i, j, k); + if (tile != null && tile instanceof TileEntityChest) FMLNetworkHandler.openGui(player, JewelrycraftMod.instance, 0, world, i, j, k); } } - else if(jewel.itemID == Item.enderPearl.itemID && !stack.getTagCompound().hasKey("x") && !stack.getTagCompound().hasKey("y") && !stack.getTagCompound().hasKey("z")) - { - JewelryNBT.addCoordonates(stack, player.posX, player.posY, player.posZ); - JewelryNBT.addEnchantment(stack); - } + else if(i != -1 && j != -1 && k != -1) player.addChatMessage("Chest out of range! You need to be " + ((int)player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) - 127) + " blocks closer."); + else player.addChatMessage("You need to link the ring with a chest first, before using it!"); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Item.enderPearl)) && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonates(stack, player.posX, player.posY, player.posZ); + JewelryNBT.addEnchantment(stack); } } return stack; @@ -242,115 +172,60 @@ public class ItemRing extends ItemBase @Override public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if (!player.worldObj.isRemote && stack.hasTagCompound()) - { - if(stack.getTagCompound().hasKey("jewel") && stack.getTagCompound().hasKey("modifier") && !stack.getTagCompound().hasKey("entityID") && !stack.getTagCompound().hasKey("entity")) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); - ItemStack jewel = new ItemStack(0, 0, 0); - ItemStack modifier = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - modifier.readFromNBT(modifierNBT); - if(jewel.itemID == Item.netherStar.itemID && modifier.itemID == Block.chest.blockID) - { - JewelryNBT.addEntity(stack, entity); - JewelryNBT.addEntityID(stack, entity); - entity.setDead(); - JewelryNBT.addEnchantment(stack); - } - } + if (!player.worldObj.isRemote && JewelryNBT.isJewelX(stack, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(stack, new ItemStack(Block.chest)) && JewelryNBT.entity(stack, player) == null){ + JewelryNBT.addEntity(stack, entity); + JewelryNBT.addEntityID(stack, entity); + entity.setDead(); + JewelryNBT.addEnchantment(stack); } return true; } /** - * allows items to add custom lines of information to the mouseover description + * allows items to add custom lines of information to the mouseover + * description */ @Override - @SuppressWarnings({ "rawtypes", "unchecked"}) + @SuppressWarnings( + { "rawtypes", "unchecked" }) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if (stack.hasTagCompound() && stack.getDisplayName() != "Wedding Ring") { - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("ingot")) - { - NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - if(ingotStack != null && ingotStack != new ItemStack(0, 0, 0) && ingotStack.getDisplayName() != null) - list.add("Ingot: " + EnumChatFormatting.YELLOW + ingotStack.getDisplayName()); - } + ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("jewel")) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack jewel = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - if(jewel != null && jewel != new ItemStack(0, 0, 0) && jewel.getDisplayName() != null) - list.add("Jewel: " + EnumChatFormatting.BLUE + jewel.getDisplayName()); - } + ItemStack jewel = JewelryNBT.jewel(stack); + if (jewel != null) list.add("Jewel: " + EnumChatFormatting.BLUE + jewel.getDisplayName()); - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("modifier")) - { - NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); - ItemStack modifier = new ItemStack(0, 0, 0); - modifier.readFromNBT(modifierNBT); - if(modifier != null && modifier != new ItemStack(0, 0, 0) && modifier.getDisplayName() != null) - list.add("Modifier: " + EnumChatFormatting.DARK_PURPLE + modifier.getDisplayName()); - } + ItemStack modifier = JewelryNBT.modifier(stack); + if(modifier != null) list.add("Modifier: " + EnumChatFormatting.DARK_PURPLE + modifier.getDisplayName()); - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("x") && stack.getTagCompound().hasKey("y") && stack.getTagCompound().hasKey("z")) - { - NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("x"); - NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("y"); - NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("z"); - double posX = 0, posY = 0, posZ = 0; - posX = x.getDouble("x"); - posY = y.getDouble("y"); - posZ = z.getDouble("z"); - list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int)posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int)posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int)posZ); - } + double playerPosX = JewelryNBT.playerPosX(stack), playerPosY = JewelryNBT.playerPosY(stack), playerPosZ = JewelryNBT.playerPosZ(stack); + if(playerPosX != -1 && playerPosY != -1 && playerPosZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) playerPosX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) playerPosY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) playerPosZ); - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("dimName")) - { - NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimName"); - String name = ""; - name = dim.getString("dimName"); - list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); - } + int posX = JewelryNBT.blockCoordX(stack), posY = JewelryNBT.blockCoordY(stack), posZ = JewelryNBT.blockCoordZ(stack); + if(posX != -1 && posY != -1 && posZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) posZ); - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity")) - { - NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID"); - NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity"); - int entityID = 0; - entityID = enID.getInteger("entityID"); - EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj); - entity.readFromNBT(en); - list.add("Entity: " + EnumChatFormatting.GOLD + entity.getEntityName()); - } + String name = JewelryNBT.dimName(stack); + if(name != null) list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); + + EntityLivingBase entity = JewelryNBT.entity(stack, player); + if (entity != null) list.add("Entity: " + EnumChatFormatting.GOLD + entity.getEntityName()); } } public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) { - if (!world.isRemote && stack.hasTagCompound()) + if (!world.isRemote) { - if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity")) - { - NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID"); - NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity"); - int entityID = 0; - entityID = enID.getInteger("entityID"); - EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj); - entity.readFromNBT(en); - entity.setLocationAndAngles(i + 0.5D, j + 1D, k + 0.5D, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); + EntityLivingBase entity = JewelryNBT.entity(stack, player); + if(entity != null){ + entity.setLocationAndAngles(i + 0.5D, j + 1D, k + 0.5D, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); world.spawnEntityInWorld(entity); - JewelryNBT.removeNBT(stack, "entityID"); - JewelryNBT.removeNBT(stack, "entity"); - JewelryNBT.removeNBT(stack, "ench"); - } + JewelryNBT.removeEntity(stack); + } + if (JewelryNBT.isJewelX(stack, new ItemStack(Item.enderPearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Block.chest)) && world.getBlockId(i, j, k) == Block.chest.blockID) JewelryNBT.addBlockCoordonates(stack, i, j, k); } return true; } @@ -359,32 +234,15 @@ public class ItemRing extends ItemBase public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { amplifier = 0; - if (!world.isRemote && stack.hasTagCompound()) - { - if(stack.getTagCompound().hasKey("jewel")) - { - NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); - ItemStack jewel = new ItemStack(0, 0, 0); - jewel.readFromNBT(jewelNBT); - if(jewel.itemID == Item.diamond.itemID) amplifier = 1; - if(jewel.itemID == Item.emerald.itemID) amplifier = 2; - } - if(stack.getTagCompound().hasKey("modifier")) - { - if (entity instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)entity; - NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); - ItemStack modifier = new ItemStack(0, 0, 0); - modifier.readFromNBT(modifierNBT); - if(modifier.itemID == Item.blazePowder.itemID && entityplayer != null) - entityplayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, amplifier)); - if(modifier.itemID == Item.sugar.itemID && entityplayer != null) - entityplayer.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, amplifier)); - if(modifier.itemID == Item.pickaxeIron.itemID && entityplayer != null) - entityplayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, amplifier)); - } - } + if (!world.isRemote){ + EntityPlayer entityplayer = (EntityPlayer) entity; + if (JewelryNBT.isJewelX(stack, new ItemStack(Item.diamond))) amplifier = 1; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Item.emerald))) amplifier = 2; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Item.netherStar))) amplifier = 7; + + if (JewelryNBT.isModifierX(stack, new ItemStack(Item.blazePowder)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, amplifier)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.sugar)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, amplifier)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Item.pickaxeIron)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, amplifier)); } } } diff --git a/common/darkknight/jewelrycraft/item/ItemThiefGloves.java b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java index 19f1a1e..4535235 100644 --- a/common/darkknight/jewelrycraft/item/ItemThiefGloves.java +++ b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java @@ -20,7 +20,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; -public class ItemThiefGloves extends ItemBase +public class ItemThiefGloves extends Item { public Random rand; diff --git a/common/darkknight/jewelrycraft/lib/Reference.java b/common/darkknight/jewelrycraft/lib/Reference.java index 4514e5c..38d22f6 100644 --- a/common/darkknight/jewelrycraft/lib/Reference.java +++ b/common/darkknight/jewelrycraft/lib/Reference.java @@ -4,6 +4,6 @@ public class Reference { public static final String MODID = "Jewelrycraft"; public static final String MODNAME = "Jewelrycraft"; - public static final String VERSION = "1.0.0"; + public static final String VERSION = "1.2.0"; public static final String PACKET_CHANNEL = "Jewelrycraft"; } diff --git a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java index ec5271b..5fb37ba 100644 --- a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java +++ b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java @@ -57,7 +57,7 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende GL11.glRotatef(180F, 1F, 0F, 0F); GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.05F, -1.6F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); GL11.glRotatef(jt.angle, 0F, 1F, 0F); if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); @@ -82,7 +82,7 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende GL11.glRotatef(180F, 1F, 0F, 0F); GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.05F, -1.6F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); GL11.glRotatef(jt.angle, 0F, 1F, 0F); if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); @@ -107,7 +107,7 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende GL11.glRotatef(180F, 1F, 0F, 0F); GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.6F, -1.5F, -0.4F); + GL11.glTranslatef(0.55F, -1.5F, -0.45F); GL11.glRotatef(jt.angle, 0F, 1F, 0F); if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); @@ -131,7 +131,7 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende GL11.glRotatef(180F, 1F, 0F, 0F); GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(-0.6F, -1.5F, -0.4F); + GL11.glTranslatef(-0.55F, -1.5F, -0.45F); GL11.glRotatef(jt.angle, 0F, 1F, 0F); if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); diff --git a/common/darkknight/jewelrycraft/util/JewelryNBT.java b/common/darkknight/jewelrycraft/util/JewelryNBT.java index c097a49..be2f959 100644 --- a/common/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/common/darkknight/jewelrycraft/util/JewelryNBT.java @@ -2,6 +2,7 @@ package darkknight.jewelrycraft.util; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -104,6 +105,25 @@ public class JewelryNBT itemStackData.setTag("z", coords); } + public static void addBlockCoordonates(ItemStack item, int x, int y, int z) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound coords = new NBTTagCompound(); + coords.setInteger("blockX", x); + coords.setInteger("blockY", y); + coords.setInteger("blockZ", z); + itemStackData.setTag("blockX", coords); + itemStackData.setTag("blockY", coords); + itemStackData.setTag("blockZ", coords); + } + public static void addCoordonatesAndDimension(ItemStack item, double x, double y, double z, int dim, String name) { NBTTagCompound itemStackData; @@ -139,6 +159,13 @@ public class JewelryNBT } itemStackData.removeTag(tag); } + + public static void removeEntity(ItemStack item) + { + JewelryNBT.removeNBT(item, "entityID"); + JewelryNBT.removeNBT(item, "entity"); + JewelryNBT.removeNBT(item, "ench"); + } public static void addEnchantment(ItemStack item) { @@ -153,4 +180,178 @@ public class JewelryNBT itemStackData.setTag("ench", new NBTTagList("ench")); } + public static ItemStack jewel(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel")) + { + NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); + ItemStack jewel = new ItemStack(0, 0, 0); + jewel.readFromNBT(jewelNBT); + return jewel; + } + return null; + } + + public static boolean isJewelX(ItemStack stack, ItemStack jewel) + { + if(jewel(stack) != null && jewel(stack).itemID == jewel.itemID && jewel(stack).getItemDamage() == jewel.getItemDamage()) return true; + return false; + } + + public static ItemStack modifier(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("modifier")) + { + NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); + ItemStack modifier = new ItemStack(0, 0, 0); + modifier.readFromNBT(modifierNBT); + return modifier; + } + return null; + } + + public static boolean isModifierX(ItemStack stack, ItemStack modifier) + { + if(modifier(stack) != null && modifier(stack).itemID == modifier.itemID && modifier(stack).getItemDamage() == modifier.getItemDamage()) return true; + return false; + } + + public static ItemStack ingot(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("ingot")) + { + NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); + ItemStack ingot = new ItemStack(0, 0, 0); + ingot.readFromNBT(ingotNBT); + return ingot; + } + return null; + } + + public static boolean isIngotX(ItemStack stack, ItemStack ingot) + { + if(ingot(stack) != null && ingot(stack).itemID == ingot.itemID && ingot(stack).getItemDamage() == ingot.getItemDamage()) return true; + return false; + } + + public static EntityLivingBase entity(ItemStack stack, EntityPlayer player) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity")) + { + NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID"); + NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity"); + int entityID = 0; + entityID = enID.getInteger("entityID"); + EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj); + entity.readFromNBT(en); + return entity; + } + return null; + } + + public static boolean isEntityX(ItemStack stack, EntityPlayer player, EntityLivingBase entity) + { + if(entity(stack, player) != null && entity(stack, player).equals(entity)) return true; + return false; + } + + public static String dimName(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("dimName")) + { + NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimName"); + String name = dim.getString("dimName"); + return name; + } + return null; + } + + public static boolean isDimNameX(ItemStack stack, String dimName) + { + if(ingot(stack) != null && dimName(stack).equals(dimName)) return true; + return false; + } + + public static int dimension(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("dimension")) + { + NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimension"); + int dimension = dim.getInteger("dimension"); + return dimension; + } + return -2; + } + + public static boolean isDimensionX(ItemStack stack, int dimension) + { + if(dimension(stack) != -2 && dimension(stack) == dimension) return true; + return false; + } + + public static int blockCoordX(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("blockX")) + { + NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("blockX"); + int posX = x.getInteger("blockX"); + return posX; + } + return -1; + } + + public static int blockCoordY(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("blockY")) + { + NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("blockY"); + int posY = y.getInteger("blockY"); + return posY; + } + return -1; + } + + public static int blockCoordZ(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("blockZ")) + { + NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("blockZ"); + int posZ = z.getInteger("blockZ"); + return posZ; + } + return -1; + } + + public static double playerPosX(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("x")) + { + NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("x"); + double posX = x.getDouble("x"); + return posX; + } + return -1; + } + + public static double playerPosY(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("y")) + { + NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("y"); + double posY = y.getDouble("y"); + return posY; + } + return -1; + } + + public static double playerPosZ(ItemStack stack) + { + if (stack != null && stack != new ItemStack(0, 0, 0) && stack.getTagCompound().hasKey("z")) + { + NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("z"); + double posZ = z.getDouble("z"); + return posZ; + } + return -1; + } } diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java new file mode 100644 index 0000000..255d4f5 --- /dev/null +++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -0,0 +1,111 @@ +package darkknight.jewelrycraft.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.item.ItemList; + +public class JewelrycraftUtil +{ + public static ArrayList<ItemStack> modifiers = new ArrayList<ItemStack>(); + public static ArrayList<ItemStack> jewel = new ArrayList<ItemStack>(); + public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>(); + public static ArrayList<String> jamcraftPlayers = new ArrayList<String>(); + public static HashMap<ItemStack, ItemStack> combinations = new HashMap<ItemStack, ItemStack>(); + + 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)); + } + + public static void addSpecialCombinations() + { + combinations.put(new ItemStack(Item.enderPearl), new ItemStack(Block.chest)); + combinations.put(new ItemStack(Item.enderPearl), new ItemStack(Item.bed)); + combinations.put(new ItemStack(Block.obsidian), new ItemStack(Item.eyeOfEnder)); + combinations.put(new ItemStack(Item.netherStar), new ItemStack(Block.chest)); + //An ender pearl with any modifier that is not a chest or bed + combinations.put(new ItemStack(Item.enderPearl), new ItemStack(Item.itemsList.length, 0, 0)); + } + + public static void jamcrafters() + { + jamcraftPlayers.add("allout58"); + jamcraftPlayers.add("ChewBaker"); + jamcraftPlayers.add("domi1819"); + jamcraftPlayers.add("founderio"); + jamcraftPlayers.add("Ironhammer354"); + jamcraftPlayers.add("isomgirls6"); + jamcraftPlayers.add("jmjmjm439"); + jamcraftPlayers.add("Joban"); + jamcraftPlayers.add("KJ4IPS"); + jamcraftPlayers.add("Mitchellbrine"); + jamcraftPlayers.add("MrComputerGhost"); + jamcraftPlayers.add("MrKol999"); + jamcraftPlayers.add("Resinresin"); + jamcraftPlayers.add("sci4me"); + jamcraftPlayers.add("sor1n"); + jamcraftPlayers.add("theminecoder"); + jamcraftPlayers.add("YSPilot"); + jamcraftPlayers.add("direwolf20"); + } + + public static 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 static 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 static 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; + } +} diff --git a/common/darkknight/jewelrycraft/worldGen/Generation.java b/common/darkknight/jewelrycraft/worldGen/Generation.java index 64a33d4..9444e6a 100644 --- a/common/darkknight/jewelrycraft/worldGen/Generation.java +++ b/common/darkknight/jewelrycraft/worldGen/Generation.java @@ -5,7 +5,7 @@ import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.common.IWorldGenerator; -import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.block.BlockList; public class Generation implements IWorldGenerator { @@ -31,12 +31,12 @@ public class Generation implements IWorldGenerator private void generateSurface(World world, Random random, int i, int j) { - for (int k = 1; k < 4; k++) + for (int k = 0; k < 1; k++) { int x = i + random.nextInt(16); int y = 5 + random.nextInt(4); int z = j + random.nextInt(16); - world.setBlock(x, y, z, ConfigHandler.idShadowOre); + if(world.rand.nextInt(10) == 0) world.setBlock(x, y, z, BlockList.shadowOre.blockID); } } diff --git a/resources/assets/jewelrycraft/lang/en_US.lang b/resources/assets/jewelrycraft/lang/en_US.lang index 6473cfb..116ed64 100644 --- a/resources/assets/jewelrycraft/lang/en_US.lang +++ b/resources/assets/jewelrycraft/lang/en_US.lang @@ -1,38 +1,38 @@ -item.jewelrycraft.thiefGloves.name=Thiefing Gloves -item.jewelrycraft.ingotShadow.name=Shadow Ingot -item.jewelrycraft.mold.ingot.name=Ingot Mold -item.jewelrycraft.mold.ring.name=Ring Mold -item.jewelrycraft.mold.necklace.name=Necklace Mold -item.jewelrycraft.mold.clayIngot.name=Clay Ingot Mold -item.jewelrycraft.mold.clayRing.name=Clay Ring Mold -item.jewelrycraft.mold.clayNecklace.name=Clay Necklace Mold -item.jewelrycraft.ring.name=Ring -tile.jewelrycraft.oreShadow.name=Shadow Ore -tile.jewelrycraft.smelter.name=Smelter -tile.jewelrycraft.molder.name=Molder -tile.jewelrycraft.jewelCraftingTable.name=Jeweler's Crafting Table +item.Jewelrycraft.thiefGloves.name=Thiefing Gloves +item.Jewelrycraft.ingotShadow.name=Shadow Ingot +item.Jewelrycraft.mold.ingot.name=Ingot Mold +item.Jewelrycraft.mold.ring.name=Ring Mold +item.Jewelrycraft.mold.necklace.name=Necklace Mold +item.Jewelrycraft.mold.clayIngot.name=Clay Ingot Mold +item.Jewelrycraft.mold.clayRing.name=Clay Ring Mold +item.Jewelrycraft.mold.clayNecklace.name=Clay Necklace Mold +item.Jewelrycraft.ring.name=Ring +tile.Jewelrycraft.oreShadow.name=Shadow Ore +tile.Jewelrycraft.smelter.name=Smelter +tile.Jewelrycraft.molder.name=Molder +tile.Jewelrycraft.jewelCraftingTable.name=Jeweler's Crafting Table itemGroup.JewelryCraft=Jewelrycraft -chatmessage.jewelrycraft.molder.addedmold=Added %s to molder. -chatmessage.jewelrycraft.molder.metaliscooling=Molten metal is cooling... -chatmessage.jewelrycraft.molder.moldisempty=Mold is currently empty. -chatmessage.jewelrycraft.molder.moldismissing=Molder does not contain a mold. -chatmessage.jewelrycraft.molder.hasmoltenmetal=You can't remove the mold. It contains molten metal! -chatmessage.jewelrycraft.smelter.alreadyhasingot=The Smelter already contains a %s -chatmessage.jewelrycraft.smelter.hasmolteningot=The Smelter contains a molten %s -chatmessage.jewelrycraft.smelter.itemneedstobeingot=The item needs to be an ingot! -chatmessage.jewelrycraft.smelter.itemrenamedtoingot=Nice try, but renaming it to an ingot doesn't make it an ingot :p You can't fool me player! -chatmessage.jewelrycraft.smelter.molderhasmoltenmetal=The Molder already has molten metal in it! -chatmessage.jewelrycraft.smelter.molderhasnomold=The Molder doesn't have a mold in it! You might as well pour this stuff on the ground, eh? -chatmessage.jewelrycraft.smelter.modlerhasitem=The Molder contains an item in it. Now you wouldn't want it to be destroyed, would you? -chatmessage.jewelrycraft.smelter.molderismissing=You need a Molder in front of this block in order to pour the molten metal! -chatmessage.jewelrycraft.smelter.nowsmeltingingot=Smelter is now smelting a %s. -chatmessage.jewelrycraft.smelter.metalismelting=%s is being melted. -chatmessage.jewelrycraft.smelter.empty=The Smelter is empty. -chatmessage.jewelrycraft.table.hasenditem=First take out the crafted jewel before inserting new stuff. -chatmessage.jewelrycraft.table.missingjewelryandmodifierorjewel=You need a ring and a modifier or a jewel. -chatmessage.jewelrycraft.table.missingjewelry=You're missing a piece of jewelry. -chatmessage.jewelrycraft.table.missingmodifierorjewel=You need a modifier or a jewel. -chatmessage.jewelrycraft.table.iscrafting=The %s is being modified. -chatmessage.jewelrycraft.table.jewelrymodifiedfull=This piece of jewelry is already modified at maxium. You can't modify it anymore! -chatmessage.jewelrycraft.table.jewelrycontainsmodifier=The piece of jewelry already contains a modifier. -chatmessage.jewelrycraft.table.jewelrycontainsjewel=The piece of jewelry already contains a jewel.
\ No newline at end of file +chatmessage.Jewelrycraft.molder.addedmold=Added %s to molder. +chatmessage.Jewelrycraft.molder.metaliscooling=Molten metal is cooling... +chatmessage.Jewelrycraft.molder.moldisempty=Mold is currently empty. +chatmessage.Jewelrycraft.molder.moldismissing=Molder does not contain a mold. +chatmessage.Jewelrycraft.molder.hasmoltenmetal=You can't remove the mold. It contains molten metal! +chatmessage.Jewelrycraft.smelter.alreadyhasingot=The Smelter already contains a %s +chatmessage.Jewelrycraft.smelter.hasmolteningot=The Smelter contains a molten %s +chatmessage.Jewelrycraft.smelter.itemneedstobeingot=The item needs to be an ingot! +chatmessage.Jewelrycraft.smelter.itemrenamedtoingot=Nice try, but renaming it to an ingot doesn't make it an ingot :p You can't fool me player! +chatmessage.Jewelrycraft.smelter.molderhasmoltenmetal=The Molder already has molten metal in it! +chatmessage.Jewelrycraft.smelter.molderhasnomold=The Molder doesn't have a mold in it! You might as well pour this stuff on the ground, eh? +chatmessage.Jewelrycraft.smelter.modlerhasitem=The Molder contains an item in it. Now you wouldn't want it to be destroyed, would you? +chatmessage.Jewelrycraft.smelter.molderismissing=You need a Molder in front of this block in order to pour the molten metal! +chatmessage.Jewelrycraft.smelter.nowsmeltingingot=Smelter is now smelting a %s. +chatmessage.Jewelrycraft.smelter.metalismelting=%s is being melted. +chatmessage.Jewelrycraft.smelter.empty=The Smelter is empty. +chatmessage.Jewelrycraft.table.hasenditem=First take out the crafted jewel before inserting new stuff. +chatmessage.Jewelrycraft.table.missingjewelryandmodifierorjewel=You need a ring and a modifier or a jewel. +chatmessage.Jewelrycraft.table.missingjewelry=You're missing a piece of jewelry. +chatmessage.Jewelrycraft.table.missingmodifierorjewel=You need a modifier or a jewel. +chatmessage.Jewelrycraft.table.iscrafting=The %s is being modified. +chatmessage.Jewelrycraft.table.jewelrymodifiedfull=This piece of jewelry is already modified at maxium. You can't modify it anymore! +chatmessage.Jewelrycraft.table.jewelrycontainsmodifier=The piece of jewelry already contains a modifier. +chatmessage.Jewelrycraft.table.jewelrycontainsjewel=The piece of jewelry already contains a jewel.
\ No newline at end of file diff --git a/resources/assets/jewelrycraft/textures/gui/chest_ring.png b/resources/assets/jewelrycraft/textures/gui/chest_ring.png Binary files differnew file mode 100644 index 0000000..66f00cc --- /dev/null +++ b/resources/assets/jewelrycraft/textures/gui/chest_ring.png |
