-
Notifications
You must be signed in to change notification settings - Fork 754
/
ThrowingKnife.java
112 lines (96 loc) · 2.89 KB
/
ThrowingKnife.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
package tconstruct.weaponry.weapons;
import net.minecraft.client.entity.EntityPlayerSP;
import tconstruct.weaponry.client.CrosshairType;
import tconstruct.weaponry.entity.ThrowingKnifeEntity;
import tconstruct.library.weaponry.AmmoWeapon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import tconstruct.tools.TinkerTools;
public class ThrowingKnife extends AmmoWeapon {
public ThrowingKnife() {
super(1, "throwingknife");
}
@Override
public int getPartAmount() {
return 2;
}
@Override
public String getIconSuffix(int partType) {
switch (partType)
{
case 0:
return "_knife_blade";
case 1:
return ""; // no broken, since it runs out of ammo
case 2:
return "_knife_handle";
default:
return "";
}
}
@Override
public String getEffectSuffix() {
return "_knife_effect";
}
@Override
public String getDefaultFolder() {
return "throwingknife";
}
@Override
public Item getHeadItem() {
return TinkerTools.knifeBlade;
}
@Override
public Item getAccessoryItem() {
return null;
}
@Override
public int getWindupTime(ItemStack itemStack) { return 15; } // 1 1/2 seconds
@Override
public float getMinWindupProgress(ItemStack itemStack) {
return 0.6f;
}
@Override
public float maxAccuracy(ItemStack itemStack) {
return 1f;
}
@Override
public float minAccuracy(ItemStack itemStack) {
return 10f;
}
@Override
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
return new ThrowingKnifeEntity(world, player, getProjectileSpeed(), accuracy, reference);
}
@Override
public float getProjectileSpeed() {
return 1.5f;
}
@SideOnly(Side.CLIENT)
@Override
public CrosshairType getCrosshairType() {
return CrosshairType.SPIKE;
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
// aiming with throwing knives slows down much less than with a bow
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 *= 3.0F;
player.movementInput.moveStrafe *= 3.0F;
}
}
}
}