Skip to content

Commit

Permalink
Backport "Player moved wrongly" fix (#3879)
Browse files Browse the repository at this point in the history
Backports @Faithcaio's "moved wrongly" fix for API-10
2c2cf41...e218bf0
  • Loading branch information
qixils authored Aug 11, 2023
1 parent ec81c44 commit 75aa6d1
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public interface ServerGamePacketListenerImplBridge {

@Nullable ResourcePack bridge$popAcceptedResourcePack();

void bridge$captureCurrentPlayerPosition();

void bridge$setLastMoveLocation(ServerLocation location);

long bridge$getLastTryBlockPacketTimeStamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ public static void callNaturalMoveEntityEvent(final net.minecraft.world.entity.E
originalToPosition);

if (finalPosition == null) {
entity.setPos(entity.xOld, entity.yOld, entity.zOld);
entity.moveTo(entity.xOld, entity.yOld, entity.zOld);
} else if (!finalPosition.equals(originalToPosition)) {
entity.setPos(finalPosition.x(), finalPosition.y(), finalPosition.z());
entity.moveTo(finalPosition.x(), finalPosition.y(), finalPosition.z());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
import org.spongepowered.common.bridge.permissions.SubjectBridge;
import org.spongepowered.common.bridge.server.ServerScoreboardBridge;
import org.spongepowered.common.bridge.server.level.ServerPlayerBridge;
import org.spongepowered.common.bridge.server.network.ServerGamePacketListenerImplBridge;
import org.spongepowered.common.bridge.world.BossEventBridge;
import org.spongepowered.common.bridge.world.entity.player.PlayerBridge;
import org.spongepowered.common.data.DataUtil;
Expand Down Expand Up @@ -881,15 +880,6 @@ public void sendMessage(final net.minecraft.network.chat.Component p_241151_1_,
}
}

@Override
protected void impl$capturePlayerPosition(
final double x, final double y, final double z, final CallbackInfo ci
) {
if (this.connection != null) {
((ServerGamePacketListenerImplBridge) this.connection).bridge$captureCurrentPlayerPosition();
}
}

@Override
protected void impl$updateHealthForUseFinish(final CallbackInfo ci) {
this.bridge$refreshScaledHealth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac

@Shadow public abstract void shadow$teleport(double x, double y, double z, float yaw, float pitch, Set<ClientboundPlayerPositionPacket.RelativeArgument> relativeArguments);
@Shadow protected abstract void shadow$filterTextPacket(List<String> p_244537_1_, Consumer<List<String>> p_244537_2_);
@Shadow public abstract void shadow$resetPosition();
// @formatter:on

private int impl$ignorePackets;
Expand Down Expand Up @@ -551,11 +550,6 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerGamePac
return 0;
}

@Override
public void bridge$captureCurrentPlayerPosition() {
this.shadow$resetPosition();
}

@Redirect(method = "handleChat(Ljava/lang/String;)V",
at = @At(
value = "INVOKE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,6 @@ public void stopRiding() {

}


@Inject(method = "setPos", at = @At("HEAD"))
protected void impl$capturePlayerPosition(final double x, final double y, final double z, final CallbackInfo ci) {
// Overridden in ServerPlayer
}

@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;collide(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;"))
private Vec3 impl$onMoveCollide(final Entity entity, final Vec3 originalMove) {
final Vec3 afterCollide = this.shadow$collide(originalMove);
Expand Down

0 comments on commit 75aa6d1

Please sign in to comment.