- 1,560
- 86
- 204
Хочу сделать чтобы когда мой моб ударял кого-то, он бы махал бы своей рукой, как игрок или зомби. Но у меня не получается это сделать. Где я ошибся?
Класс моба:
Рендер:
Класс моба:
Java:
public class EntityMyMob extends EntityCreature {
public EntityMyMob(World world) {
super(world);
setSize(0.6F, 1.95F);
}
public EntityMyMob(World world, double x, double y, double z) {
this(world);
setPosition(x, y, z);
}
public boolean processInteract(EntityPlayer player, EnumHand hand) {
setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD));
setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
return true;
}
protected void entityInit() {
super.entityInit();
}
@Override
protected void initEntityAI() {
super.initEntityAI();
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(3, new EntityAIAttackMelee(this, 0.6D, false));
tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.6D));
tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6F));
tasks.addTask(7, new EntityAILookIdle(this));
targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(25D);
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2D);
getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(6D);
}
public boolean attackEntityAsMob(Entity entity) {
boolean flag = entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()));
if (flag) {
this.applyEnchantments(this, entity);
entity.setFire(1);
}
return flag;
}
}
Java:
public class RenderMyMob extends RenderBiped<EntityMyMob> {
public RenderMyMob(RenderManager rm) {
super(rm, new ModelBiped(0F, 0F, 64, 64), 0.5F);
addLayer(new LayerHeldItem(this));
addLayer(new LayerBipedArmor(this) {
protected void initArmor() {
modelLeggings = new ModelBiped(0.5F);
modelArmor = new ModelBiped(1.0F);
}
});
}
}