From 0ef6a00aa79f022e5bd56b3f77e6861bbecf6d94 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 13 Aug 2015 21:12:11 +0100 Subject: Added a new structure, a new curse, achievements, challenges, curses entry in the guide; reworked liquids to be tile entities, cleaned the structures code, potion code and... you know what? I improved and changed so much stuff that I literally forgot what I did... --- .../tileentity/TileEntityMoltenMetal.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java (limited to 'src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java') diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java new file mode 100644 index 0000000..5da722a --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMoltenMetal.java @@ -0,0 +1,66 @@ +/** + * + */ +package darkknight.jewelrycraft.tileentity; + +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.tileentity.TileEntity; + +/** + * @author Sorin + */ +public class TileEntityMoltenMetal extends TileEntity { + private ItemStack metal; + + public TileEntityMoltenMetal() { + metal = null; + } + + public boolean canUpdate() { + return false; + } + + public void setMetal(ItemStack metal) { + if(metal != null) this.metal = metal.copy(); + else this.metal = null; + } + + public ItemStack getMetal() { + return metal; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + if (metal != null) { + NBTTagCompound tag = new NBTTagCompound(); + metal.writeToNBT(tag); + nbt.setTag("metal", tag); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + if (nbt.hasKey("metal")) setMetal(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("metal"))); + else metal = null; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} -- cgit v1.2.3