Доброго времени суток, подскажите, как сделать, чтоб моего моба нельзя было толкать? Раньше работало, видимо где-то накосячил..
Java:
public class PresentMob extends EntityMob
{
public InventoryBasic inventory = new InventoryBasic("entity.open_gui1.EntityInventory.name", false, 9 * 3);
public PresentMob(World par1World)
{
super(par1World);
}
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent e) {
net.minecraft.entity.Entity en = (attackingPlayer);
if (en instanceof PresentMob) {
e.setCanceled(true);
}
}
@Override
protected boolean interact(EntityPlayer player) {
//if (worldObj.isRemote) {
if (player.getCurrentEquippedItem()!= null && player.getCurrentEquippedItem().getItem() == Main.eggpresentmob){
this.setDead();
return true;
}
if (player instanceof EntityPlayerMP) {
if (inventory == null) return true;
player.openGui(Main.instance, 0, this.worldObj, this.getEntityId(), -1, -1);
}
return true;
}
@Override
public boolean canBreatheUnderwater()
{
return true;
}
public boolean canBePushed() {
return false;
}
public void applyEntityCollision(Entity p_70108_1_){
}
protected void collideWithEntity(Entity p_82167_1_)
{
if (p_82167_1_ != ridingEntity )
{
}
super.collideWithEntity(p_82167_1_);
}
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent e) {
if (e.entityLiving instanceof PresentMob)
e.setCanceled(true);
}
@Override
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_){
this.hurtResistantTime = 10;
this.hurtTime = 1;
this.canAttackWithItem();
}
protected void applyEntityAttributes() {
super.applyEntityAttributes();
//������������� ��������
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.0D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(0.0D);
// this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D);
// this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).setBaseValue(2.0D);
}
protected void initEntityAI() {
/*������ �������� ����
* 1 �������� - ���������
* 2 �������� - �������� ����� �� EntityAIBase
*/
this.tasks.addTask(0, new EntityAISwimming(this));
// this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(2, new EntityAIWander(this, 0.0D));//��� ������������
// this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.tasks.addTask(1, new EntityAIWatchClosest2(this, EntityPlayer.class, 5.0F, 1.0F));
// this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[]{EntityZombie.class, EntityPlayer.class}));������ ������: EntityZombie, EntityPlayer
}
}
Последнее редактирование: