-
Notifications
You must be signed in to change notification settings - Fork 755
/
Weapon.java
129 lines (111 loc) · 3.47 KB
/
Weapon.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
125
126
127
128
129
package tconstruct.library.tools;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class Weapon extends ToolCore
{
public Weapon(int baseDamage)
{
super(baseDamage);
}
protected float baseSpeed ()
{
return 1.5f;
}
protected float effectiveSpeed ()
{
return 15f;
}
@Override
public float getStrVsBlock (ItemStack stack, Block block, int meta)
{
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken"))
return 0.1f;
for (int i = 0; i < web.length; i++)
{
if (web[i] == block.func_149688_o())
{
return effectiveSpeed();
}
}
return baseSpeed();
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction (ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration (ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
{
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
}
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
{
return false;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock (Block block, ItemStack is)
{
for (int i = 0; i < web.length; i++)
{
if (block.func_149688_o() == web[i])
return true;
}
return super.canHarvestBlock(block, is);
}
protected Material[] getEffectiveMaterials ()
{
return web;
}
@Override
@SideOnly(Side.CLIENT)
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
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 *= 2.5F;
player.movementInput.moveStrafe *= 2.5F;
}
}
}
/*@Override
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity entity)
{
TContent.modL.midStreamModify(stack);
return super.onLeftClickEntity(stack, player, entity);
}*/
@Override
public String[] toolCategories ()
{
return new String[] { "weapon", "melee" };
}
public static Material[] web = new Material[] { Material.field_151569_G };
public static Material[] none = new Material[0];
}