/
FlintAndBlaze.java
119 lines (104 loc) · 3.32 KB
/
FlintAndBlaze.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
package mods.natura.items.tools;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
public class FlintAndBlaze extends Item
{
public FlintAndBlaze(int id)
{
super(id);
this.maxStackSize = 1;
this.setMaxDamage(256);
this.setCreativeTab(CreativeTabs.tabTools);
}
/*public ItemStack onItemRightClick (ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.fireballCharge.itemID))
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
}
return par1ItemStack;
}
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int ticksRemaining)
{
if (!world.isRemote)
{
int time = this.getMaxItemUseDuration(stack) - ticksRemaining;
if (time > 8)
{
int amount = time / 8;
if (amount > 1)
amount = 1;
for (int i = 0; i < amount; i++)
{
double x = player.posX;
double y = player.posY;
double z = player.posZ;
float f1 = player.rotationYawHead;
EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, player, x, y, z);
entitysmallfireball.posY = player.posY + 1.62D;
world.spawnEntityInWorld(entitysmallfireball);
world.playAuxSFXAtEntity(player, 1009, (int) x, (int) y, (int) z, 0);
}
}
}
}
public int getMaxItemUseDuration (ItemStack par1ItemStack)
{
return 72000;
}
public EnumAction getItemUseAction (ItemStack par1ItemStack)
{
return EnumAction.bow;
}*/
//Right-click on blocks
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if (side == 0)
{
--y;
}
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 (world.isAirBlock(x, y, z))
{
world.playSoundEffect((double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
world.setBlock(x, y, z, Block.fire.blockID);
}
stack.damageItem(1, player);
return true;
}
}
}