From 280147491d18c666b4d5843abdf934d1f638edf3 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 11 Jul 2019 07:52:55 +1000 Subject: [PATCH] protochunk --- .../boydti/fawe/bukkit/beta/BukkitQueue.java | 11 +++-- .../fawe/bukkit/v1_14/BukkitQueue_1_14.java | 49 ++++++++++++------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java index 2e48d7329..f27b66fcf 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitQueue.java @@ -33,8 +33,10 @@ import net.minecraft.server.v1_14_R1.DataPaletteBlock; import net.minecraft.server.v1_14_R1.DataPaletteLinear; import net.minecraft.server.v1_14_R1.GameProfileSerializer; import net.minecraft.server.v1_14_R1.IBlockData; +import net.minecraft.server.v1_14_R1.IChunkAccess; import net.minecraft.server.v1_14_R1.PlayerChunk; import net.minecraft.server.v1_14_R1.PlayerChunkMap; +import net.minecraft.server.v1_14_R1.ProtoChunkExtension; import net.minecraft.server.v1_14_R1.WorldServer; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; @@ -206,11 +208,12 @@ public class BukkitQueue extends SimpleCharQueueExtent { public static Chunk ensureLoaded(net.minecraft.server.v1_14_R1.World nmsWorld, int X, int Z) { ChunkProviderServer provider = (ChunkProviderServer) nmsWorld.getChunkProvider(); - - - Chunk nmsChunk = (Chunk) provider.getChunkAt(X, Z, ChunkStatus.FEATURES, false);; + IChunkAccess nmsChunk = provider.getChunkAt(X, Z, ChunkStatus.FEATURES, false); if (nmsChunk != null) { - return nmsChunk; + if (nmsChunk instanceof ProtoChunkExtension) { + return ((ProtoChunkExtension) nmsChunk).u(); + } + return (Chunk) nmsChunk; } if (Fawe.isMainThread()) { return nmsWorld.getChunkAt(X, Z); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java index 1a9cd9ae9..a8ad08768 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java @@ -49,6 +49,7 @@ import net.minecraft.server.v1_14_R1.PacketDataSerializer; import net.minecraft.server.v1_14_R1.PacketPlayOutMultiBlockChange; import net.minecraft.server.v1_14_R1.PlayerChunk; import net.minecraft.server.v1_14_R1.PlayerChunkMap; +import net.minecraft.server.v1_14_R1.ProtoChunkExtension; import net.minecraft.server.v1_14_R1.RegistryID; import net.minecraft.server.v1_14_R1.TileEntity; import net.minecraft.server.v1_14_R1.WorldChunkManager; @@ -70,7 +71,7 @@ import java.util.concurrent.atomic.LongAdder; import java.util.function.Consumer; import java.util.function.Supplier; -public class BukkitQueue_1_14 extends BukkitQueue_0 { +public class BukkitQueue_1_14 extends BukkitQueue_0 { public final static Field fieldBits; public final static Field fieldPalette; @@ -204,12 +205,12 @@ public class BukkitQueue_1_14 extends BukkitQueue_0 tiles = chunk.getTileEntities(); + public CompoundTag getTileEntity(IChunkAccess chunk, int x, int y, int z) { + Map tiles = ((net.minecraft.server.v1_14_R1.Chunk) cast(chunk)).getTileEntities(); pos.c(x, y, z); TileEntity tile = tiles.get(pos); return tile != null ? getTag(tile) : null;