From 07cc3b38745ca9e9a509ac884ca210b33f996cc8 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Mon, 18 Nov 2024 23:47:35 +0800 Subject: [PATCH] Update createTeleportForUnknown to 1.21.3 --- .../com/moulberry/flashback/PacketHelper.java | 22 ++++++++----------- src/main/resources/flashback.accesswidener | 15 ------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/moulberry/flashback/PacketHelper.java b/src/main/java/com/moulberry/flashback/PacketHelper.java index b40c0ed..b6d1163 100644 --- a/src/main/java/com/moulberry/flashback/PacketHelper.java +++ b/src/main/java/com/moulberry/flashback/PacketHelper.java @@ -11,12 +11,15 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ExperienceOrb; import net.minecraft.world.entity.Marker; import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.entity.Relative; import net.minecraft.world.entity.boss.EnderDragonPart; import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.entity.decoration.Painting; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.monster.warden.Warden; import net.minecraft.world.level.block.Block; +import net.minecraft.world.phys.Vec3; import java.util.ArrayList; @@ -27,19 +30,12 @@ public class PacketHelper { } public static ClientboundTeleportEntityPacket createTeleportForUnknown(int id, double x, double y, double z, byte yRot, byte xRot, boolean onGround) { - try { - ClientboundTeleportEntityPacket packet = (ClientboundTeleportEntityPacket) UnsafeWrapper.UNSAFE.allocateInstance(ClientboundTeleportEntityPacket.class); - packet.id = id; - packet.x = x; - packet.y = y; - packet.z = z; - packet.yRot = yRot; - packet.xRot = xRot; - packet.onGround = onGround; - return packet; - } catch (Exception e) { - throw SneakyThrow.sneakyThrow(e); - } + return new ClientboundTeleportEntityPacket( + id, + new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, yRot, xRot), + Relative.DELTA, + onGround + ); } public static Packet createAddEntity(Entity entity) { diff --git a/src/main/resources/flashback.accesswidener b/src/main/resources/flashback.accesswidener index bfb1dc6..f764d43 100644 --- a/src/main/resources/flashback.accesswidener +++ b/src/main/resources/flashback.accesswidener @@ -161,18 +161,3 @@ accessible field com/mojang/blaze3d/audio/Library currentDevice J accessible field com/mojang/blaze3d/audio/Library context J accessible field net/minecraft/client/sounds/SoundEngine executor Lnet/minecraft/client/sounds/SoundEngineExecutor; accessible field net/minecraft/client/sounds/SoundEngineExecutor thread Ljava/lang/Thread; - -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket id I -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket id I -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket x D -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket x D -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket y D -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket y D -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket z D -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket z D -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket yRot B -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket yRot B -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket xRot B -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket xRot B -accessible field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket onGround Z -mutable field net/minecraft/network/protocol/game/ClientboundTeleportEntityPacket onGround Z