Update TODO, fix wrong version references

This commit is contained in:
FlorianMichael 2024-10-27 18:38:03 +01:00
parent 4e97abe15d
commit bd047de3de
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
10 changed files with 17 additions and 14 deletions

View File

@ -33,6 +33,10 @@ import java.io.File;
import java.util.concurrent.CompletableFuture;
/*
* TODO | Port 1.21.3
* - VehicleMovePacket handling now has distance check
* - Game options are now only send if they changed
*
* TODO | Port 1.20.6
* - ClientPlayerInteractionManager#interactBlockInternal added new condition
* - Command arguments (Probably not everything worth, but least them with nbt)

View File

@ -53,7 +53,7 @@ public abstract class MixinBedBlock extends HorizontalFacingBlock {
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true)
private void dontSwingHand(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
cir.setReturnValue(ActionResult.CONSUME);
}
}

View File

@ -41,7 +41,7 @@ public abstract class MixinDecoratedPotBlock {
@Redirect(method = "onUseWithItem", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;SUCCESS:Lnet/minecraft/util/ActionResult$Success;", ordinal = 0))
private ActionResult.Success dontSwingHand() {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return ActionResult.CONSUME;
} else {
return ActionResult.SUCCESS;

View File

@ -58,7 +58,7 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock {
@Override
protected ActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return stack.isOf(Items.LEAD) ? ActionResult.SUCCESS : ActionResult.PASS;
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) {
return ActionResult.SUCCESS;

View File

@ -32,7 +32,7 @@ public abstract class MixinHoneyBlock {
@Inject(method = { "method_65067", "method_65068" }, at = @At("HEAD"), cancellable = true)
private static void simplifyVelocityComparisons(double d, CallbackInfoReturnable<Double> cir) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
cir.setReturnValue(d);
}
}

View File

@ -32,7 +32,7 @@ public abstract class MixinVaultBlock {
@Redirect(method = "onUseWithItem", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;SUCCESS_SERVER:Lnet/minecraft/util/ActionResult$Success;"))
private ActionResult.Success dontSwingHand() {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return ActionResult.CONSUME;
} else {
return ActionResult.SUCCESS_SERVER;

View File

@ -88,7 +88,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSprintingPacket()V"))
private void sendSneakingAfterSprinting(CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
this.sendSneakingPacket();
}
}
@ -96,7 +96,7 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastHorizontalCollision:Z", ordinal = 0))
private boolean removeHorizontalCollisionFromOnGroundCheck(ClientPlayerEntity instance) {
// Since it doesn't exist in older versions, we need to exclude it from the check to prevent bad packets
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return this.horizontalCollision;
} else {
return this.lastHorizontalCollision;

View File

@ -167,7 +167,7 @@ public abstract class MixinEntity implements IEntity {
private double fixBlockCollisionMargin(double constant) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return 1E-3;
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
} else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return 1E-7;
} else {
return constant;

View File

@ -102,7 +102,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
@Redirect(method = "onEntityPosition", at = @At(value = "INVOKE", target = "Ljava/util/OptionalInt;isPresent()Z"))
private boolean dontHandleRemovedVehiclePositionChange(OptionalInt instance) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return false;
} else {
return instance.isPresent();
@ -111,7 +111,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
@Inject(method = "onPlayerRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;addEntity(Lnet/minecraft/entity/Entity;)V", shift = At.Shift.BEFORE))
private void dontApplyRotationAndVelocity(PlayerRespawnS2CPacket packet, CallbackInfo ci, @Local(ordinal = 1) ClientPlayerEntity clientPlayerEntity) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
clientPlayerEntity.init();
clientPlayerEntity.setYaw(-180.0F);
}
@ -119,7 +119,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
@Redirect(method = "onSignEditorOpen", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
private void openEmptySignEditor(Logger instance, String format, Object arg1, Object arg2, @Local(argsOnly = true) SignEditorOpenS2CPacket packet) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
final BlockPos pos = packet.getPos();
final SignBlockEntity emptySignBlockEntity = new SignBlockEntity(pos, this.world.getBlockState(pos));
@ -225,8 +225,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
@Redirect(method = {"onEntityPosition", "onEntity"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isLogicalSideForUpdatingMovement()Z"))
private boolean allowPlayerToBeMovedByEntityPackets(Entity instance) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3) || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
final boolean logicalMovementSide = instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient;
return !logicalMovementSide; // Older versions had the logic which is now executed if logicalMovementSide is false, so we need to invert values
return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient;
} else {
return instance.isLogicalSideForUpdatingMovement();
}

View File

@ -113,7 +113,7 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay
@Redirect(method = "interactBlockInternal", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;CONSUME:Lnet/minecraft/util/ActionResult$Success;"))
private ActionResult.Success changeSpectatorAction() {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) {
return ActionResult.SUCCESS;
} else {
return ActionResult.CONSUME;