From d83ae9e5dff05ec876050fdc64e597b1b54ecd3d Mon Sep 17 00:00:00 2001 From: bspkrs Date: Mon, 16 Dec 2013 23:44:45 -0500 Subject: last ditch effort to get crafting table working --- .../block/BlockJewelrsCraftingTable.java | 56 ++++++++++------------ common/darkknight/jewelrycraft/item/ItemRing.java | 13 ++--- .../tileentity/TileEntityJewelrsCraftingTable.java | 18 ++++--- 3 files changed, 42 insertions(+), 45 deletions(-) (limited to 'common') diff --git a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index bcbf7a3..b24f69d 100644 --- a/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -5,46 +5,39 @@ 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; -import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.StatCollector; -import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemRing; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; public class BlockJewelrsCraftingTable extends BlockContainer { - Random rand = new Random(); - int modifiers[] = new int[] {Item.blazePowder.itemID}; - int effects[] = new int[] {12}; - + Random rand = new Random(); + int modifiers[] = new int[] { Item.blazePowder.itemID }; + int effects[] = new int[] { 12 }; + protected BlockJewelrsCraftingTable(int par1, Material par2Material) { super(par1, par2Material); this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); } - + @Override public TileEntity createNewTileEntity(World world) { return new TileEntityJewelrsCraftingTable(); } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { @@ -54,23 +47,23 @@ public class BlockJewelrsCraftingTable extends BlockContainer { if (!te.hasJewel && item != null && item.getItem().itemID == ItemList.ring.itemID) { - te.jewel = item; + te.jewel = item.copy(); te.hasJewel = true; --item.stackSize; } if (!te.hasModifier && item != null && item.getItem().itemID == modifiers[0]) { - te.modifier = item; + te.modifier = item.copy(); te.hasModifier = true; --item.stackSize; - } - + } + if (te.hasModifier && entityPlayer.isSneaking()) { entityPlayer.inventory.addItemStackToInventory(new ItemStack(te.modifier.itemID, 1, te.modifier.getItemDamage())); te.modifier = new ItemStack(0, 0, 0); te.hasModifier = false; - } + } if (te.hasJewel && entityPlayer.isSneaking()) { entityPlayer.inventory.addItemStackToInventory(new ItemStack(te.jewel.itemID, 1, te.jewel.getItemDamage())); @@ -81,57 +74,56 @@ public class BlockJewelrsCraftingTable extends BlockContainer } return true; } - + public void giveJewelToPlayer(TileEntityJewelrsCraftingTable cf, EntityPlayer player, ItemStack item, ItemStack modifier) { if (item != null) { - //ItemRing.addEffect(item, new PotionEffect(12, 12)); - //player.inventory.addItemStackToInventory(item); + // ItemRing.addEffect(item, new PotionEffect(Potion.fireResistance.id, 120)); player.inventory.addItemStackToInventory(item); } } - + @Override public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) { TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getBlockTileEntity(i, j, k); - if(te != null) + if (te != null) { - if(te.hasEndItem) + if (te.hasEndItem) { giveJewelToPlayer(te, player, te.endItem, te.modifier); te.endItem = new ItemStack(0, 0, 0); te.hasEndItem = false; } - else if(!te.hasModifier && !te.hasJewel) + else if (!te.hasModifier && !te.hasJewel && !world.isRemote) player.addChatMessage("You need a ring and a modifier"); - else if(!te.hasJewel) + else if (!te.hasJewel && !world.isRemote) player.addChatMessage("You're missing a ring"); - else if(!te.hasModifier) + else if (!te.hasModifier && !world.isRemote) player.addChatMessage("You need a modifier"); te.timer = 5; } } - + @Override public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override public int getRenderType() { return -1; } - + @Override public void registerIcons(IconRegister icon) { diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 8953b9a..aa23da3 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -75,14 +75,15 @@ public class ItemRing extends ItemBase } } - public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) + @Override + public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) { - if(stack.hasTagCompound() && stack.getTagCompound().hasKey("effect")) + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("effect") && !par2World.isRemote) { - NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); - PotionEffect effect = new PotionEffect(0, 0); - effect.readCustomPotionEffectFromNBT(effectNBT); - ((EntityPlayer)par3Entity).addPotionEffect(effect); + // NBTTagCompound effectNBT = (NBTTagCompound) stack.getTagCompound().getTag("effect"); + // PotionEffect effect = new PotionEffect(0, 0); + // effect.readCustomPotionEffectFromNBT(effectNBT); + // ((EntityPlayer) par3Entity).addPotionEffect(effect); } } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 7d24c21..633c4fd 100644 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -11,7 +11,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity { public boolean hasJewel, hasModifier, hasEndItem; public ItemStack jewel, modifier, endItem; - public int timer; + public int timer; public TileEntityJewelrsCraftingTable() { @@ -59,30 +59,34 @@ public class TileEntityJewelrsCraftingTable extends TileEntity this.endItem.readFromNBT(nbt.getCompoundTag("endItem")); } + @Override public void updateEntity() { super.updateEntity(); - if(this.hasJewel && this.hasEndItem) + if (this.hasJewel && this.hasModifier && !this.hasEndItem) { - if(timer > 0) timer--; + if (timer > 0) + timer--; System.out.println(timer); - if(timer == 0) + if (timer == 0) { this.hasEndItem = true; - this.endItem = jewel; + this.endItem = jewel.copy(); this.hasJewel = false; - this.jewel = new ItemStack(0, 0, 0); + // this.jewel = new ItemStack(0, 0, 0); this.hasModifier = false; - this.modifier = new ItemStack(0, 0, 0); + // this.modifier = new ItemStack(0, 0, 0); } } } + @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { readFromNBT(pkt.data); } + @Override public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); -- cgit v1.2.3