aether-legacy/src/main/java/com/gildedgames/the_aether/entities/passive/EntityAerwhale.java

110 lines
3.1 KiB
Java
Raw Normal View History

2020-08-14 08:29:22 +02:00
package com.gildedgames.the_aether.entities.passive;
2016-12-17 16:28:16 +01:00
2021-01-04 17:29:40 +01:00
import com.gildedgames.the_aether.AetherConfig;
2020-08-14 08:29:22 +02:00
import com.gildedgames.the_aether.entities.ai.aerwhale.AerwhaleAITravelCourse;
import com.gildedgames.the_aether.entities.ai.aerwhale.AerwhaleAIUnstuck;
2016-12-17 16:28:16 +01:00
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.monster.IMob;
2018-12-07 05:33:43 +01:00
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
2020-06-21 22:21:57 +02:00
import net.minecraft.world.EnumDifficulty;
2016-12-17 16:28:16 +01:00
import net.minecraft.world.World;
2020-08-14 08:29:22 +02:00
import com.gildedgames.the_aether.blocks.BlocksAether;
2016-12-17 16:28:16 +01:00
2020-08-14 02:59:25 +02:00
public class EntityAerwhale extends EntityFlying {
2016-12-17 16:28:16 +01:00
2017-11-18 21:22:49 +01:00
private double motionYaw;
2018-12-07 06:32:48 +01:00
private double motionPitch;
public double aerwhaleRotationYaw;
public double aerwhaleRotationPitch;
public EntityAerwhale(World world) {
super(world);
2020-06-21 22:21:57 +02:00
this.setSize(3F, 3F);
2018-12-07 06:32:48 +01:00
this.isImmuneToFire = true;
this.ignoreFrustumCheck = true;
this.rotationYaw = 360F * this.getRNG().nextFloat();
this.rotationPitch = 90F * this.getRNG().nextFloat() - 45F;
2020-06-21 22:21:57 +02:00
this.tasks.addTask(1, new AerwhaleAIUnstuck(this));
this.tasks.addTask(5, new AerwhaleAITravelCourse(this));
2018-12-07 06:32:48 +01:00
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
}
@Override
protected boolean isAIEnabled() {
return true;
}
@Override
public boolean getCanSpawnHere() {
int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.boundingBox.minY);
int k = MathHelper.floor_double(this.posZ);
2021-01-04 17:29:40 +01:00
return this.rand.nextInt(AetherConfig.getAerwhaleSpawnrate()) == 0 && this.worldObj.getBlock(i, j - 1, k) == BlocksAether.aether_grass && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).size() == 0 && !this.worldObj.isAnyLiquid(this.boundingBox) && this.worldObj.getBlockLightValue(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY), MathHelper.floor_double(this.posZ)) > 8 && super.getCanSpawnHere();
2018-12-07 06:32:48 +01:00
}
@Override
public int getMaxSpawnedInChunk() {
return 1;
}
@Override
public void onUpdate() {
super.onUpdate();
this.extinguish();
2020-06-21 22:21:57 +02:00
if (this.posY < -64.0D)
{
2018-12-07 06:32:48 +01:00
this.setDead();
}
2020-06-21 22:21:57 +02:00
this.aerwhaleRotationYaw = this.rotationYaw;
this.aerwhaleRotationPitch = this.rotationPitch;
2018-12-07 06:32:48 +01:00
}
2020-06-21 22:21:57 +02:00
@Override
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_)
{
this.stepHeight = 0.5F;
this.jumpMovementFactor = 0.02F;
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
2018-12-07 06:32:48 +01:00
}
@Override
public String getLivingSound() {
return "aether_legacy:aemob.aerwhale.call";
2017-11-18 21:22:49 +01:00
}
2018-12-07 06:32:48 +01:00
@Override
protected String getHurtSound() {
return "aether_legacy:aemob.aerwhale.death";
}
@Override
protected String getDeathSound() {
return "aether_legacy:aemob.aerwhale.death";
}
@Override
public boolean canDespawn() {
return true;
}
2016-12-17 16:28:16 +01:00
}