mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-24 12:15:41 +01:00
Revert previous behaviour in entity and respawn packets in <= 1.21.1
- EntityPositionPacket's now fallback to the player if it was sent for a vehicle which got removed - onPlayerRespawn now restores player rotation and velocity if KEEP_TRACKED_DATA is set
This commit is contained in:
parent
9f5f6e8421
commit
8ff9354c04
@ -34,6 +34,7 @@ import net.minecraft.client.gui.screen.ingame.BookScreen;
|
||||
import net.minecraft.client.network.*;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.TrackedPosition;
|
||||
import net.minecraft.entity.attribute.AttributeContainer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.vehicle.AbstractBoatEntity;
|
||||
@ -47,6 +48,7 @@ import net.minecraft.network.packet.c2s.play.ChatCommandSignedC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.*;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.World;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
@ -61,6 +63,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
@ -87,6 +90,23 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
|
||||
super(client, connection, connectionState);
|
||||
}
|
||||
|
||||
@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)) {
|
||||
return false;
|
||||
} else {
|
||||
return instance.isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@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)) {
|
||||
clientPlayerEntity.init();
|
||||
clientPlayerEntity.setYaw(-180.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapWithCondition(method = "onPlayerRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/AttributeContainer;setBaseFrom(Lnet/minecraft/entity/attribute/AttributeContainer;)V"))
|
||||
private boolean dontApplyBaseValues(AttributeContainer instance, AttributeContainer other) {
|
||||
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21);
|
||||
|
Loading…
Reference in New Issue
Block a user