Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 17:10:13 +01:00
Remove ClientChunk from 1.14+ chunk types
Apparently multiple people (including me) blindly copied that from older versions. Also removed join/respawn from the abstract MetadataRewriter, since they were only used twice each.
Dieser Commit ist enthalten in:
Ursprung
31f7bde35f
Commit
6a7a92a97b
@ -4,8 +4,7 @@ public enum Environment {
|
|||||||
|
|
||||||
NORMAL(0),
|
NORMAL(0),
|
||||||
NETHER(-1),
|
NETHER(-1),
|
||||||
END(1),
|
END(1);
|
||||||
CUSTOM(Integer.MAX_VALUE);
|
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
@ -28,17 +27,4 @@ public enum Environment {
|
|||||||
return END;
|
return END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Environment getEnvironmentById(String id) {
|
|
||||||
switch (id) {
|
|
||||||
case "minecraft:the_nether":
|
|
||||||
return NETHER;
|
|
||||||
case "minecraft:overworld":
|
|
||||||
return NORMAL;
|
|
||||||
case "minecraft:the_end":
|
|
||||||
return END;
|
|
||||||
default:
|
|
||||||
return CUSTOM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,39 +50,7 @@ public abstract class MetadataRewriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerJoinGame(ClientboundPacketType packetType, @Nullable EntityType playerType) {
|
//TODO add respawn/join once they stop changing too much
|
||||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.INT); // 0 - Entity ID
|
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
|
||||||
map(Type.INT); // 2 - Dimension
|
|
||||||
handler(wrapper -> {
|
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 1);
|
|
||||||
clientChunks.setEnvironment(dimensionId);
|
|
||||||
|
|
||||||
if (playerType != null) {
|
|
||||||
wrapper.user().get(entityTrackerClass).addEntity(wrapper.get(Type.INT, 0), playerType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerRespawn(ClientboundPacketType packetType) {
|
|
||||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.INT);
|
|
||||||
handler(wrapper -> {
|
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 0);
|
|
||||||
clientWorld.setEnvironment(dimensionId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerTracker(ClientboundPacketType packetType) {
|
public void registerTracker(ClientboundPacketType packetType) {
|
||||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||||
|
@ -15,12 +15,12 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
|||||||
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
|
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
|
import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets;
|
import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
|
import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||||
@ -235,9 +235,30 @@ public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, Client
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null);
|
registerOutgoing(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Entity ID
|
||||||
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
|
map(Type.INT); // 2 - Dimension
|
||||||
|
handler(wrapper -> {
|
||||||
|
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientChunks.setEnvironment(dimensionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
registerOutgoing(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT);
|
||||||
|
handler(wrapper -> {
|
||||||
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 0);
|
||||||
|
clientWorld.setEnvironment(dimensionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
INCOMING PACKETS
|
INCOMING PACKETS
|
||||||
|
@ -138,11 +138,34 @@ public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, Clie
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null);
|
|
||||||
metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||||
metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
|
||||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||||
|
|
||||||
|
registerOutgoing(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT);
|
||||||
|
map(Type.UNSIGNED_BYTE);
|
||||||
|
map(Type.INT);
|
||||||
|
handler(wrapper -> {
|
||||||
|
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientChunks.setEnvironment(dimensionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
registerOutgoing(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT);
|
||||||
|
handler(wrapper -> {
|
||||||
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 0);
|
||||||
|
clientWorld.setEnvironment(dimensionId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||||
|
|
||||||
public Chunk1_13Type(ClientWorld param) {
|
public Chunk1_13Type(ClientWorld param) {
|
||||||
super(param, Chunk.class);
|
super(param, Chunk.class);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
|
|||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
public void init(UserConnection userConnection) {
|
||||||
userConnection.put(new EntityTracker1_14(userConnection));
|
userConnection.put(new EntityTracker1_14(userConnection));
|
||||||
if (!userConnection.has(ClientWorld.class))
|
if (!userConnection.has(ClientWorld.class)) {
|
||||||
userConnection.put(new ClientWorld(userConnection));
|
userConnection.put(new ClientWorld(userConnection));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class WorldPackets {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
Chunk chunk = wrapper.read(new Chunk1_13Type(clientWorld));
|
Chunk chunk = wrapper.read(new Chunk1_13Type(clientWorld));
|
||||||
wrapper.write(new Chunk1_14Type(clientWorld), chunk);
|
wrapper.write(new Chunk1_14Type(), chunk);
|
||||||
|
|
||||||
int[] motionBlocking = new int[16 * 16];
|
int[] motionBlocking = new int[16 * 16];
|
||||||
int[] worldSurface = new int[16 * 16];
|
int[] worldSurface = new int[16 * 16];
|
||||||
|
@ -6,24 +6,22 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.PartialType;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
|
public class Chunk1_14Type extends Type<Chunk> {
|
||||||
|
|
||||||
public Chunk1_14Type(ClientWorld param) {
|
public Chunk1_14Type() {
|
||||||
super(param, Chunk.class);
|
super(Chunk.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
public Chunk read(ByteBuf input) throws Exception {
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
int chunkZ = input.readInt();
|
int chunkZ = input.readInt();
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
public void write(ByteBuf output, Chunk chunk) throws Exception {
|
||||||
output.writeInt(chunk.getX());
|
output.writeInt(chunk.getX());
|
||||||
output.writeInt(chunk.getZ());
|
output.writeInt(chunk.getZ());
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.InventoryPacke
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.PlayerPackets;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.PlayerPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.WorldPackets;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.WorldPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||||
|
|
||||||
@ -84,7 +83,5 @@ public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, Clien
|
|||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
public void init(UserConnection userConnection) {
|
||||||
userConnection.put(new EntityTracker1_15(userConnection));
|
userConnection.put(new EntityTracker1_15(userConnection));
|
||||||
if (!userConnection.has(ClientWorld.class))
|
|
||||||
userConnection.put(new ClientWorld(userConnection));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
public class PlayerPackets {
|
public class PlayerPackets {
|
||||||
|
|
||||||
@ -16,14 +15,7 @@ public class PlayerPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
handler(wrapper -> {
|
create(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 0);
|
|
||||||
clientWorld.setEnvironment(dimensionId);
|
|
||||||
});
|
|
||||||
create(wrapper -> {
|
|
||||||
wrapper.write(Type.LONG, 0L); // Level Seed
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,28 +27,19 @@ public class PlayerPackets {
|
|||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
|
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Store the player
|
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 1);
|
|
||||||
clientChunks.setEnvironment(dimensionId);
|
|
||||||
|
|
||||||
// Register Type ID
|
// Register Type ID
|
||||||
EntityTracker1_15 tracker = wrapper.user().get(EntityTracker1_15.class);
|
EntityTracker1_15 tracker = wrapper.user().get(EntityTracker1_15.class);
|
||||||
int entityId = wrapper.get(Type.INT, 0);
|
int entityId = wrapper.get(Type.INT, 0);
|
||||||
tracker.addEntity(entityId, Entity1_15Types.EntityType.PLAYER);
|
tracker.addEntity(entityId, Entity1_15Types.EntityType.PLAYER);
|
||||||
});
|
});
|
||||||
create(wrapper -> {
|
create(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||||
wrapper.write(Type.LONG, 0L); // Level Seed
|
|
||||||
});
|
|
||||||
|
|
||||||
map(Type.UNSIGNED_BYTE); // 3 - Max Players
|
map(Type.UNSIGNED_BYTE); // 3 - Max Players
|
||||||
map(Type.STRING); // 4 - Level Type
|
map(Type.STRING); // 4 - Level Type
|
||||||
map(Type.VAR_INT); // 5 - View Distance
|
map(Type.VAR_INT); // 5 - View Distance
|
||||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||||
|
|
||||||
create(wrapper -> {
|
create(wrapper -> wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn())); // Show Death Screen
|
||||||
wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn()); // Show Death Screen
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
|
|
||||||
@ -30,9 +29,8 @@ public class WorldPackets {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
Chunk chunk = wrapper.read(new Chunk1_14Type());
|
||||||
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
|
wrapper.write(new Chunk1_15Type(), chunk);
|
||||||
wrapper.write(new Chunk1_15Type(clientWorld), chunk);
|
|
||||||
|
|
||||||
if (chunk.isFullChunk()) {
|
if (chunk.isFullChunk()) {
|
||||||
int[] biomeData = chunk.getBiomeData();
|
int[] biomeData = chunk.getBiomeData();
|
||||||
|
@ -6,25 +6,23 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.PartialType;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
public class Chunk1_15Type extends Type<Chunk> {
|
||||||
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
||||||
|
|
||||||
public Chunk1_15Type(ClientWorld param) {
|
public Chunk1_15Type() {
|
||||||
super(param, Chunk.class);
|
super(Chunk.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
public Chunk read(ByteBuf input) throws Exception {
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
int chunkZ = input.readInt();
|
int chunkZ = input.readInt();
|
||||||
|
|
||||||
@ -66,7 +64,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
public void write(ByteBuf output, Chunk chunk) throws Exception {
|
||||||
output.writeInt(chunk.getX());
|
output.writeInt(chunk.getX());
|
||||||
output.writeInt(chunk.getZ());
|
output.writeInt(chunk.getZ());
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
|
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
|
public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
|
||||||
|
|
||||||
@ -113,8 +112,5 @@ public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, Cli
|
|||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
public void init(UserConnection userConnection) {
|
||||||
userConnection.put(new EntityTracker1_16_2(userConnection));
|
userConnection.put(new EntityTracker1_16_2(userConnection));
|
||||||
if (!userConnection.has(ClientWorld.class)) {
|
|
||||||
userConnection.put(new ClientWorld(userConnection));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.metadata.MetadataRew
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
|
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
public class EntityPackets {
|
public class EntityPackets {
|
||||||
|
|
||||||
@ -52,9 +51,6 @@ public class EntityPackets {
|
|||||||
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // Max players
|
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // Max players
|
||||||
// ...
|
// ...
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
String dimension = wrapper.get(Type.STRING, 0);
|
|
||||||
clientChunks.setEnvironment(dimension);
|
|
||||||
wrapper.user().get(EntityTracker1_16_2.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16_2Types.EntityType.PLAYER);
|
wrapper.user().get(EntityTracker1_16_2.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16_2Types.EntityType.PLAYER);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,9 +33,8 @@ public class WorldPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
||||||
Chunk chunk = wrapper.read(new Chunk1_16Type(clientWorld));
|
wrapper.write(new Chunk1_16_2Type(), chunk);
|
||||||
wrapper.write(new Chunk1_16_2Type(clientWorld), chunk);
|
|
||||||
|
|
||||||
for (int s = 0; s < 16; s++) {
|
for (int s = 0; s < 16; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
|
@ -6,25 +6,23 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.PartialType;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_16;
|
import us.myles.ViaVersion.api.type.types.version.Types1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Chunk1_16_2Type extends PartialType<Chunk, ClientWorld> {
|
public class Chunk1_16_2Type extends Type<Chunk> {
|
||||||
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
||||||
|
|
||||||
public Chunk1_16_2Type(ClientWorld param) {
|
public Chunk1_16_2Type() {
|
||||||
super(param, Chunk.class);
|
super(Chunk.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
public Chunk read(ByteBuf input) throws Exception {
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
int chunkZ = input.readInt();
|
int chunkZ = input.readInt();
|
||||||
|
|
||||||
@ -64,7 +62,7 @@ public class Chunk1_16_2Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
public void write(ByteBuf output, Chunk chunk) throws Exception {
|
||||||
output.writeInt(chunk.getX());
|
output.writeInt(chunk.getX());
|
||||||
output.writeInt(chunk.getZ());
|
output.writeInt(chunk.getZ());
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.WorldPackets;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.WorldPackets;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -270,8 +269,5 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
|
|||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
public void init(UserConnection userConnection) {
|
||||||
userConnection.put(new EntityTracker1_16(userConnection));
|
userConnection.put(new EntityTracker1_16(userConnection));
|
||||||
if (!userConnection.has(ClientWorld.class)) {
|
|
||||||
userConnection.put(new ClientWorld(userConnection));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -170,10 +169,6 @@ public class EntityPackets {
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none
|
wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none
|
||||||
|
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
|
||||||
String dimensionId = wrapper.get(Type.STRING, 0);
|
|
||||||
clientWorld.setEnvironment(dimensionId);
|
|
||||||
|
|
||||||
String levelType = wrapper.read(Type.STRING);
|
String levelType = wrapper.read(Type.STRING);
|
||||||
wrapper.write(Type.BOOLEAN, false); // debug
|
wrapper.write(Type.BOOLEAN, false); // debug
|
||||||
wrapper.write(Type.BOOLEAN, levelType.equals("flat"));
|
wrapper.write(Type.BOOLEAN, levelType.equals("flat"));
|
||||||
@ -196,10 +191,6 @@ public class EntityPackets {
|
|||||||
map(Type.LONG); // Seed
|
map(Type.LONG); // Seed
|
||||||
map(Type.UNSIGNED_BYTE); // Max players
|
map(Type.UNSIGNED_BYTE); // Max players
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
String dimension = wrapper.get(Type.STRING, 0);
|
|
||||||
clientChunks.setEnvironment(dimension);
|
|
||||||
|
|
||||||
wrapper.user().get(EntityTracker1_16.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.EntityType.PLAYER);
|
wrapper.user().get(EntityTracker1_16.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.EntityType.PLAYER);
|
||||||
|
|
||||||
final String type = wrapper.read(Type.STRING);// level type
|
final String type = wrapper.read(Type.STRING);// level type
|
||||||
|
@ -17,7 +17,6 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -45,9 +44,8 @@ public class WorldPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
||||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
wrapper.write(new Chunk1_16Type(), chunk);
|
||||||
wrapper.write(new Chunk1_16Type(clientWorld), chunk);
|
|
||||||
|
|
||||||
chunk.setIgnoreOldLightData(chunk.isFullChunk());
|
chunk.setIgnoreOldLightData(chunk.isFullChunk());
|
||||||
|
|
||||||
|
@ -6,25 +6,23 @@ import us.myles.ViaVersion.api.Via;
|
|||||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
import us.myles.ViaVersion.api.type.PartialType;
|
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||||
import us.myles.ViaVersion.api.type.types.version.Types1_16;
|
import us.myles.ViaVersion.api.type.types.version.Types1_16;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
public class Chunk1_16Type extends Type<Chunk> {
|
||||||
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
private static final CompoundTag[] EMPTY_COMPOUNDS = new CompoundTag[0];
|
||||||
|
|
||||||
public Chunk1_16Type(ClientWorld param) {
|
public Chunk1_16Type() {
|
||||||
super(param, Chunk.class);
|
super(Chunk.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
public Chunk read(ByteBuf input) throws Exception {
|
||||||
int chunkX = input.readInt();
|
int chunkX = input.readInt();
|
||||||
int chunkZ = input.readInt();
|
int chunkZ = input.readInt();
|
||||||
|
|
||||||
@ -67,7 +65,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
public void write(ByteBuf output, Chunk chunk) throws Exception {
|
||||||
output.writeInt(chunk.getX());
|
output.writeInt(chunk.getX());
|
||||||
output.writeInt(chunk.getZ());
|
output.writeInt(chunk.getZ());
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import us.myles.ViaVersion.api.data.StoredObject;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stored up until 1.14 to be used in chunk sending.
|
||||||
|
*/
|
||||||
public class ClientWorld extends StoredObject {
|
public class ClientWorld extends StoredObject {
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
@ -18,8 +21,4 @@ public class ClientWorld extends StoredObject {
|
|||||||
public void setEnvironment(int environmentId) {
|
public void setEnvironment(int environmentId) {
|
||||||
this.environment = Environment.getEnvironmentById(environmentId);
|
this.environment = Environment.getEnvironmentById(environmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnvironment(String environmentId) {
|
|
||||||
this.environment = Environment.getEnvironmentById(environmentId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren