diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-17 01:10:07 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-17 01:10:07 +0200 |
| commit | e66f86a8624a5504fb1b389982883be9ebe6a092 (patch) | |
| tree | 4dcc23f3589f2b2f48116fbe8ac8410020c7deef | |
| parent | 766dafe80bdf9d2fe338346971fde1b87d0b7ad8 (diff) | |
Final commit, couldn't make the bench work, so I will send it as it is
4 files changed, 47 insertions, 25 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index 5965ccd..bcbf7a3 100644 --- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -5,6 +5,7 @@ import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -81,25 +82,12 @@ public class BlockJewelrsCraftingTable extends BlockContainer return true; } - @Override - public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int par5) - { - } - - @Override - public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion) - { - onBlockDestroyedByPlayer(world, i, j, k, 0); - } - public void giveJewelToPlayer(TileEntityJewelrsCraftingTable cf, EntityPlayer player, ItemStack item, ItemStack modifier) { if (item != null) { - if (modifier.itemID == Item.blazePowder.itemID) - { - ItemRing.addEffect(item, new PotionEffect(12, 12)); - } + //ItemRing.addEffect(item, new PotionEffect(12, 12)); + //player.inventory.addItemStackToInventory(item); player.inventory.addItemStackToInventory(item); } } @@ -108,20 +96,21 @@ public class BlockJewelrsCraftingTable extends BlockContainer public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) { TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getBlockTileEntity(i, j, k); - if(te != null && !world.isRemote) + if(te != null) { - if(te.hasJewel && te.hasModifier) + if(te.hasEndItem) { - giveJewelToPlayer(te, player, te.jewel, te.modifier); - te.jewel = new ItemStack(0, 0, 0); - te.hasJewel = false; - te.modifier = new ItemStack(0, 0, 0); - te.hasModifier = false; + giveJewelToPlayer(te, player, te.endItem, te.modifier); + te.endItem = new ItemStack(0, 0, 0); + te.hasEndItem = false; } + else if(!te.hasModifier && !te.hasJewel) + player.addChatMessage("You need a ring and a modifier"); else if(!te.hasJewel) player.addChatMessage("You're missing a ring"); else if(!te.hasModifier) player.addChatMessage("You need a modifier"); + te.timer = 5; } } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 8d6b83d..8953b9a 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -77,7 +77,7 @@ public class ItemRing extends ItemBase public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(stack.getTagCompound().hasKey("effect")) + if(stack.hasTagCompound() && stack.getTagCompound().hasKey("effect")) { NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); PotionEffect effect = new PotionEffect(0, 0); diff --git a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java index 7d187a2..3f466f4 100644 --- a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.recipes; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @@ -16,6 +17,11 @@ public class CraftingRecipes if (!isInitialized) { GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Block.cloth, 1, 15)); + GameRegistry.addRecipe(new ItemStack(ItemList.molds, 1, 0), "x", "y", 'x', Item.ingotGold, 'y', Block.cobblestone); + GameRegistry.addRecipe(new ItemStack(ItemList.molds, 1, 1), "x x", "xyx", "x x", 'x', Item.ingotGold, 'y', Block.cobblestone); + GameRegistry.addRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Block.cobblestone); + GameRegistry.addRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Block.cobblestone, 'y', Item.bucketEmpty, 'z', Item.bucketLava); + GameRegistry.addRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Block.planks, 'y', Block.cobblestone); GameRegistry.addSmelting(BlockList.shadowOre.blockID, new ItemStack(ItemList.shadowIngot), 1.5f); isInitialized = true; diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 5cce837..7d24c21 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -9,15 +9,19 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityJewelrsCraftingTable extends TileEntity { - public boolean hasJewel, hasModifier; - public ItemStack jewel, modifier; + public boolean hasJewel, hasModifier, hasEndItem; + public ItemStack jewel, modifier, endItem; + public int timer; public TileEntityJewelrsCraftingTable() { this.jewel = new ItemStack(0, 0, 0); this.modifier = new ItemStack(0, 0, 0); + this.endItem = new ItemStack(0, 0, 0); this.hasJewel = false; this.hasModifier = false; + this.hasEndItem = false; + this.timer = 0; } @Override @@ -26,12 +30,17 @@ public class TileEntityJewelrsCraftingTable extends TileEntity super.writeToNBT(nbt); nbt.setBoolean("hasJewel", hasJewel); nbt.setBoolean("hasModifier", hasModifier); + nbt.setBoolean("hasEndItem", hasEndItem); + nbt.setInteger("timer", timer); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag1 = new NBTTagCompound(); + NBTTagCompound tag2 = new NBTTagCompound(); this.jewel.writeToNBT(tag); nbt.setCompoundTag("jewel", tag); this.modifier.writeToNBT(tag1); nbt.setCompoundTag("modifier", tag1); + this.endItem.writeToNBT(tag2); + nbt.setCompoundTag("endItem", tag2); } @Override @@ -40,15 +49,33 @@ public class TileEntityJewelrsCraftingTable extends TileEntity super.readFromNBT(nbt); this.hasJewel = nbt.getBoolean("hasJewel"); this.hasModifier = nbt.getBoolean("hasModifier"); + this.hasEndItem = nbt.getBoolean("hasEndItem"); + this.timer = nbt.getInteger("timer"); this.jewel = new ItemStack(0, 0, 0); this.jewel.readFromNBT(nbt.getCompoundTag("jewel")); this.modifier = new ItemStack(0, 0, 0); this.modifier.readFromNBT(nbt.getCompoundTag("modifier")); + this.endItem = new ItemStack(0, 0, 0); + this.endItem.readFromNBT(nbt.getCompoundTag("endItem")); } public void updateEntity() { super.updateEntity(); + if(this.hasJewel && this.hasEndItem) + { + if(timer > 0) timer--; + System.out.println(timer); + if(timer == 0) + { + this.hasEndItem = true; + this.endItem = jewel; + this.hasJewel = false; + this.jewel = new ItemStack(0, 0, 0); + this.hasModifier = false; + this.modifier = new ItemStack(0, 0, 0); + } + } } public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) |
