Handle boat velocity change in <= 1.20.6

This commit is contained in:
FlorianMichael 2024-08-02 00:29:12 +02:00
parent fad95d2670
commit dc189976a4
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -44,6 +44,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -84,6 +85,15 @@ public abstract class MixinBoatEntity extends VehicleEntity {
super(type, world); super(type, world);
} }
@Redirect(method = "updateVelocity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isSpaceEmpty(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Z"))
private boolean alwaysUpdatePosition(World instance, Entity entity, Box box) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_5)) {
return true;
} else {
return instance.isSpaceEmpty(entity, box);
}
}
@Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true) @Inject(method = "pushAwayFrom", at = @At("HEAD"), cancellable = true)
private void pushAwayFrom1_8(Entity entity, CallbackInfo ci) { private void pushAwayFrom1_8(Entity entity, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {