diff --git a/modules/banner-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/modules/banner-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index f859f66fe..7e1a2a40e 100644 --- a/modules/banner-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/modules/banner-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -576,14 +576,14 @@ public void clearPlugins() { public void callEvent(@NotNull Event event) { if (event.isAsynchronous()) { if (Thread.holdsLock(this)) { - throw new IllegalStateException(event.getEventName() + " cannot be triggered asynchronously from inside synchronized code."); + return; } if (server.isPrimaryThread()) { - throw new IllegalStateException(event.getEventName() + " cannot be triggered asynchronously from primary server thread."); + return; } } else { if (!server.isPrimaryThread()) { - throw new IllegalStateException(event.getEventName() + " cannot be triggered asynchronously from another thread."); + return; } } diff --git a/modules/banner-server/src/main/java/org/bukkit/craftbukkit/v1_20_R1/CraftChunk.java b/modules/banner-server/src/main/java/org/bukkit/craftbukkit/v1_20_R1/CraftChunk.java index 10532f8c2..c249485ac 100644 --- a/modules/banner-server/src/main/java/org/bukkit/craftbukkit/v1_20_R1/CraftChunk.java +++ b/modules/banner-server/src/main/java/org/bukkit/craftbukkit/v1_20_R1/CraftChunk.java @@ -303,13 +303,17 @@ public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeB PalettedContainerRO>[] biome = (includeBiome || includeBiomeTempRain) ? new PalettedContainer[cs.length] : null; net.minecraft.core.Registry iregistry = worldServer.registryAccess().registryOrThrow(Registries.BIOME); - Codec>> biomeCodec = PalettedContainer.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS)); for (int i = 0; i < cs.length; i++) { - CompoundTag data = new CompoundTag(); - data.put("block_states", ChunkSerializer.BLOCK_STATE_CODEC.encodeStart(NbtOps.INSTANCE, cs[i].getStates()).get().left().get()); - sectionBlockIDs[i] = ChunkSerializer.BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, data.getCompound("block_states")).get().left().get(); + // Paper start + sectionEmpty[i] = cs[i].hasOnlyAir(); // Paper - fix sectionEmpty array not being filled + if (!sectionEmpty[i]) { + sectionBlockIDs[i] = cs[i].getStates().copy(); // Paper - use copy instead of round tripping with codecs + } else { + sectionBlockIDs[i] = emptyBlockIDs; // Paper - use cached instance for empty block sections + } + // Paper end LevelLightEngine lightengine = worldServer.getLightEngine(); DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(x, i, z)); @@ -328,8 +332,7 @@ public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeB } if (biome != null) { - data.put("biomes", biomeCodec.encodeStart(NbtOps.INSTANCE, cs[i].getBiomes()).get().left().get()); - biome[i] = biomeCodec.parse(NbtOps.INSTANCE, data.getCompound("biomes")).get().left().get(); + biome[i] = ((PalettedContainer>) cs[i].getBiomes()).copy(); // Paper - use copy instead of round tripping with codecs } }