mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Add UpdateLightPacket
This commit is contained in:
parent
01128ae796
commit
10710b62a2
2 changed files with 62 additions and 2 deletions
|
@ -137,6 +137,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlaySo
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerSpawnPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateLightPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateViewDistancePacket;
|
||||
|
@ -402,7 +403,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerIncoming(0x21, ServerChunkDataPacket.class);
|
||||
this.registerIncoming(0x22, ServerPlayEffectPacket.class);
|
||||
this.registerIncoming(0x23, ServerSpawnParticlePacket.class);
|
||||
// 0x24 Update Light - New
|
||||
this.registerIncoming(0x24, ServerUpdateLightPacket.class);
|
||||
this.registerIncoming(0x25, ServerJoinGamePacket.class);
|
||||
this.registerIncoming(0x26, ServerMapDataPacket.class);
|
||||
this.registerIncoming(0x27, ServerTradeListPacket.class);
|
||||
|
@ -591,7 +592,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerOutgoing(0x21, ServerChunkDataPacket.class);
|
||||
this.registerOutgoing(0x22, ServerPlayEffectPacket.class);
|
||||
this.registerOutgoing(0x23, ServerSpawnParticlePacket.class);
|
||||
// 0x24 Update Light - New
|
||||
this.registerOutgoing(0x24, ServerUpdateLightPacket.class);
|
||||
this.registerOutgoing(0x25, ServerJoinGamePacket.class);
|
||||
this.registerOutgoing(0x26, ServerMapDataPacket.class);
|
||||
this.registerOutgoing(0x27, ServerTradeListPacket.class);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server.world;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
public class ServerUpdateLightPacket extends MinecraftPacket {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
private int skyLightMask;
|
||||
private int blockLightMask;
|
||||
private int emptySkyLightMask;
|
||||
private int emptyBlockLightMask;
|
||||
private List<byte[]> skyLightArrays;
|
||||
private List<byte[]> blockLightArrays;
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.chunkX = in.readVarInt();
|
||||
this.chunkZ = in.readVarInt();
|
||||
this.skyLightMask = in.readVarInt();
|
||||
this.blockLightMask = in.readVarInt();
|
||||
this.emptySkyLightMask = in.readVarInt();
|
||||
this.emptyBlockLightMask = in.readVarInt();
|
||||
this.skyLightArrays = new ArrayList<>();
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if ((this.skyLightMask & 1 << i) != 0) {
|
||||
this.skyLightArrays.add(in.readBytes(2048));
|
||||
}
|
||||
}
|
||||
this.blockLightArrays = new ArrayList<>();
|
||||
for (int i = 0; i < 18; i++) {
|
||||
if ((this.blockLightMask & 1 << i) != 0) {
|
||||
this.blockLightArrays.add(in.readBytes(2048));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.chunkX);
|
||||
out.writeVarInt(this.chunkZ);
|
||||
out.writeVarInt(this.skyLightMask);
|
||||
out.writeVarInt(this.blockLightMask);
|
||||
out.writeVarInt(this.emptySkyLightMask);
|
||||
out.writeVarInt(this.emptyBlockLightMask);
|
||||
for (byte[] bytes : skyLightArrays) {
|
||||
out.writeBytes(bytes);
|
||||
}
|
||||
for (byte[] bytes : blockLightArrays) {
|
||||
out.writeBytes(bytes);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue