-
Notifications
You must be signed in to change notification settings - Fork 754
/
BehaviorPotion.java
76 lines (68 loc) · 2.39 KB
/
BehaviorPotion.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
package tconstruct.util.landmine.behavior;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.init.Items;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import tconstruct.items.blocks.ItemBlockLandmine;
/**
*
* @author fuj1n
*
*/
public class BehaviorPotion extends Behavior
{
@Override
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
{
if (ItemPotion.isSplash(par5ItemStack.getItemDamage()))
{
par1World.playSoundAtEntity(triggerer, "random.bow", 0.5F, 0.4F / (ItemBlockLandmine.getRandom().nextFloat() * 0.4F + 0.8F));
if (!par1World.isRemote)
{
if (triggerer instanceof EntityLivingBase)
{
par1World.spawnEntityInWorld(new EntityPotion(par1World, (EntityLivingBase) triggerer, par5ItemStack));
}
else
{
par1World.spawnEntityInWorld(new EntityPotion(par1World, par2, par3, par4, par5ItemStack));
}
}
}
else
{
if (triggerer instanceof EntityPlayer)
{
Items.potionitem.onEaten(par5ItemStack, par1World, (EntityPlayer) triggerer);
}
else if (triggerer instanceof EntityLivingBase)
{
if (!par1World.isRemote)
{
List list = Items.potionitem.getEffects(par5ItemStack);
if (list != null)
{
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
PotionEffect potioneffect = (PotionEffect) iterator.next();
((EntityLivingBase) triggerer).addPotionEffect(new PotionEffect(potioneffect));
}
}
}
}
}
}
@Override
public boolean isOffensive (ItemStack par1ItemStack)
{
return false;
}
}