From 8cfed96b39085fb7a9efd303eef52a07c2ef30ae Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 9 Sep 2023 10:36:10 +0200 Subject: [PATCH] Compilable (Small sections remaining) --- .../packet/SetBlockBufferPacketListener.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java b/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java index abd4336..c04688d 100644 --- a/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/SetBlockBufferPacketListener.java @@ -1,6 +1,7 @@ package com.moulberry.axiom.packet; import com.moulberry.axiom.AxiomConstants; +import com.moulberry.axiom.AxiomPaper; import com.moulberry.axiom.buffer.BiomeBuffer; import com.moulberry.axiom.buffer.CompressedBlockEntity; import com.moulberry.axiom.buffer.MojBuf; @@ -9,18 +10,17 @@ import com.moulberry.axiom.integration.RegionProtection; import com.moulberry.axiom.integration.VersionTranslator; import io.netty.buffer.ByteBuf; import net.minecraft.core.BlockPos; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.game.ClientboundChunksBiomesPacket; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.PalettedContainer; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; +import org.bukkit.craftbukkit.v1_20_R1.CraftChunk; import org.bukkit.entity.Player; import java.util.*; @@ -85,13 +85,14 @@ public class SetBlockBufferPacketListener implements AxiomPacketListener { changedChunks.add(world.getChunkAt(x << 2, z << 2)); }); + ServerLevel level = AxiomPaper.convert(world); //TODO multiversioning - var chunkMap = world.getChunkSource().chunkMap; + ChunkMap chunkMap = level.getChunkSource().chunkMap; HashMap> map = new HashMap<>(); - for (LevelChunk chunk : changedChunks) { - ChunkPos chunkPos = chunk.getPos(); + for (Chunk chunk : changedChunks) { + ChunkPos chunkPos = new ChunkPos(chunk.getX(), chunk.getZ()); for (ServerPlayer serverPlayer2 : chunkMap.getPlayers(chunkPos, false)) { - map.computeIfAbsent(serverPlayer2, serverPlayer -> new ArrayList<>()).add(chunk); + map.computeIfAbsent(serverPlayer2, serverPlayer -> new ArrayList<>()).add((LevelChunk) ((CraftChunk)chunk).getHandle(ChunkStatus.BIOMES)); } } map.forEach((serverPlayer, list) -> serverPlayer.connection.send(ClientboundChunksBiomesPacket.forChunks(list)));