mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 21:59:05 +00:00
Added fly gravity for NPCs, configurable with npc.setFlyGravity(gravity) and npc.getFlyGravity()
This commit is contained in:
1 parent
c2564de470
commit
94c7df410b
4 files changed
+25
-1
No files matched your search
@@ -36,6 +36,7 @@ public class DataAI {
|
||||
// Fly Change
|
||||
public int movementType = 0;
|
||||
public double flySpeed = 1.0D;
|
||||
public double flyGravity = 0.0D;
|
||||
|
||||
public EnumAnimation animationType = EnumAnimation.NONE;
|
||||
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
||||
@@ -104,6 +105,11 @@ public class DataAI {
|
||||
else
|
||||
flySpeed = compound.getDouble("FlySpeed");
|
||||
|
||||
if(!compound.hasKey("FlyGravity"))
|
||||
flyGravity = 0.0D;
|
||||
else
|
||||
flyGravity = compound.getDouble("FlyGravity");
|
||||
|
||||
startPos = compound.getIntArray("StartPosNew");
|
||||
if (startPos == null || startPos.length != 3){
|
||||
startPos = new int[] {
|
||||
@@ -152,6 +158,7 @@ public class DataAI {
|
||||
|
||||
compound.setInteger("MovingType", movementType);
|
||||
compound.setDouble("FlySpeed",flySpeed);
|
||||
compound.setDouble("FlyGravity",flyGravity);
|
||||
|
||||
npc.setAvoidWater(avoidsWater);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
|
||||
|
||||
if (!this.onGround && !this.getMoveHelper().isUpdating())
|
||||
{
|
||||
this.motionY *= 0.0D;
|
||||
this.motionY *= this.ai.flyGravity;
|
||||
this.velocityChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,6 +954,19 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
return npc.ai.flySpeed;
|
||||
}
|
||||
|
||||
public void setFlyGravity(double flyGravity){
|
||||
if(flyGravity < 0.0D)
|
||||
flyGravity = 0.0D;
|
||||
if(flyGravity > 1.0D)
|
||||
flyGravity = 1.0D;
|
||||
|
||||
npc.ai.flyGravity = flyGravity;
|
||||
}
|
||||
|
||||
public double getFlyGravity(double flySpeed){
|
||||
return npc.ai.flyGravity;
|
||||
}
|
||||
|
||||
public void setSkinType(byte type) {
|
||||
npc.display.skinType = type;
|
||||
npc.updateClient = true;
|
||||
|
||||
@@ -684,6 +684,10 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
|
||||
public double getFlySpeed(double flySpeed);
|
||||
|
||||
public void setFlyGravity(double flyGravity);
|
||||
|
||||
public double getFlyGravity(double flyGravity);
|
||||
|
||||
public void setSkinType(byte type);
|
||||
|
||||
public byte getSkinType();
|
||||
|
||||
Reference in new issue
Block a user