diff options
Diffstat (limited to 'java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java')
| -rw-r--r-- | java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java | 153 |
1 files changed, 73 insertions, 80 deletions
diff --git a/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 8fcf62f..c148bd0 100644 --- a/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -1,21 +1,13 @@ package darkknight.jewelrycraft.tileentity; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.particles.EntityShadowsFX; import darkknight.jewelrycraft.util.JewelryNBT; import darkknight.jewelrycraft.util.JewelrycraftUtil; @@ -26,21 +18,27 @@ public class TileEntityJewelrsCraftingTable extends TileEntity public int carving, effect; public float angle; + /** + * + */ public TileEntityJewelrsCraftingTable() { - this.jewelry = new ItemStack(Item.getItemById(0), 0, 0); - this.endItem = new ItemStack(Item.getItemById(0), 0, 0); - this.gem = new ItemStack(Item.getItemById(0), 0, 0); - this.hasJewelry = false; - this.hasEndItem = false; - this.hasGem = false; - this.crafting = false; - this.carving = 0; - this.effect = 0; - this.angle = 0; - this.isDirty = false; + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + endItem = new ItemStack(Item.getItemById(0), 0, 0); + gem = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelry = false; + hasEndItem = false; + hasGem = false; + crafting = false; + carving = 0; + effect = 0; + angle = 0; + isDirty = false; } + /** + * @param nbt + */ @Override public void writeToNBT(NBTTagCompound nbt) { @@ -52,92 +50,79 @@ public class TileEntityJewelrsCraftingTable extends TileEntity nbt.setInteger("timer", carving); nbt.setInteger("effect", effect); nbt.setFloat("angle", angle); - NBTTagCompound tag1 = new NBTTagCompound(); NBTTagCompound tag2 = new NBTTagCompound(); NBTTagCompound tag3 = new NBTTagCompound(); - - this.jewelry.writeToNBT(tag1); + jewelry.writeToNBT(tag1); nbt.setTag("jewelry", tag1); - this.endItem.writeToNBT(tag2); + endItem.writeToNBT(tag2); nbt.setTag("endItem", tag2); - this.gem.writeToNBT(tag3); + gem.writeToNBT(tag3); nbt.setTag("jewel", tag3); } + /** + * @param nbt + */ @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - this.hasJewelry = nbt.getBoolean("hasJewelry"); - this.hasEndItem = nbt.getBoolean("hasEndItem"); - this.hasGem = nbt.getBoolean("hasJewel"); - this.crafting = nbt.getBoolean("crafting"); - - this.carving = nbt.getInteger("timer"); - this.effect = nbt.getInteger("effect"); - this.angle = nbt.getFloat("angle"); - this.jewelry = new ItemStack(Item.getItemById(0), 0, 0); - this.jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); - this.endItem = new ItemStack(Item.getItemById(0), 0, 0); - this.endItem.readFromNBT(nbt.getCompoundTag("endItem")); - this.gem = new ItemStack(Item.getItemById(0), 0, 0); - this.gem.readFromNBT(nbt.getCompoundTag("jewel")); + hasJewelry = nbt.getBoolean("hasJewelry"); + hasEndItem = nbt.getBoolean("hasEndItem"); + hasGem = nbt.getBoolean("hasJewel"); + crafting = nbt.getBoolean("crafting"); + carving = nbt.getInteger("timer"); + effect = nbt.getInteger("effect"); + angle = nbt.getFloat("angle"); + jewelry = new ItemStack(Item.getItemById(0), 0, 0); + jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); + endItem = new ItemStack(Item.getItemById(0), 0, 0); + endItem.readFromNBT(nbt.getCompoundTag("endItem")); + gem = new ItemStack(Item.getItemById(0), 0, 0); + gem.readFromNBT(nbt.getCompoundTag("jewel")); } + /** + * + */ @Override public void updateEntity() { super.updateEntity(); - if (isDirty) - { + if (isDirty){ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); isDirty = false; } if (angle < 360F) angle += 3F; else angle = 0F; - - if (this.hasJewelry && this.hasGem && !this.hasEndItem && crafting) - { + if (hasJewelry && hasGem && !hasEndItem && crafting){ if (carving > 0) carving--; - if (crafting) - { - for (int l = 0; l < ConfigHandler.jewelryCraftingTime / (carving + 2); ++l) - { - if (worldObj.rand.nextInt(10) == 0) this.worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F); - if (this.getBlockMetadata() == 0) this.worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); - if (this.getBlockMetadata() == 1) this.worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double) yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - if (this.getBlockMetadata() == 2) this.worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D); - if (this.getBlockMetadata() == 3) this.worldObj.spawnParticle("instantSpell", xCoord + 0.2F, (double) yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - - } + if (crafting) for(int l = 0; l < ConfigHandler.jewelryCraftingTime / (carving + 2); ++l){ + if (worldObj.rand.nextInt(10) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F); + if (getBlockMetadata() == 0) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 1) worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 2) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D); + if (getBlockMetadata() == 3) worldObj.spawnParticle("instantSpell", xCoord + 0.2F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); } - if (carving == 0) - { - this.hasEndItem = true; - this.endItem = jewelry.copy(); - if (hasGem && gem != new ItemStack(Item.getItemById(0), 0, 0)) - { - if (!JewelryNBT.hasTag(jewelry, "gem")) - { - JewelryNBT.addGem(endItem, gem); - this.hasGem = false; - this.gem = new ItemStack(Item.getItemById(0), 0, 0); - } - else - { - ItemStack aux = JewelryNBT.gem(jewelry); - JewelryNBT.addGem(endItem, gem); - if(JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy(); - else - { - this.hasGem = false; - this.gem = new ItemStack(Item.getItemById(0), 0, 0); - } + if (carving == 0){ + hasEndItem = true; + endItem = jewelry.copy(); + if (hasGem && gem != new ItemStack(Item.getItemById(0), 0, 0)) if (!JewelryNBT.hasTag(jewelry, "gem")){ + JewelryNBT.addGem(endItem, gem); + hasGem = false; + gem = new ItemStack(Item.getItemById(0), 0, 0); + }else{ + ItemStack aux = JewelryNBT.gem(jewelry); + JewelryNBT.addGem(endItem, gem); + if (JewelrycraftUtil.rand.nextBoolean()) gem = aux.copy(); + else{ + hasGem = false; + gem = new ItemStack(Item.getItemById(0), 0, 0); } } - this.hasJewelry = false; - this.jewelry = new ItemStack(Item.getItemById(0), 0, 0); + hasJewelry = false; + jewelry = new ItemStack(Item.getItemById(0), 0, 0); carving = -1; crafting = false; isDirty = true; @@ -145,13 +130,21 @@ public class TileEntityJewelrsCraftingTable extends TileEntity } } + /** + * @return + */ + @Override public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); - this.writeToNBT(nbttagcompound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); } + /** + * @param net + * @param packet + */ @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { |
