3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Reuse 1.15, 1.16 and 1.16.2 chunk types as well

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-20 12:43:46 +10:00
Ursprung 84a054aac1
Commit 7edde72416
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
10 geänderte Dateien mit 13 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.List;
public class ChunkType1_15 extends Type<Chunk> {
public static final Type<Chunk> TYPE = new ChunkType1_15();
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
public ChunkType1_15() {

Datei anzeigen

@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.List;
public class ChunkType1_16 extends Type<Chunk> {
public static final Type<Chunk> TYPE = new ChunkType1_16();
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
public ChunkType1_16() {

Datei anzeigen

@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.List;
public class ChunkType1_16_2 extends Type<Chunk> {
public static final Type<Chunk> TYPE = new ChunkType1_16_2();
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
public ChunkType1_16_2() {

Datei anzeigen

@ -41,7 +41,7 @@ public final class WorldPackets {
protocol.registerClientbound(ClientboundPackets1_14_4.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(ChunkType1_14.TYPE);
wrapper.write(new ChunkType1_15(), chunk);
wrapper.write(ChunkType1_15.TYPE, chunk);
if (chunk.isFullChunk()) {
int[] biomeData = chunk.getBiomeData();

Datei anzeigen

@ -46,8 +46,8 @@ public class WorldPackets {
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new ChunkType1_16());
wrapper.write(new ChunkType1_16_2(), chunk);
Chunk chunk = wrapper.read(ChunkType1_16.TYPE);
wrapper.write(ChunkType1_16_2.TYPE, chunk);
for (int s = 0; s < chunk.getSections().length; s++) {
ChunkSection section = chunk.getSections()[s];

Datei anzeigen

@ -59,8 +59,8 @@ public class WorldPackets {
});
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new ChunkType1_15());
wrapper.write(new ChunkType1_16(), chunk);
Chunk chunk = wrapper.read(ChunkType1_15.TYPE);
wrapper.write(ChunkType1_16.TYPE, chunk);
chunk.setIgnoreOldLightData(chunk.isFullChunk());

Datei anzeigen

@ -122,7 +122,7 @@ public final class WorldPackets {
});
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new ChunkType1_16_2());
Chunk chunk = wrapper.read(ChunkType1_16_2.TYPE);
if (!chunk.isFullChunk()) {
// All chunks are full chunk packets now (1.16 already stopped sending non-full chunks)
// Construct multi block change packets instead

Datei anzeigen

@ -110,7 +110,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_4.PLAYER));
user.put(new PlayerVehicleTracker(user));
user.put(new PlayerVehicleTracker());
}
@Override

Datei anzeigen

@ -179,7 +179,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
map(Type.STRING); // Dimension
map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey());
handler(wrapper -> wrapper.user().put(new PlayerVehicleTracker(wrapper.user())));
handler(wrapper -> wrapper.user().put(new PlayerVehicleTracker()));
}
});

Datei anzeigen

@ -17,17 +17,12 @@
*/
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.storage;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.connection.StorableObject;
public class PlayerVehicleTracker extends StoredObject {
public class PlayerVehicleTracker implements StorableObject {
private int vehicleId = -1;
public PlayerVehicleTracker(final UserConnection user) {
super(user);
}
public int getVehicleId() {
return this.vehicleId;
}
@ -35,5 +30,4 @@ public class PlayerVehicleTracker extends StoredObject {
public void setVehicleId(final int vehicleId) {
this.vehicleId = vehicleId;
}
}