3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-08 11:10:06 +02:00

Merge pull request #1265 from Gerrygames/1.14

only update center chunk when needed
Dieser Commit ist enthalten in:
Myles 2019-04-22 10:44:10 +01:00 committet von GitHub
Commit 89a01b3997
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 16 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ public class WorldPackets {
private static final int AIR = MappingData.blockStateMappings.getNewBlock(0); private static final int AIR = MappingData.blockStateMappings.getNewBlock(0);
private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591); private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591);
private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592); 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) { 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])); lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(data).toArray(new Byte[0]));
} }
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 PacketWrapper fakePosLook = wrapper.create(0x40); // Set center chunk
fakePosLook.write(Type.VAR_INT, chunk.getX()); fakePosLook.write(Type.VAR_INT, chunk.getX());
fakePosLook.write(Type.VAR_INT, chunk.getZ()); fakePosLook.write(Type.VAR_INT, chunk.getZ());
fakePosLook.send(Protocol1_14To1_13_2.class, true, true); 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); 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.UNSIGNED_BYTE); // Max Players
wrapper.passthrough(Type.STRING); // Level Type 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
} }
}); });
} }

Datei anzeigen

@ -17,6 +17,9 @@ public class EntityTracker extends StoredObject {
@Getter @Getter
@Setter @Setter
private int latestTradeWindowId; private int latestTradeWindowId;
@Getter
@Setter
private int chunkCenterX, chunkCenterZ;
public EntityTracker(UserConnection user) { public EntityTracker(UserConnection user) {
super(user); super(user);