-
Notifications
You must be signed in to change notification settings - Fork 755
/
FryingPan.java
203 lines (174 loc) · 5.44 KB
/
FryingPan.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
package tconstruct.items.tools;
import java.util.List;
import tconstruct.blocks.logic.EquipLogic;
import tconstruct.common.TContent;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.Weapon;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class FryingPan extends Weapon
{
public FryingPan(int itemID)
{
super(itemID, 2);
this.setUnlocalizedName("InfiTool.FryPan");
}
@Override
public boolean hitEntity (ItemStack stack, EntityLivingBase mob, EntityLivingBase player)
{
AbilityHelper.knockbackEntity(mob, 1.7f);
mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 0)); //5 seconds of stun
return true;
}
@Override
public boolean onLeftClickEntity (ItemStack stack, EntityPlayer player, Entity mob)
{
if (mob.canAttackWithItem() && !mob.hitByEntity(player) && mob.hurtResistantTime < 14)
AbilityHelper.onLeftClickEntity(stack, player, mob, this);
return false;
}
@Override
public void onEntityDamaged (World world, EntityLivingBase player, Entity entity)
{
world.playSoundEffect(entity.posX, entity.posY, entity.posZ, "tinker:frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
}
public String getToolName ()
{
return "Frying Pan";
}
public void getSubItems (int id, CreativeTabs tab, List list)
{
super.getSubItems(id, tab, list);
Item accessory = getAccessoryItem();
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 2), new ItemStack(getHandleItem(), 1, 16), null, "Bane of Pigs");
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setInteger("Modifiers", 0);
tags.setInteger("Attack", Integer.MAX_VALUE / 100);
tags.setInteger("TotalDurability", Integer.MAX_VALUE / 100);
tags.setInteger("BaseDurability", Integer.MAX_VALUE / 100);
tags.setInteger("MiningSpeed", Integer.MAX_VALUE / 100);
int[] keyPair = new int[] { Integer.MAX_VALUE / 100, 0, 0 };
tags.setIntArray("Blaze", keyPair);
tags.setInteger("Necrotic", Integer.MAX_VALUE / 100);
tags.setInteger("Effect1", 7);
tags.setBoolean("Built", true);
list.add(tool);
}
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
{
if (side == 0 || !player.isSneaking())
{
return false;
}
else if (!world.getBlockMaterial(x, y, z).isSolid())
{
return false;
}
else
{
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
if (!player.canPlayerEdit(x, y, z, side, stack))
{
return false;
}
else if (!TContent.heldItemBlock.canPlaceBlockAt(world, x, y, z))
{
return false;
}
else
{
world.setBlock(x, y, z, TContent.heldItemBlock.blockID, 0, 3);
TContent.heldItemBlock.onBlockPlacedBy(world, x, y, z, player, stack);
world.playSoundEffect(x, y, z, "tinker:frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F);
EquipLogic logic = (EquipLogic) world.getBlockTileEntity(x, y, z);
logic.setEquipmentItem(stack);
--stack.stackSize;
return true;
}
}
}
@Override
public Item getHeadItem ()
{
return TContent.frypanHead;
}
@Override
public Item getAccessoryItem ()
{
return null;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderPasses (int metadata)
{
return 8;
}
@Override
public int getPartAmount ()
{
return 2;
}
@Override
public void registerPartPaths (int index, String[] location)
{
headStrings.put(index, location[0]);
brokenPartStrings.put(index, location[1]);
handleStrings.put(index, location[2]);
}
@Override
public String getIconSuffix (int partType)
{
switch (partType)
{
case 0:
return "_frypan_head";
case 1:
return "_frypan_head_broken";
case 2:
return "_frypan_handle";
default:
return "";
}
}
@Override
public String getEffectSuffix ()
{
return "_frypan_effect";
}
@Override
public String getDefaultFolder ()
{
return "frypan";
}
}