-
Notifications
You must be signed in to change notification settings - Fork 755
/
BehaviorSpawnEgg.java
47 lines (40 loc) · 1.37 KB
/
BehaviorSpawnEgg.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
package tconstruct.util.landmine.behavior;
import net.minecraft.block.BlockDispenser;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
/**
*
* @author fuj1n
*
*/
public class BehaviorSpawnEgg extends Behavior
{
@Override
public void executeLogic (World par1World, int par2, int par3, int par4, ItemStack par5ItemStack, Entity triggerer, boolean willBlockBeRemoved)
{
EnumFacing enumfacing = getFacing(par1World, par2, par3, par4);
double d0 = par2 + Math.random() + (double) enumfacing.getFrontOffsetX();
double d1 = (double) ((float) par3 + 0.2F);
double d2 = par4 + Math.random() + (double) enumfacing.getFrontOffsetZ();
Entity entity = ItemMonsterPlacer.spawnCreature(par1World, par5ItemStack.getItemDamage(), d0, d1, d2);
if (entity instanceof EntityLivingBase && par5ItemStack.hasDisplayName())
{
((EntityLiving) entity).setCustomNameTag(par5ItemStack.getDisplayName());
}
}
@Override
public boolean effectStacks ()
{
return false;
}
@Override
public boolean isOffensive (ItemStack par1ItemStack)
{
return true;
}
}