2020-08-14 19:24:29 +02:00
|
|
|
package mod.acgaming.spackenmobs.entities;
|
2020-08-23 10:30:02 +02:00
|
|
|
|
2020-08-14 19:24:29 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityAgeable;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.ai.EntityAIAvoidEntity;
|
|
|
|
import net.minecraft.entity.monster.EntityCreeper;
|
|
|
|
import net.minecraft.entity.monster.EntityGhast;
|
|
|
|
import net.minecraft.entity.passive.AbstractHorse;
|
|
|
|
import net.minecraft.entity.passive.EntityAnimal;
|
|
|
|
import net.minecraft.entity.passive.EntityLlama;
|
|
|
|
import net.minecraft.entity.passive.EntityWolf;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.network.datasync.DataParameter;
|
|
|
|
import net.minecraft.network.datasync.DataSerializers;
|
|
|
|
import net.minecraft.network.datasync.EntityDataManager;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2020-08-23 15:38:40 +02:00
|
|
|
public class EntityWolfMZTE extends EntityWolf
|
|
|
|
{
|
2020-08-27 20:12:55 +02:00
|
|
|
class AIAvoidEntity<T extends Entity> extends EntityAIAvoidEntity<T>
|
|
|
|
{
|
|
|
|
private final EntityWolfMZTE wolf;
|
|
|
|
|
|
|
|
public AIAvoidEntity(EntityWolfMZTE wolfIn, Class<T> p_i47251_3_, float p_i47251_4_, double p_i47251_5_, double p_i47251_7_)
|
|
|
|
{
|
|
|
|
super(wolfIn, p_i47251_3_, p_i47251_4_, p_i47251_5_, p_i47251_7_);
|
|
|
|
this.wolf = wolfIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean avoidLlama(EntityLlama p_190854_1_)
|
|
|
|
{
|
|
|
|
return p_190854_1_.getStrength() >= EntityWolfMZTE.this.rand.nextInt(5);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldExecute()
|
|
|
|
{
|
|
|
|
if (super.shouldExecute() && this.closestLivingEntity instanceof EntityLlama)
|
|
|
|
{
|
|
|
|
return !this.wolf.isTamed() && this.avoidLlama((EntityLlama) this.closestLivingEntity);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startExecuting()
|
|
|
|
{
|
|
|
|
EntityWolfMZTE.this.setAttackTarget((EntityLivingBase) null);
|
|
|
|
super.startExecuting();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateTask()
|
|
|
|
{
|
|
|
|
EntityWolfMZTE.this.setAttackTarget((EntityLivingBase) null);
|
|
|
|
super.updateTask();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 16:26:30 +02:00
|
|
|
private static final DataParameter<Float> DATA_HEALTH_ID = EntityDataManager.<Float>createKey(EntityWolfMZTE.class, DataSerializers.FLOAT);
|
|
|
|
private static final DataParameter<Boolean> BEGGING = EntityDataManager.<Boolean>createKey(EntityWolfMZTE.class, DataSerializers.BOOLEAN);
|
|
|
|
private static final DataParameter<Integer> COLLAR_COLOR = EntityDataManager.<Integer>createKey(EntityWolfMZTE.class, DataSerializers.VARINT);
|
2020-08-23 15:38:40 +02:00
|
|
|
private float headRotationCourse;
|
|
|
|
private float headRotationCourseOld;
|
|
|
|
private boolean isWet;
|
|
|
|
private boolean isShaking;
|
|
|
|
private float timeWolfIsShaking;
|
2020-08-27 20:12:55 +02:00
|
|
|
|
2020-08-23 15:38:40 +02:00
|
|
|
private float prevTimeWolfIsShaking;
|
|
|
|
|
|
|
|
public EntityWolfMZTE(World worldIn)
|
|
|
|
{
|
|
|
|
super(worldIn);
|
|
|
|
this.setSize(0.6F, 0.85F);
|
|
|
|
this.setTamed(false);
|
2020-08-23 10:30:02 +02:00
|
|
|
}
|
|
|
|
|
2020-08-23 15:38:40 +02:00
|
|
|
@Override
|
|
|
|
public boolean canMateWith(EntityAnimal otherAnimal)
|
|
|
|
{
|
|
|
|
if (otherAnimal == this)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (!this.isTamed())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (!(otherAnimal instanceof EntityWolfMZTE))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EntityWolfMZTE entitywolfmzte = (EntityWolfMZTE) otherAnimal;
|
|
|
|
|
|
|
|
if (!entitywolfmzte.isTamed())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (entitywolfmzte.isSitting())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.isInLove() && entitywolfmzte.isInLove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-23 10:30:02 +02:00
|
|
|
|
2020-08-27 20:12:55 +02:00
|
|
|
@Override
|
|
|
|
public EntityWolfMZTE createChild(EntityAgeable ageable)
|
|
|
|
{
|
|
|
|
EntityWolfMZTE entitywolfmzte = new EntityWolfMZTE(this.world);
|
|
|
|
UUID uuid = this.getOwnerId();
|
|
|
|
|
|
|
|
if (uuid != null)
|
|
|
|
{
|
|
|
|
entitywolfmzte.setOwnerId(uuid);
|
|
|
|
entitywolfmzte.setTamed(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return entitywolfmzte;
|
|
|
|
}
|
|
|
|
|
2020-08-23 15:38:40 +02:00
|
|
|
@Override
|
|
|
|
public boolean shouldAttackEntity(EntityLivingBase target, EntityLivingBase owner)
|
|
|
|
{
|
|
|
|
if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast))
|
|
|
|
{
|
|
|
|
if (target instanceof EntityWolfMZTE)
|
|
|
|
{
|
|
|
|
EntityWolfMZTE entitywolfmzte = (EntityWolfMZTE) target;
|
|
|
|
|
|
|
|
if (entitywolfmzte.isTamed() && entitywolfmzte.getOwner() == owner)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) target))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return !(target instanceof AbstractHorse) || !((AbstractHorse) target).isTame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
2020-08-23 10:30:02 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-14 19:24:29 +02:00
|
|
|
}
|