diff --git a/src/main/java/com/github/alexthe666/iceandfire/entity/EntityDragonBase.java b/src/main/java/com/github/alexthe666/iceandfire/entity/EntityDragonBase.java index 15755669a5..0a3830df79 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/entity/EntityDragonBase.java +++ b/src/main/java/com/github/alexthe666/iceandfire/entity/EntityDragonBase.java @@ -637,6 +637,10 @@ public boolean isDismounting() { return (entityData.get(CONTROL_STATE) >> 4 & 1) == 1; } + public boolean isSprinting() { + return (entityData.get(CONTROL_STATE) >> 5 & 1) == 1; + } + @Override public void up(boolean up) { setStateField(0, up); @@ -662,6 +666,11 @@ public void dismount(boolean dismount) { setStateField(4, dismount); } + @Override + public void sprint(boolean sprint) { + setStateField(5, sprint); + } + private void setStateField(int i, boolean newState) { byte prevState = entityData.get(CONTROL_STATE); if (newState) { @@ -681,6 +690,14 @@ public void setControlState(byte state) { entityData.set(CONTROL_STATE, state); } + /** + * Required in LocalPlayer#canStartSprinting + */ + @Override + public boolean canSprint() { + return true; + } + public int getCommand() { return this.entityData.get(COMMAND); } @@ -2027,7 +2044,12 @@ public void travel(@NotNull Vec3 pTravelVector) { // Note: when motion is handled by the client no server side setDeltaMovement() should be called // otherwise the movement will halt // Todo: move wrongly fix - float flyingSpeed; // FIXME :: Why overlay the flyingSpeed variable from LivingEntity + + // LivingEntity#flyingSpeed from 1.18 controls how fast entity moves when falling + // it has little to do with the flying here and is deprecated in 1.20 + // flyingSpeed is now semi-hardcoded in LivingEntity#getFlyingSpeed + // Todo: remove flyingSpeed + float flyingSpeed; if (allowLocalMotionControl && this.getControllingPassenger() != null) { LivingEntity rider = this.getControllingPassenger(); if (rider == null) { @@ -2061,6 +2083,8 @@ public void travel(@NotNull Vec3 pTravelVector) { this.setTackling(false); } + // Todo: use ICustomMoveController#sprint for custom control + // Todo: FOV effect visual hint gliding = allowMousePitchControl && rider.isSprinting(); if (!gliding) { // Mouse controlled yaw diff --git a/src/main/java/com/github/alexthe666/iceandfire/entity/util/ICustomMoveController.java b/src/main/java/com/github/alexthe666/iceandfire/entity/util/ICustomMoveController.java index f6326fb979..46799f1a8f 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/entity/util/ICustomMoveController.java +++ b/src/main/java/com/github/alexthe666/iceandfire/entity/util/ICustomMoveController.java @@ -1,5 +1,10 @@ package com.github.alexthe666.iceandfire.entity.util; +/** + * A custom byte is used to store custom movement state + * From hi to low + * x|x|sprint|dismount strike|attack|down|up + */ public interface ICustomMoveController { void up(boolean up); @@ -11,6 +16,12 @@ public interface ICustomMoveController { void dismount(boolean dismount); + default void sprint(boolean sprint) { + // Not implemented + // Todo :: Implement this for everyone + } + + void setControlState(byte state); byte getControlState(); diff --git a/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java b/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java index dc401651b2..0fa8efb23b 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java +++ b/src/main/java/com/github/alexthe666/iceandfire/event/ClientEvents.java @@ -103,6 +103,7 @@ public void onLivingUpdate(LivingEvent.LivingTickEvent event) { byte previousState = moveController.getControlState(); moveController.up(mc.options.keyJump.isDown()); moveController.down(IafKeybindRegistry.dragon_down.isDown()); + moveController.sprint(mc.options.keySprint.isDown()); moveController.attack(IafKeybindRegistry.dragon_strike.isDown()); moveController.dismount(mc.options.keyShift.isDown()); moveController.strike(IafKeybindRegistry.dragon_fireAttack.isDown());