use of net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket in project BleachHack by BleachDrinker420.
the class ChunkProcessor method onReadPacket.
@BleachSubscribe
public void onReadPacket(EventPacket.Read event) {
if (MinecraftClient.getInstance().world == null)
return;
if (updateBlockConsumer != null && event.getPacket() instanceof BlockUpdateS2CPacket) {
BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
executor.execute(() -> updateBlockConsumer.accept(packet.getPos(), packet.getState()));
} else if (updateBlockConsumer != null && event.getPacket() instanceof ExplosionS2CPacket) {
ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
for (BlockPos pos : packet.getAffectedBlocks()) {
executor.execute(() -> updateBlockConsumer.accept(pos, Blocks.AIR.getDefaultState()));
}
} else if (updateBlockConsumer != null && event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
packet.visitUpdates((pos, state) -> {
BlockPos impos = /*ter*/
pos.toImmutable();
executor.execute(() -> updateBlockConsumer.accept(impos, state));
});
} else if (loadChunkConsumer != null && event.getPacket() instanceof ChunkDataS2CPacket) {
ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
WorldChunk chunk = new WorldChunk(MinecraftClient.getInstance().world, cp, null);
chunk.loadFromPacket(null, packet.getReadBuffer(), new NbtCompound(), packet.getVerticalStripBitmask());
executor.execute(() -> loadChunkConsumer.accept(cp, chunk));
} else if (unloadChunkConsumer != null && event.getPacket() instanceof UnloadChunkS2CPacket) {
UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
WorldChunk chunk = MinecraftClient.getInstance().world.getChunk(cp.x, cp.z);
executor.execute(() -> unloadChunkConsumer.accept(cp, chunk));
}
}
use of net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket in project Hypnotic-Client by Hypnotic-Development.
the class Search method receivePacket.
@EventTarget
public void receivePacket(EventReceivePacket event) {
if (event.getPacket() instanceof DisconnectS2CPacket || event.getPacket() instanceof GameJoinS2CPacket || event.getPacket() instanceof PlayerRespawnS2CPacket) {
reset();
} else if (event.getPacket() instanceof BlockUpdateS2CPacket) {
BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
queuedBlocks.add(Pair.of(packet.getPos(), packet.getState()));
} else if (event.getPacket() instanceof ExplosionS2CPacket) {
ExplosionS2CPacket packet = (ExplosionS2CPacket) event.getPacket();
for (BlockPos pos : packet.getAffectedBlocks()) {
queuedBlocks.add(Pair.of(pos, Blocks.AIR.getDefaultState()));
}
} else if (event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
packet.visitUpdates((pos, state) -> queuedBlocks.add(Pair.of(pos.toImmutable(), state)));
} else if (event.getPacket() instanceof ChunkDataS2CPacket) {
ChunkDataS2CPacket packet = (ChunkDataS2CPacket) event.getPacket();
ChunkPos cp = new ChunkPos(packet.getX(), packet.getZ());
queuedChunks.add(cp);
queuedUnloads.remove(cp);
} else if (event.getPacket() instanceof UnloadChunkS2CPacket) {
UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) event.getPacket();
queuedUnloads.add(new ChunkPos(packet.getX(), packet.getZ()));
}
}
use of net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket in project Hypnotic-Client by Hypnotic-Development.
the class NewChunks method onReadPacket.
@EventTarget
public void onReadPacket(EventReceivePacket event) {
Direction[] searchDirs = new Direction[] { Direction.EAST, Direction.NORTH, Direction.WEST, Direction.SOUTH, Direction.UP };
if (event.getPacket() instanceof ChunkDeltaUpdateS2CPacket) {
ChunkDeltaUpdateS2CPacket packet = (ChunkDeltaUpdateS2CPacket) event.getPacket();
packet.visitUpdates((pos, state) -> {
if (!state.getFluidState().isEmpty() && !state.getFluidState().isStill()) {
ChunkPos chunkPos = new ChunkPos(pos);
for (Direction dir : searchDirs) {
if (mc.world.getBlockState(pos.offset(dir)).getFluidState().isStill() && !oldChunks.contains(chunkPos)) {
newChunks.add(chunkPos);
return;
}
}
}
});
} else if (event.getPacket() instanceof BlockUpdateS2CPacket) {
BlockUpdateS2CPacket packet = (BlockUpdateS2CPacket) event.getPacket();
if (!packet.getState().getFluidState().isEmpty() && !packet.getState().getFluidState().isStill()) {
ChunkPos chunkPos = new ChunkPos(packet.getPos());
for (Direction dir : searchDirs) {
if (mc.world.getBlockState(packet.getPos().offset(dir)).getFluidState().isStill() && !oldChunks.contains(chunkPos)) {
newChunks.add(chunkPos);
return;
}
}
}
}
}
Aggregations