2023-05-14 08:26:08 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
Date: Sat, 13 May 2023 17:13:40 -0700
|
|
|
|
Subject: [PATCH] Do not access POI data for lodestone compass
|
|
|
|
|
|
|
|
Instead, we can just check the loaded chunk's block position for
|
|
|
|
the lodestone block, as that is at least safe enough for the light
|
|
|
|
engine compared to the POI access. This should make it safe for
|
|
|
|
off-region access.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/CompassItem.java b/src/main/java/net/minecraft/world/item/CompassItem.java
|
2024-01-21 12:33:21 +08:00
|
|
|
index b3c67c954acf7e518d89d6af65a55d6f22dac059..eea1066379805a4bdef9b496a92ad956d0c84ac7 100644
|
2023-05-14 08:26:08 +08:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/CompassItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/CompassItem.java
|
2024-01-21 12:33:21 +08:00
|
|
|
@@ -77,7 +77,10 @@ public class CompassItem extends Item implements Vanishable {
|
2023-05-14 08:26:08 +08:00
|
|
|
Optional<ResourceKey<Level>> optional = getLodestoneDimension(compoundTag);
|
|
|
|
if (optional.isPresent() && optional.get() == world.dimension() && compoundTag.contains("LodestonePos")) {
|
|
|
|
BlockPos blockPos = NbtUtils.readBlockPos(compoundTag.getCompound("LodestonePos"));
|
2024-01-21 12:33:21 +08:00
|
|
|
- if (!world.isInWorldBounds(blockPos) || (world.hasChunkAt(blockPos) && !((ServerLevel)world).getPoiManager().existsAtPosition(PoiTypes.LODESTONE, blockPos))) { // Paper - Prevent compass from loading chunks
|
2023-05-14 08:26:08 +08:00
|
|
|
+ // Folia start - do not access the POI data off-region
|
|
|
|
+ net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkIfLoaded(blockPos);
|
2024-01-21 12:33:21 +08:00
|
|
|
+ if (!world.isInWorldBounds(blockPos) || chunk != null && chunk.getBlockState(blockPos).getBlock() != Blocks.LODESTONE) { // Paper - Prevent compass from loading chunks
|
2023-05-14 08:26:08 +08:00
|
|
|
+ // Folia end - do not access the POI data off-region
|
|
|
|
compoundTag.remove("LodestonePos");
|
|
|
|
}
|
|
|
|
}
|