75 lines
5.0 KiB
Diff
75 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Mon, 10 Jun 2024 10:51:08 +0000
|
|
Subject: [PATCH] Try fixing folia off region POI accessing issue
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..7812a71f05dd32646037afd22cdabf72bb23b0d1
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
|
@@ -0,0 +1,25 @@
|
|
+package me.earthme.luminol.config.modules.fixes;
|
|
+
|
|
+import me.earthme.luminol.config.ConfigInfo;
|
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
|
+import me.earthme.luminol.config.IConfigModule;
|
|
+
|
|
+public class FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
|
|
+ @ConfigInfo(baseName = "enabled", comments =
|
|
+ """
|
|
+ The POIManager of folia has something which has not been patched\s
|
|
+ for regionized ticking and these would trigger the async catcher\s
|
|
+ and make the server crash.If you would like to prevent it and didn't\s
|
|
+ mind the side effect(currently unknown), you can enable this""")
|
|
+ public static boolean enabled = false;
|
|
+
|
|
+ @Override
|
|
+ public EnumConfigCategory getCategory() {
|
|
+ return EnumConfigCategory.FIXES;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getBaseName() {
|
|
+ return "folia.fix_poi_access_off_region";
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
|
index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..dd1baee4bc36b28b7e10d98525d55cbcfb562649 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
|
@@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.GlobalPos;
|
|
import net.minecraft.core.Holder;
|
|
import net.minecraft.network.protocol.game.DebugPackets;
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.entity.PathfinderMob;
|
|
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
|
|
@@ -33,7 +34,10 @@ public class YieldJobSite {
|
|
} else if (entity.getVillagerData().getProfession() != VillagerProfession.NONE) {
|
|
return false;
|
|
} else {
|
|
- BlockPos blockPos = context.<GlobalPos>get(potentialJobSite).pos();
|
|
+ final GlobalPos globalPos = context.<GlobalPos>get(potentialJobSite); //Luminol - Try fixing off main POI accessing
|
|
+ final ServerLevel targetLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()); //Luminol - Try fixing off main POI accessing
|
|
+ BlockPos blockPos = globalPos.pos(); //Luminol - Try fixing off main POI accessing
|
|
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(targetLevel, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) return true; //Luminol - Try fixing off main POI accessing
|
|
Optional<Holder<PoiType>> optional = world.getPoiManager().getType(blockPos);
|
|
if (optional.isEmpty()) {
|
|
return true;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
index a26cc9b81d93f04cd741a2558f0787bb2037351e..c7860dca86e4a9251d81d98129347e1a59c09f04 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
@@ -82,7 +82,7 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
|
|
|
public Stream<PoiRecord> getInSquare(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) {
|
|
int i = Math.floorDiv(radius, 16) + 1;
|
|
- return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> {
|
|
+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? io.papermc.paper.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access
|
|
BlockPos blockPos2 = poi.getPos();
|
|
return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius;
|
|
});
|