-
Notifications
You must be signed in to change notification settings - Fork 753
/
ShortBow.java
124 lines (108 loc) · 3.26 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
115
116
117
118
119
120
121
122
123
124
package tconstruct.weaponry.weapons;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.entity.EntityPlayerSP;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.weaponry.ammo.ArrowAmmo;
import tconstruct.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;
public class ShortBow extends BowBaseAmmo {
public ShortBow() {
super(0, "Shortbow");
}
@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, float windup) {
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, windup);
}
@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 TinkerWeaponry.bowstring;
}
@Override
public Item getAccessoryItem ()
{
return TinkerWeaponry.partBowLimb;
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
// shortbows are smaller and more mobile than longbows
super.onUpdate(stack, world, entity, par4, par5);
if (entity instanceof EntityPlayerSP)
{
EntityPlayerSP player = (EntityPlayerSP) entity;
ItemStack usingItem = player.getItemInUse();
if (usingItem != null && usingItem.getItem() == this)
{
player.movementInput.moveForward *= 1.5F;
player.movementInput.moveStrafe *= 1.5F;
}
}
}
}