-
Notifications
You must be signed in to change notification settings - Fork 754
/
ShortBow.java
114 lines (97 loc) · 2.8 KB
/
ShortBow.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
package boni.tinkersweaponry.weapons;
import boni.tinkersweaponry.TinkerWeaponry;
import boni.tinkersweaponry.ammo.ArrowAmmo;
import boni.tinkersweaponry.library.weaponry.BowBaseAmmo;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tconstruct.tools.TinkerTools;
public class ShortBow extends BowBaseAmmo {
public ShortBow() {
super(0, "Shortbow");
}
@Override
protected float windupModifier(ItemStack itemStack) {
return 0.9f; // SHORT bows have a SHORTER windup because they're SHORT. hahahaha.... get it?
}
@Override
public float minAccuracy(ItemStack itemStack) {
return 1;
}
@Override
public float maxAccuracy(ItemStack itemStack) {
return 1;
}
@Override
protected Entity createProjectile(ItemStack arrows, World world, EntityPlayer player, float speed, float accuracy) {
if(arrows.getItem() instanceof ArrowAmmo)
{
// modify accuraccy of the arrow depending on its accuraccy and weight
NBTTagCompound tags = arrows.getTagCompound().getCompoundTag("InfiTool");
float matAccuracy = tags.getFloat("Accuracy");
float weight = tags.getFloat("Mass");
// weight influences the accuracy too, but only a little bit.
accuracy += ((100f-matAccuracy)/10f)/(weight);
if(accuracy < 0)
accuracy = 0;
}
return super.createProjectile(arrows, world, player, speed, accuracy);
}
@Override
public String getIconSuffix (int partType)
{
switch (partType)
{
case 0:
return "_bow_top";
case 1:
return "_bowstring_broken";
case 2:
return "_bowstring";
case 3:
return "_bow_bottom";
default:
return "";
}
}
@Override
public String getEffectSuffix ()
{
return "_bow_effect";
}
@Override
public String getDefaultFolder ()
{
return "shortbow";
}
@Override
public int getPartAmount() {
return 3;
}
@Override
protected boolean animateLayer(int renderPass) {
return renderPass < 3;
}
@Override
public Item getHeadItem ()
{
return TinkerWeaponry.partBowLimb;
}
@Override
public Item getHandleItem ()
{
return TinkerTools.bowstring;
}
@Override
public Item getAccessoryItem ()
{
return TinkerWeaponry.partBowLimb;
}
@Override
public String[] getTraits() {
return new String[] {"weapon", "ranged", "bow"};
}
}