Skip to content

Commit

Permalink
Fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Dec 14, 2024
1 parent 434ab8f commit e7f96ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,17 @@ public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeB
PalettedContainerRO<Holder<Biome>>[] biome = (includeBiome || includeBiomeTempRain) ? new PalettedContainer[cs.length] : null;

net.minecraft.core.Registry<Biome> iregistry = worldServer.registryAccess().registryOrThrow(Registries.BIOME);
Codec<PalettedContainerRO<Holder<Biome>>> 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));
Expand All @@ -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<Holder<net.minecraft.world.level.biome.Biome>>) cs[i].getBiomes()).copy(); // Paper - use copy instead of round tripping with codecs
}
}

Expand Down

0 comments on commit e7f96ba

Please sign in to comment.