2
1
Fork 1
mirror of https://github.com/ACGaming/Spackenmobs synced 2024-06-02 18:49:45 +02:00
Spackenmobs/src/main/java/mod/acgaming/spackenmobs/entities/EntityMZTEWolf.java

130 lines
3.3 KiB
Java
Raw Normal View History

2020-08-14 19:24:29 +02:00
package mod.acgaming.spackenmobs.entities;
2020-08-23 10:30:02 +02:00
2021-09-13 19:03:13 +02:00
import java.util.UUID;
2020-08-14 19:24:29 +02:00
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
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.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
2022-04-12 13:23:27 +02:00
import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundEvent;
2020-08-14 19:24:29 +02:00
import net.minecraft.world.World;
2022-04-12 13:23:27 +02:00
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
2020-09-06 10:23:15 +02:00
public class EntityMZTEWolf extends EntityWolf
2020-08-29 20:42:50 +02:00
{
2021-09-13 19:03:13 +02:00
public EntityMZTEWolf(World worldIn)
{
super(worldIn);
this.setSize(0.6F, 0.85F);
this.setTamed(false);
}
2022-04-12 13:23:27 +02:00
@Override
protected SoundEvent getAmbientSound()
{
return ModSoundEvents.ENTITY_MZTEWOLF_AMBIENT;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
{
return ModSoundEvents.ENTITY_MZTEWOLF_HURT;
}
@Override
protected SoundEvent getDeathSound()
{
return ModSoundEvents.ENTITY_MZTEWOLF_DEATH;
}
@Override
protected float getSoundVolume()
{
return 1.0F;
}
2021-09-13 19:03:13 +02:00
@Override
public EntityMZTEWolf createChild(EntityAgeable ageable)
{
EntityMZTEWolf entitymztewolf = new EntityMZTEWolf(this.world);
UUID uuid = this.getOwnerId();
2021-09-13 19:03:13 +02:00
if (uuid != null)
{
entitymztewolf.setOwnerId(uuid);
entitymztewolf.setTamed(true);
}
2021-09-13 19:03:13 +02:00
return entitymztewolf;
}
2021-09-13 19:03:13 +02:00
@Override
public boolean canMateWith(EntityAnimal otherAnimal)
{
if (otherAnimal == this)
{
return false;
}
else if (!this.isTamed())
{
return false;
}
else if (!(otherAnimal instanceof EntityMZTEWolf))
{
return false;
}
else
{
EntityMZTEWolf entitymztewolf = (EntityMZTEWolf) otherAnimal;
2021-09-13 19:03:13 +02:00
if (!entitymztewolf.isTamed())
{
return false;
}
else if (entitymztewolf.isSitting())
{
return false;
}
else
{
return this.isInLove() && entitymztewolf.isInLove();
}
}
}
2021-09-13 19:03:13 +02:00
@Override
public boolean shouldAttackEntity(EntityLivingBase target, EntityLivingBase owner)
{
if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast))
{
if (target instanceof EntityMZTEWolf)
{
EntityMZTEWolf entitymztewolf = (EntityMZTEWolf) target;
2021-09-13 19:03:13 +02:00
if (entitymztewolf.isTamed() && entitymztewolf.getOwner() == owner)
{
return false;
}
}
2022-04-12 13:23:27 +02:00
if (target instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) target))
2021-09-13 19:03:13 +02:00
{
return false;
}
else
{
return !(target instanceof AbstractHorse) || !((AbstractHorse) target).isTame();
}
}
else
{
return false;
}
}
2020-08-14 19:24:29 +02:00
}