blob: 77e06c7904cd41981cd5b5e8d48a3a0c6823eef8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/**
*
*/
package darkknight.jewelrycraft.tileentity;
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;
}
@Override
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);
}
}
|