-
Notifications
You must be signed in to change notification settings - Fork 81
/
EntityImp.java
143 lines (126 loc) · 4.54 KB
/
EntityImp.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
package com.progwml6.natura.entities.entity.passive;
import static com.progwml6.natura.shared.NaturaCommons.soups;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.progwml6.natura.library.Util;
import com.progwml6.natura.shared.NaturaCommons;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
public class EntityImp extends EntityAnimal
{
public static final ResourceLocation LOOT_TABLE = Util.getResource("entities/imp");
@SuppressWarnings({ "rawtypes", "unchecked" })
public EntityImp(World par1World)
{
super(par1World);
this.setSize(0.9F, 0.9F);
this.isImmuneToFire = true;
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
this.tasks.addTask(2, new EntityAITempt(this, 0.3F, soups, false));
this.tasks.addTask(3, new EntityAIMate(this, 0.25F));
this.tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 8.0F, 0.25F, 0.3F));
this.tasks.addTask(5, new EntityAIFollowParent(this, 0.28F));
this.tasks.addTask(6, new EntityAIWander(this, 0.25F));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(8, new EntityAILookIdle(this));
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(40.0D); //Health
}
@Override
protected void updateAITasks()
{
super.updateAITasks();
}
/**
* Returns the sound this mob makes while it's alive.
*/
@Override
protected SoundEvent getAmbientSound()
{
return SoundEvents.ENTITY_PIG_AMBIENT;
}
/**
* Returns the sound this mob makes when it is hurt.
*/
@Override
protected SoundEvent getHurtSound()
{
return SoundEvents.ENTITY_PIG_HURT;
}
/**
* Returns the sound this mob makes on death.
*/
@Override
protected SoundEvent getDeathSound()
{
return SoundEvents.ENTITY_PIG_DEATH;
}
/**
* Plays step sound at given x, y, z for the entity
*/
@Override
protected void playStepSound(BlockPos pos, Block blockIn)
{
this.playSound(SoundEvents.ENTITY_PIG_STEP, 0.15F, 1.0F);
}
// we're using this instead of getDropItem because we need the metadata
@Nonnull
@Override
public EntityItem dropItemWithOffset(@Nonnull Item itemIn, int size, float offsetY)
{
ItemStack stack = NaturaCommons.impmeatRaw.copy();
stack.setCount(size);
return this.entityDropItem(stack, offsetY);
}
@Override
@Nullable
protected ResourceLocation getLootTable()
{
return LOOT_TABLE;
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
@Override
public boolean isBreedingItem(ItemStack par1ItemStack)
{
return !par1ItemStack.isEmpty() && par1ItemStack.getItem() == soups && par1ItemStack.getItemDamage() >= 4;
}
@Override
public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
{
return new EntityImp(this.world);
}
@Override
public boolean getCanSpawnHere()
{
return this.world.provider instanceof WorldProviderHell && this.world.checkNoEntityCollision(this.getEntityBoundingBox()) && this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.world.containsAnyLiquid(this.getEntityBoundingBox());
}
}