Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix can't sprint on dragon's back #5366

Open
wants to merge 1 commit into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down