mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-27 12:38:25 +01:00
commit
f570e77325
@ -8,16 +8,18 @@ public class BaseChunk implements Chunk {
|
|||||||
protected final int x;
|
protected final int x;
|
||||||
protected final int z;
|
protected final int z;
|
||||||
protected final boolean fullChunk;
|
protected final boolean fullChunk;
|
||||||
|
protected boolean ignoreOldLightData;
|
||||||
protected final int bitmask;
|
protected final int bitmask;
|
||||||
protected final ChunkSection[] sections;
|
protected final ChunkSection[] sections;
|
||||||
protected int[] biomeData;
|
protected int[] biomeData;
|
||||||
protected CompoundTag heightMap;
|
protected CompoundTag heightMap;
|
||||||
protected final List<CompoundTag> blockEntities;
|
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.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.fullChunk = fullChunk;
|
this.fullChunk = fullChunk;
|
||||||
|
this.ignoreOldLightData = ignoreOldLightData;
|
||||||
this.bitmask = bitmask;
|
this.bitmask = bitmask;
|
||||||
this.sections = sections;
|
this.sections = sections;
|
||||||
this.biomeData = biomeData;
|
this.biomeData = biomeData;
|
||||||
@ -25,8 +27,8 @@ public class BaseChunk implements Chunk {
|
|||||||
this.blockEntities = blockEntities;
|
this.blockEntities = blockEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseChunk(int x, int z, boolean fullChunk, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
public BaseChunk(int x, int z, boolean fullChunk, boolean ignoreOldLightData, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
||||||
this(x, z, fullChunk, bitmask, sections, biomeData, null, blockEntities);
|
this(x, z, fullChunk, ignoreOldLightData, bitmask, sections, biomeData, null, blockEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,6 +51,16 @@ public class BaseChunk implements Chunk {
|
|||||||
return fullChunk;
|
return fullChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIgnoreOldLightData() {
|
||||||
|
return ignoreOldLightData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIgnoreOldLightData(boolean ignoreOldLightData) {
|
||||||
|
this.ignoreOldLightData = ignoreOldLightData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBitmask() {
|
public int getBitmask() {
|
||||||
return bitmask;
|
return bitmask;
|
||||||
|
@ -19,6 +19,10 @@ public interface Chunk {
|
|||||||
return isFullChunk();
|
return isFullChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isIgnoreOldLightData();
|
||||||
|
|
||||||
|
void setIgnoreOldLightData(boolean ignoreOldLightData);
|
||||||
|
|
||||||
int getBitmask();
|
int getBitmask();
|
||||||
|
|
||||||
ChunkSection[] getSections();
|
ChunkSection[] getSections();
|
||||||
|
@ -9,7 +9,7 @@ public class Chunk1_8 extends BaseChunk {
|
|||||||
private boolean unloadPacket;
|
private boolean unloadPacket;
|
||||||
|
|
||||||
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
|
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 = new ProtocolVersion(573, "1.15"));
|
||||||
register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
|
register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
|
||||||
register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
|
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"));
|
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public class ItemRewriter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sub 1.16
|
||||||
public void registerEntityEquipment(ClientboundPacketType packetType, Type<Item> type) {
|
public void registerEntityEquipment(ClientboundPacketType packetType, Type<Item> type) {
|
||||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||||
@Override
|
@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) {
|
public void registerCreativeInvAction(ServerboundPacketType packetType, Type<Item> type) {
|
||||||
protocol.registerIncoming(packetType, new PacketRemapper() {
|
protocol.registerIncoming(packetType, new PacketRemapper() {
|
||||||
@Override
|
@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
|
@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
|
@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
|
@Override
|
||||||
|
@ -95,7 +95,19 @@ public class InventoryPackets {
|
|||||||
});
|
});
|
||||||
|
|
||||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
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() {
|
protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,6 +47,9 @@ public class WorldPackets {
|
|||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
||||||
wrapper.write(new Chunk1_16Type(clientWorld), chunk);
|
wrapper.write(new Chunk1_16Type(clientWorld), chunk);
|
||||||
|
|
||||||
|
chunk.setIgnoreOldLightData(chunk.isFullChunk());
|
||||||
|
|
||||||
for (int s = 0; s < 16; s++) {
|
for (int s = 0; s < 16; s++) {
|
||||||
ChunkSection section = chunk.getSections()[s];
|
ChunkSection section = chunk.getSections()[s];
|
||||||
if (section == null) continue;
|
if (section == null) continue;
|
||||||
|
@ -29,6 +29,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
int chunkZ = input.readInt();
|
int chunkZ = input.readInt();
|
||||||
|
|
||||||
boolean fullChunk = input.readBoolean();
|
boolean fullChunk = input.readBoolean();
|
||||||
|
boolean ignoreOldLightData = input.readBoolean();
|
||||||
int primaryBitmask = Type.VAR_INT.read(input);
|
int primaryBitmask = Type.VAR_INT.read(input);
|
||||||
CompoundTag heightMap = Type.NBT.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
|
@Override
|
||||||
@ -71,6 +72,7 @@ public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
|||||||
output.writeInt(chunk.getZ());
|
output.writeInt(chunk.getZ());
|
||||||
|
|
||||||
output.writeBoolean(chunk.isFullChunk());
|
output.writeBoolean(chunk.isFullChunk());
|
||||||
|
output.writeBoolean(chunk.isIgnoreOldLightData());
|
||||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||||
Type.NBT.write(output, chunk.getHeightMap());
|
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
|
@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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user