Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
only update center chunk when needed
Dieser Commit ist enthalten in:
Ursprung
4fa57fd642
Commit
a4085c1a5a
@ -26,6 +26,7 @@ public class WorldPackets {
|
||||
private static final int AIR = MappingData.blockStateMappings.getNewBlock(0);
|
||||
private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591);
|
||||
private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592);
|
||||
public static final int SERVERSIDE_VIEW_DISTANCE = 64;
|
||||
|
||||
public static void register(final Protocol protocol) {
|
||||
|
||||
@ -191,10 +192,17 @@ public class WorldPackets {
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0]));
|
||||
}
|
||||
|
||||
PacketWrapper fakePosLook = wrapper.create(0x40); // Set center chunk
|
||||
fakePosLook.write(Type.VAR_INT, chunk.getX());
|
||||
fakePosLook.write(Type.VAR_INT, chunk.getZ());
|
||||
fakePosLook.send(Protocol1_14To1_13_2.class, true, true);
|
||||
EntityTracker entityTracker = wrapper.user().get(EntityTracker.class);
|
||||
int diffX = Math.abs(entityTracker.getChunkCenterX() - chunk.getX());
|
||||
int diffZ = Math.abs(entityTracker.getChunkCenterZ() - chunk.getZ());
|
||||
if (diffX >= SERVERSIDE_VIEW_DISTANCE || diffZ >= SERVERSIDE_VIEW_DISTANCE) {
|
||||
PacketWrapper fakePosLook = wrapper.create(0x40); // Set center chunk
|
||||
fakePosLook.write(Type.VAR_INT, chunk.getX());
|
||||
fakePosLook.write(Type.VAR_INT, chunk.getZ());
|
||||
fakePosLook.send(Protocol1_14To1_13_2.class, true, true);
|
||||
entityTracker.setChunkCenterX(chunk.getX());
|
||||
entityTracker.setChunkCenterZ(chunk.getZ());
|
||||
}
|
||||
|
||||
lightPacket.send(Protocol1_14To1_13_2.class, true, false);
|
||||
}
|
||||
@ -294,7 +302,7 @@ public class WorldPackets {
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
|
||||
wrapper.write(Type.VAR_INT, 64); // Serverside view distance, added in 19w13a
|
||||
wrapper.write(Type.VAR_INT, SERVERSIDE_VIEW_DISTANCE); // Serverside view distance, added in 19w13a
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ public class EntityTracker extends StoredObject {
|
||||
@Getter
|
||||
@Setter
|
||||
private int latestTradeWindowId;
|
||||
@Getter
|
||||
@Setter
|
||||
private int chunkCenterX, chunkCenterZ;
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren