-
Notifications
You must be signed in to change notification settings - Fork 754
/
RedstoneMachineItem.java
75 lines (65 loc) · 2.27 KB
/
RedstoneMachineItem.java
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
74
75
package tconstruct.items.blocks;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
public class RedstoneMachineItem extends ItemBlock
{
public static final String blockType[] = { "drawbridge", "firestarter", "advdrawbridge" };
public RedstoneMachineItem(int id)
{
super(id);
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata (int meta)
{
return meta;
}
public String getUnlocalizedName (ItemStack itemstack)
{
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1);
return (new StringBuilder()).append("block.").append(blockType[pos]).toString();
}
@Override
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack.hasTagCompound() && stack.getItemDamage() == 0)
{
NBTTagCompound contentTags = stack.getTagCompound().getCompoundTag("Contents");
if (contentTags != null)
{
ItemStack contents = ItemStack.loadItemStackFromNBT(contentTags);
if (contents != null)
{
list.add("Inventory: " + contents.getDisplayName());
list.add("Amount: " + contents.stackSize);
}
}
NBTTagCompound camoTag = stack.getTagCompound().getCompoundTag("Camoflauge");
if (camoTag != null)
{
ItemStack camo = ItemStack.loadItemStackFromNBT(camoTag);
if (camo != null)
list.add("Camoflauge: " + camo.getDisplayName());
}
if (stack.getTagCompound().hasKey("Placement"))
{
String string = getDirectionString(stack.getTagCompound().getByte("Placement"));
list.add("Placement Direction: " + string);
}
}
}
String getDirectionString (byte key)
{
if (key == 0)
return ("Up");
if (key == 1)
return ("Right");
if (key == 2)
return ("Down");
return "Left";
}
}