Enabled fly button in movement, and extended max values for several NPC attributes, converting some to floats and doubles.

NPCs fly with speed based on their movement speed now.
This commit is contained in:
luisc committed 2021-12-03 00:49:10 -06:00
1 parent 44d4e74279
commit 23686dc3b8
35 files changed
+258 -189

No files matched your search

@@ -1,20 +1,17 @@
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.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
public abstract class EntityNPCFlying extends EntityNPCInterface {
public EntityNPCFlying(World world) {
super(world);
this.getNavigator().setCanSwim(true);
this.tasks.addTask(0, new EntityAISwimming(this));
}
// FLY CHANGE [WIP]
@@ -43,15 +40,14 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
return;
}
this.motionY *= 0.6000000238418579D;
double d1;
double d3;
double d5;
double speed = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
double speedMult = 0.6000000238418579D/0.5D;
if (!this.worldObj.isRemote && this.getAttackTarget() != null)
this.motionY *= speed*speedMult;
Entity entity = this.getAttackTarget();
if (!this.worldObj.isRemote)
{
Entity entity = this.getAttackTarget();
if (entity != null)
{
if (this.posY < entity.posY)
@@ -61,26 +57,26 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
this.motionY = 0.0D;
}
this.motionY += (0.5D - this.motionY) * 0.6000000238418579D;
this.motionY += (speed - this.motionY) * speed*speedMult;
}
double d0 = entity.posX - this.posX;
d1 = entity.posZ - this.posZ;
d3 = d0 * d0 + d1 * d1;
double d1 = entity.posY - this.posY;
double d2 = entity.posZ - this.posZ;
double d3 = d0 * d0 + d2 * d2;
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;
this.motionX *= this.ai.getWalkingSpeed()/10.0D;
this.motionZ *= this.ai.getWalkingSpeed()/10.0D;
double d5 = (double)MathHelper.sqrt_double(d3);
this.motionX += (d0 / d5 * speed - this.motionX) * speed*speedMult;
this.motionZ += (d2 / d5 * speed - this.motionZ) * speed*speedMult;
}
this.rotationYaw = (float)((Math.atan2(-d0,-d2)+Math.PI)*-(180F/Math.PI));
}
}
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D)
if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D && isEntityAlive())
{
this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F;
}