mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 22:17:10 +00:00
Use PositionSync instead of Teleport packet
This commit is contained in:
1 parent
48cbcaa776
commit
b0ab20a3ea
2 files changed
+5
-9
No files matched your search
@@ -1,10 +1,7 @@
|
|||||||
package com.moulberry.flashback;
|
package com.moulberry.flashback;
|
||||||
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
import net.minecraft.network.protocol.game.*;
|
||||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket;
|
|
||||||
import net.minecraft.network.protocol.game.VecDeltaCodec;
|
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
@@ -29,11 +26,10 @@ public class PacketHelper {
|
|||||||
return entity == null || entity.isRemoved() || entity instanceof EnderDragonPart || entity.getType().clientTrackingRange() <= 0;
|
return entity == null || entity.isRemoved() || entity instanceof EnderDragonPart || entity.getType().clientTrackingRange() <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClientboundTeleportEntityPacket createTeleportForUnknown(int id, double x, double y, double z, byte yRot, byte xRot, boolean onGround) {
|
public static Packet<ClientGamePacketListener> createTeleportForUnknown(int id, double x, double y, double z, byte yRot, byte xRot, boolean onGround) {
|
||||||
return new ClientboundTeleportEntityPacket(
|
return new ClientboundEntityPositionSyncPacket(
|
||||||
id,
|
id,
|
||||||
new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, yRot, xRot),
|
new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, yRot, xRot),
|
||||||
Relative.DELTA,
|
|
||||||
onGround
|
onGround
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1085,8 +1085,8 @@ public class ReplayServer extends IntegratedServer {
|
|||||||
byte quantizedXRot = (byte) Mth.floor(serverEntity.entity.getXRot() * 256.0F / 360.0F);
|
byte quantizedXRot = (byte) Mth.floor(serverEntity.entity.getXRot() * 256.0F / 360.0F);
|
||||||
|
|
||||||
if (!serverEntity.positionCodec.getBase().equals(trackingPosition)) {
|
if (!serverEntity.positionCodec.getBase().equals(trackingPosition)) {
|
||||||
trackedEntity.broadcast(new ClientboundTeleportEntityPacket(serverEntity.entity.getId(),
|
trackedEntity.broadcast(new ClientboundEntityPositionSyncPacket(serverEntity.entity.getId(),
|
||||||
PositionMoveRotation.of(serverEntity.entity), Set.of(), serverEntity.wasOnGround));
|
PositionMoveRotation.of(serverEntity.entity), serverEntity.wasOnGround));
|
||||||
serverEntity.positionCodec.setBase(trackingPosition);
|
serverEntity.positionCodec.setBase(trackingPosition);
|
||||||
serverEntity.lastSentYRot = quantizedYRot;
|
serverEntity.lastSentYRot = quantizedYRot;
|
||||||
serverEntity.lastSentXRot = quantizedXRot;
|
serverEntity.lastSentXRot = quantizedXRot;
|
||||||
|
|||||||
Reference in new issue
Block a user