mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-23 10:35:12 +01:00
commit
f570e77325
@ -8,16 +8,18 @@ public class BaseChunk implements Chunk {
|
||||
protected final int x;
|
||||
protected final int z;
|
||||
protected final boolean fullChunk;
|
||||
protected boolean ignoreOldLightData;
|
||||
protected final int bitmask;
|
||||
protected final ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected CompoundTag heightMap;
|
||||
protected final List<CompoundTag> blockEntities;
|
||||
|
||||
public BaseChunk(int x, int z, boolean fullChunk, int bitmask, ChunkSection[] sections, int[] biomeData, CompoundTag heightMap, List<CompoundTag> blockEntities) {
|
||||
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, CompoundTag heightMap, List<CompoundTag> blockEntities) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.fullChunk = fullChunk;
|
||||
this.ignoreOldLightData = ignoreOldLightData;
|
||||
this.bitmask = bitmask;
|
||||
this.sections = sections;
|
||||
this.biomeData = biomeData;
|
||||
@ -25,8 +27,8 @@ public class BaseChunk implements Chunk {
|
||||
this.blockEntities = blockEntities;
|
||||
}
|
||||
|
||||
public BaseChunk(int x, int z, boolean fullChunk, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
this(x, z, fullChunk, bitmask, sections, biomeData, null, blockEntities);
|
||||
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
this(x, z, fullChunk, ignoreOldLightData, bitmask, sections, biomeData, null, blockEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,6 +51,16 @@ public class BaseChunk implements Chunk {
|
||||
return fullChunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreOldLightData() {
|
||||
return ignoreOldLightData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
|
||||
this.ignoreOldLightData = ignoreOldLightData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitmask() {
|
||||
return bitmask;
|
||||
|
@ -19,6 +19,10 @@ public interface Chunk {
|
||||
return isFullChunk();
|
||||
}
|
||||
|
||||
boolean isIgnoreOldLightData();
|
||||
|
||||
void setIgnoreOldLightData(boolean ignoreOldLightData);
|
||||
|
||||
int getBitmask();
|
||||
|
||||
ChunkSection[] getSections();
|
||||
|
@ -9,7 +9,7 @@ public class Chunk1_8 extends BaseChunk {
|
||||
private boolean unloadPacket;
|
||||
|
||||
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||
super(x, z, groundUp, bitmask, sections, biomeData, blockEntities);
|
||||
super(x, z, groundUp, false, bitmask, sections, biomeData, blockEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class ProtocolVersion {
|
||||
register(v1_15 = new ProtocolVersion(573, "1.15"));
|
||||
register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
|
||||
register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
|
||||
register(v1_16 = new ProtocolVersion(730, "1.16"));
|
||||
register(v1_16 = new ProtocolVersion(732, "1.16"));
|
||||
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class ItemRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
// Sub 1.16
|
||||
public void registerEntityEquipment(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
@ -58,6 +59,25 @@ public class ItemRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
// 1.16+
|
||||
public void registerEntityEquipmentArray(ClientboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
|
||||
handler(wrapper -> {
|
||||
byte slot;
|
||||
do {
|
||||
slot = wrapper.read(Type.BYTE);
|
||||
// & 0x7F into an extra variable if slot is needed
|
||||
toClient.rewrite(wrapper.passthrough(type));
|
||||
} while ((slot & 0xFFFFFF80) != 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCreativeInvAction(ServerboundPacketType packetType, Type<Item> type) {
|
||||
protocol.registerIncoming(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,7 +62,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,7 +95,19 @@ public class InventoryPackets {
|
||||
});
|
||||
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
|
||||
handler(wrapper -> {
|
||||
int slot = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.BYTE, (byte) slot);
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -47,6 +47,9 @@ public class WorldPackets {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
||||
wrapper.write(new Chunk1_16Type(clientWorld), chunk);
|
||||
|
||||
chunk.setIgnoreOldLightData(chunk.isFullChunk());
|
||||
|
||||
for (int s = 0; s < 16; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
|
@ -29,6 +29,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
boolean fullChunk = input.readBoolean();
|
||||
boolean ignoreOldLightData = input.readBoolean();
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
CompoundTag heightMap = Type.NBT.read(input);
|
||||
|
||||
@ -62,7 +63,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, ignoreOldLightData, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,6 +72,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
||||
output.writeInt(chunk.getZ());
|
||||
|
||||
output.writeBoolean(chunk.isFullChunk());
|
||||
output.writeBoolean(chunk.isIgnoreOldLightData());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
Type.NBT.write(output, chunk.getHeightMap());
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, nbtData);
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, false, primaryBitmask, sections, biomeData, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, false, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user