Consolidated EventScriptContainer and ScriptContainer into a single ScriptContainer class. NPCs are now able to fly when ai.movementType == 1.

This commit is contained in:
luisc committed 2021-12-01 15:31:05 -06:00
1 parent f3ebf86b1e
commit 72869e6a78
14 files changed
+422 -457

No files matched your search

@@ -3,6 +3,7 @@ package noppes.npcs.entity;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
@@ -35,59 +36,53 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
super.updateFallState(p_180433_1_, p_180433_3_);
}
@Override
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_){
if(!canFly()){
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
return;
}
if (this.isInWater()){
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
public void onLivingUpdate()
{
if(!canFly()){
super.onLivingUpdate();
return;
}
else if (this.isInsideOfMaterial(Material.lava)){
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
}
else{
float f2 = 0.91F;
if (this.onGround){
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
this.motionY *= 0.6000000238418579D;
double d1;
double d3;
double d5;
if (!this.worldObj.isRemote && this.getAttackTarget() != null)
{
Entity entity = this.getAttackTarget();
if (entity != null)
{
if (this.posY < entity.posY)
{
if (this.motionY < 0.0D)
{
this.motionY = 0.0D;
}
this.motionY += (0.5D - this.motionY) * 0.6000000238418579D;
}
double d0 = entity.posX - this.posX;
d1 = entity.posZ - this.posZ;
d3 = d0 * d0 + d1 * d1;
if (d3 > 9.0D)
{
d5 = (double)MathHelper.sqrt_double(d3);
this.motionX += (d0 / d5 * 0.5D - this.motionX) * 0.6000000238418579D;
this.motionZ += (d1 / d5 * 0.5D - this.motionZ) * 0.6000000238418579D;
}
}
float f3 = 0.16277136F / (f2 * f2 * f2);
this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F;
if (this.onGround){
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
}
this.prevLimbSwingAmount = this.limbSwingAmount;
double d1 = this.posX - this.prevPosX;
double d0 = this.posZ - this.prevPosZ;
float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;
if (f4 > 1.0F){
f4 = 1.0F;
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D)
{
this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F;
}
this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
super.onLivingUpdate();
}
@Override