-
Notifications
You must be signed in to change notification settings - Fork 753
/
BehaviorProjectile.java
69 lines (59 loc) · 2.09 KB
/
BehaviorProjectile.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
package tconstruct.util.landmine.behavior;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
/**
*
* @author fuj1n
*
*/
public class BehaviorProjectile extends Behavior
{
@Override
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
{
IProjectile entity = null;
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
if (par5ItemStack.itemID == Item.arrow.itemID)
{
entity = new EntityArrow(par1World, par2, par3, par4);
((EntityArrow) entity).canBePickedUp = 1;
}
else if (par5ItemStack.itemID == Item.snowball.itemID)
{
entity = new EntitySnowball(par1World, par2, par3, par4);
}
else if (par5ItemStack.itemID == Item.enderPearl.itemID)
{
if (triggerer instanceof EntityLivingBase)
{
entity = new EntityEnderPearl(par1World, (EntityLivingBase) triggerer);
((EntityEnderPearl) entity).setPosition(par2, par3, par4);
}
else
{
entity = new EntityEnderPearl(par1World, par2, par3, par4);
}
}
if (entity == null)
{
return;
}
entity.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), 1.1F, 6.0F);
par1World.spawnEntityInWorld((Entity) entity);
par1World.playAuxSFX(1002, par2, par3, par4, 0);
}
//Projectiles: snowballs, arrows
@Override
public boolean isOffensive (ItemStack par1ItemStack)
{
return true;
}
}