-
Notifications
You must be signed in to change notification settings - Fork 754
/
BoltAmmo.java
122 lines (103 loc) · 3.41 KB
/
BoltAmmo.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package tconstruct.weaponry.ammo;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.CustomMaterial;
import tconstruct.library.tools.FletchingMaterial;
import tconstruct.library.tools.FletchlingLeafMaterial;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.library.tools.DualMaterialToolPart;
import tconstruct.library.weaponry.AmmoItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import tconstruct.library.crafting.ToolBuilder;
import java.util.List;
public class BoltAmmo extends AmmoItem {
public BoltAmmo() {
super(0, "Bolts");
}
@Override
public String getIconSuffix(int partType) {
switch (partType)
{
case 0:
return "_bolt_head";
case 1:
return ""; // Doesn't break
case 2:
return "_bolt_shaft";
case 3:
return "_bolt_fletching";
default:
return "";
}
}
@Override
public String getEffectSuffix() {
return "_bolt_effect";
}
@Override
public String getDefaultFolder() {
return "bolt";
}
@Override
public void registerPartPaths (int index, String[] location)
{
headStrings.put(index, location[0]);
handleStrings.put(index, location[2]);
}
@Override
public void registerAlternatePartPaths (int index, String[] location)
{
accessoryStrings.put(index, location[3]);
}
@Override
public Item getHeadItem() {
return TinkerWeaponry.partBolt;
}
@Override
public Item getHandleItem() {
return TinkerWeaponry.partBolt;
}
@Override
public Item getAccessoryItem() {
return TinkerWeaponry.fletching;
}
@Override
public String[] getTraits ()
{
return new String[] { "ammo", "projectile", "weapon" };
}
@Override
public void buildTool (int id, String name, List list)
{
if(TConstructRegistry.getArrowMaterial(id) == null)
return;
// dual material head: we use wooden shafts
ItemStack headStack = DualMaterialToolPart.createDualMaterial(getHeadItem(), 0, id); // wooden shaft, material head
ItemStack handleStack = new ItemStack(getAccessoryItem(), 1, 0); // feather Fletchling
//ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling
ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, null, null, "");
if (tool != null)
{
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
}
}
@Override
protected int getDefaultColor(int renderPass, int materialID) {
if(renderPass != 2)
return super.getDefaultColor(renderPass, materialID);
CustomMaterial mat = TConstructRegistry.getCustomMaterial(materialID, FletchingMaterial.class);
if(mat == null)
mat = TConstructRegistry.getCustomMaterial(materialID, FletchlingLeafMaterial.class);
if(mat == null)
return 0xffffff;
return mat.color;
}
// fix tooltip custom materials
@Override
public String getAbilityNameForType(int type, int part) {
if(part >= 2) // only head and handle have ability
return "";
return super.getAbilityNameForType(type, part);
}
}