Fix wrong ticket update determination in RegionizedTaskQueue
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||||
|
Date: Sun, 26 Jul 2026 20:42:44 +0800
|
||||||
|
Subject: [PATCH] Fix wrong ticket update determination in RegionizedTaskQueue
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||||
|
index fefec2930716b02b8e14f4b4f0fe3226fe53a617..037697e6364c73057b1fbac354bd78d8bf35bc7b 100644
|
||||||
|
--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||||
|
+++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||||
|
@@ -289,14 +289,17 @@ public final class RegionizedTaskQueue {
|
||||||
|
boolean executeTickTasks = allowedTickTasks > 0;
|
||||||
|
boolean executeChunkTasks = allowedChunkTasks > 0;
|
||||||
|
boolean executeGlobalTasks = true;
|
||||||
|
+ boolean processedChunkTask = false; // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||||
|
|
||||||
|
do {
|
||||||
|
executeTickTasks = executeTickTasks && allowedTickTasks-- > 0 && tickTaskQueue.executeTask();
|
||||||
|
executeChunkTasks = executeChunkTasks && allowedChunkTasks-- > 0 && chunkTaskQueue.executeTask();
|
||||||
|
executeGlobalTasks = executeGlobalTasks && this.worldRegionTaskData.executeGlobalChunkTask();
|
||||||
|
+
|
||||||
|
+ processedChunkTask |= (executeChunkTasks | executeGlobalTasks); // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||||
|
} while (executeTickTasks | executeChunkTasks | executeGlobalTasks);
|
||||||
|
|
||||||
|
- if (allowedChunkTasks > 0) {
|
||||||
|
+ if (processedChunkTask) { // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||||
|
// if we executed chunk tasks, we should try to process ticket updates for full status changes
|
||||||
|
this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates();
|
||||||
|
}
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
|
||||||
Date: Sat, 25 Jul 2026 21:16:19 +0800
|
|
||||||
Subject: [PATCH] Lithium Optimizes Hoglin repellent search.
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
|
||||||
index 7022679c84e184999b416e06d1af2cc2500cb12b..ac8f4acc2aaee8ca9f7598d842ecf29f2ad73be3 100644
|
|
||||||
--- a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
|
||||||
+++ b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
|
||||||
@@ -16,6 +16,14 @@ import net.minecraft.world.entity.monster.hoglin.Hoglin;
|
|
||||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
|
||||||
|
|
||||||
public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
|
||||||
+ // Shiroha start - Lithium Optimizes Hoglin repellent search.
|
|
||||||
+ private static final java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> IS_VALID_REPELLENT_PREDICATE =
|
|
||||||
+ HoglinSpecificSensor::lithium$isValidRepellent;
|
|
||||||
+
|
|
||||||
+ private static boolean lithium$isValidRepellent(net.minecraft.world.level.block.state.BlockState blockState) {
|
|
||||||
+ return blockState.is(BlockTags.HOGLIN_REPELLENTS);
|
|
||||||
+ }
|
|
||||||
+ // Shiroha end - Lithium Optimizes Hoglin repellent search.
|
|
||||||
@Override
|
|
||||||
public Set<MemoryModuleType<?>> requires() {
|
|
||||||
return ImmutableSet.of(
|
|
||||||
@@ -30,8 +38,8 @@ public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doTick(final ServerLevel level, final Hoglin body) {
|
|
||||||
- Brain<?> brain = body.getBrain();
|
|
||||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.findNearestRepellent(level, body));
|
|
||||||
+ Brain<?> brain = body.getBrain();;
|
|
||||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Hoglin repellent search.
|
|
||||||
Optional<Piglin> adultPiglin = Optional.empty();
|
|
||||||
int adultPiglinCount = 0;
|
|
||||||
List<Hoglin> adultHoglins = Lists.newArrayList();
|
|
||||||
+94
-2
@@ -1,7 +1,7 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||||
Date: Sat, 25 Jul 2026 21:30:17 +0800
|
Date: Sat, 25 Jul 2026 21:16:19 +0800
|
||||||
Subject: [PATCH] Lithium Optimizes move to block goal
|
Subject: [PATCH] Lithium optimized non poi block searching
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||||
@@ -185,3 +185,95 @@ index c6e9b155c2341c13d569f28f54f0c1d2d7313676..7bd3c8a1c627cfd3e377a269c649c0c1
|
|||||||
+ }
|
+ }
|
||||||
+ // Shiorha end - Lithium Optimizes move to block goal
|
+ // Shiorha end - Lithium Optimizes move to block goal
|
||||||
}
|
}
|
||||||
|
diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||||
|
index ff0f99d4b560a1c0721885b0eba5bd5ab2087bd7..90beeee7b74324f81690776546713b4f04887f75 100644
|
||||||
|
--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||||
|
@@ -25,6 +25,19 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||||
|
private final Mob removerMob;
|
||||||
|
private int ticksSinceReachedGoal;
|
||||||
|
private static final int WAIT_AFTER_BLOCK_FOUND = 20;
|
||||||
|
+ // Shiroha start - Lithium Optimize remove block goal
|
||||||
|
+ private static final java.util.function.BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> IS_VALID_TARGET_ABOVE_BIPREDICATE =
|
||||||
|
+ RemoveBlockGoal::lithium$isValidTargetAbove;
|
||||||
|
+ //Split check condition in order to use maybeHas
|
||||||
|
+ private boolean lithium$isValidTargetBlock(net.minecraft.world.level.block.state.BlockState blockState){
|
||||||
|
+ return blockState.is(this.blockToRemove);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean lithium$isValidTargetAbove(ChunkAccess chunkAccess, BlockPos.MutableBlockPos mutable) {
|
||||||
|
+ return chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir()
|
||||||
|
+ && chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir();
|
||||||
|
+ }
|
||||||
|
+ // Shiroha end - Lithium Optimize remove block goal
|
||||||
|
|
||||||
|
public RemoveBlockGoal(final Block blockToRemove, final PathfinderMob mob, final double speedModifier, final int verticalSearchRange) {
|
||||||
|
super(mob, speedModifier, 24, verticalSearchRange);
|
||||||
|
@@ -39,7 +52,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||||
|
} else if (this.nextStartTick > 0) {
|
||||||
|
this.nextStartTick--;
|
||||||
|
return false;
|
||||||
|
- } else if (this.findNearestBlock()) {
|
||||||
|
+ } else if (((net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal) this).lithium$findNearestBlock(this::lithium$isValidTargetBlock, IS_VALID_TARGET_ABOVE_BIPREDICATE, false)) { // Shiroha - Lithium Optimize remove block goal
|
||||||
|
this.nextStartTick = reducedTickDelay(20);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
diff --git a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||||
|
index 7022679c84e184999b416e06d1af2cc2500cb12b..ac8f4acc2aaee8ca9f7598d842ecf29f2ad73be3 100644
|
||||||
|
--- a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||||
|
@@ -16,6 +16,14 @@ import net.minecraft.world.entity.monster.hoglin.Hoglin;
|
||||||
|
import net.minecraft.world.entity.monster.piglin.Piglin;
|
||||||
|
|
||||||
|
public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||||
|
+ // Shiroha start - Lithium Optimizes Hoglin repellent search.
|
||||||
|
+ private static final java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||||
|
+ HoglinSpecificSensor::lithium$isValidRepellent;
|
||||||
|
+
|
||||||
|
+ private static boolean lithium$isValidRepellent(net.minecraft.world.level.block.state.BlockState blockState) {
|
||||||
|
+ return blockState.is(BlockTags.HOGLIN_REPELLENTS);
|
||||||
|
+ }
|
||||||
|
+ // Shiroha end - Lithium Optimizes Hoglin repellent search.
|
||||||
|
@Override
|
||||||
|
public Set<MemoryModuleType<?>> requires() {
|
||||||
|
return ImmutableSet.of(
|
||||||
|
@@ -30,8 +38,8 @@ public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doTick(final ServerLevel level, final Hoglin body) {
|
||||||
|
- Brain<?> brain = body.getBrain();
|
||||||
|
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.findNearestRepellent(level, body));
|
||||||
|
+ Brain<?> brain = body.getBrain();;
|
||||||
|
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Hoglin repellent search.
|
||||||
|
Optional<Piglin> adultPiglin = Optional.empty();
|
||||||
|
int adultPiglinCount = 0;
|
||||||
|
List<Hoglin> adultHoglins = Lists.newArrayList();
|
||||||
|
diff --git a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||||
|
index 060a53da799a3036a343cc6f1d73e3e5ca4b7af9..7e5accce5a9183165e7604ca5e144e600b6f503d 100644
|
||||||
|
--- a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||||
|
@@ -26,6 +26,15 @@ import net.minecraft.world.level.block.CampfireBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||||
|
+ // Shiroha start - Lithium Optimizes Piglin repellent search.
|
||||||
|
+ private static final java.util.function.Predicate<BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||||
|
+ PiglinSpecificSensor::lithium$isValidRepellent;
|
||||||
|
+ private static boolean lithium$isValidRepellent(BlockState blockState){
|
||||||
|
+ final boolean isPiglinRepellent = blockState.is(BlockTags.PIGLIN_REPELLENTS);
|
||||||
|
+ return isPiglinRepellent && blockState.is(Blocks.SOUL_CAMPFIRE) ?
|
||||||
|
+ CampfireBlock.isLitCampfire(blockState) : isPiglinRepellent;
|
||||||
|
+ }
|
||||||
|
+ // Shiroha end - Lithium Optimizes Piglin repellent search.
|
||||||
|
@Override
|
||||||
|
public Set<MemoryModuleType<?>> requires() {
|
||||||
|
return ImmutableSet.of(
|
||||||
|
@@ -47,7 +56,7 @@ public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||||
|
@Override
|
||||||
|
protected void doTick(final ServerLevel level, final LivingEntity body) {
|
||||||
|
Brain<?> brain = body.getBrain();
|
||||||
|
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, findNearestRepellent(level, body));
|
||||||
|
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Piglin repellent search.
|
||||||
|
Optional<Mob> nemesis = Optional.empty();
|
||||||
|
Optional<Hoglin> huntableHoglin = Optional.empty();
|
||||||
|
Optional<Hoglin> babyHoglin = Optional.empty();
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
|
||||||
Date: Sat, 25 Jul 2026 21:30:26 +0800
|
|
||||||
Subject: [PATCH] Lithium Optimizes Piglin repellent search.
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
|
||||||
index 060a53da799a3036a343cc6f1d73e3e5ca4b7af9..7e5accce5a9183165e7604ca5e144e600b6f503d 100644
|
|
||||||
--- a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
|
||||||
+++ b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
|
||||||
@@ -26,6 +26,15 @@ import net.minecraft.world.level.block.CampfireBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
|
||||||
+ // Shiroha start - Lithium Optimizes Piglin repellent search.
|
|
||||||
+ private static final java.util.function.Predicate<BlockState> IS_VALID_REPELLENT_PREDICATE =
|
|
||||||
+ PiglinSpecificSensor::lithium$isValidRepellent;
|
|
||||||
+ private static boolean lithium$isValidRepellent(BlockState blockState){
|
|
||||||
+ final boolean isPiglinRepellent = blockState.is(BlockTags.PIGLIN_REPELLENTS);
|
|
||||||
+ return isPiglinRepellent && blockState.is(Blocks.SOUL_CAMPFIRE) ?
|
|
||||||
+ CampfireBlock.isLitCampfire(blockState) : isPiglinRepellent;
|
|
||||||
+ }
|
|
||||||
+ // Shiroha end - Lithium Optimizes Piglin repellent search.
|
|
||||||
@Override
|
|
||||||
public Set<MemoryModuleType<?>> requires() {
|
|
||||||
return ImmutableSet.of(
|
|
||||||
@@ -47,7 +56,7 @@ public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
|
||||||
@Override
|
|
||||||
protected void doTick(final ServerLevel level, final LivingEntity body) {
|
|
||||||
Brain<?> brain = body.getBrain();
|
|
||||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, findNearestRepellent(level, body));
|
|
||||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Piglin repellent search.
|
|
||||||
Optional<Mob> nemesis = Optional.empty();
|
|
||||||
Optional<Hoglin> huntableHoglin = Optional.empty();
|
|
||||||
Optional<Hoglin> babyHoglin = Optional.empty();
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
|
||||||
Date: Sat, 25 Jul 2026 21:33:58 +0800
|
|
||||||
Subject: [PATCH] Lithium Optimize remove block goal
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
||||||
index ff0f99d4b560a1c0721885b0eba5bd5ab2087bd7..90beeee7b74324f81690776546713b4f04887f75 100644
|
|
||||||
--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
||||||
+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
|
||||||
@@ -25,6 +25,19 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
|
||||||
private final Mob removerMob;
|
|
||||||
private int ticksSinceReachedGoal;
|
|
||||||
private static final int WAIT_AFTER_BLOCK_FOUND = 20;
|
|
||||||
+ // Shiroha start - Lithium Optimize remove block goal
|
|
||||||
+ private static final java.util.function.BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> IS_VALID_TARGET_ABOVE_BIPREDICATE =
|
|
||||||
+ RemoveBlockGoal::lithium$isValidTargetAbove;
|
|
||||||
+ //Split check condition in order to use maybeHas
|
|
||||||
+ private boolean lithium$isValidTargetBlock(net.minecraft.world.level.block.state.BlockState blockState){
|
|
||||||
+ return blockState.is(this.blockToRemove);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static boolean lithium$isValidTargetAbove(ChunkAccess chunkAccess, BlockPos.MutableBlockPos mutable) {
|
|
||||||
+ return chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir()
|
|
||||||
+ && chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir();
|
|
||||||
+ }
|
|
||||||
+ // Shiroha end - Lithium Optimize remove block goal
|
|
||||||
|
|
||||||
public RemoveBlockGoal(final Block blockToRemove, final PathfinderMob mob, final double speedModifier, final int verticalSearchRange) {
|
|
||||||
super(mob, speedModifier, 24, verticalSearchRange);
|
|
||||||
@@ -39,7 +52,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
|
||||||
} else if (this.nextStartTick > 0) {
|
|
||||||
this.nextStartTick--;
|
|
||||||
return false;
|
|
||||||
- } else if (this.findNearestBlock()) {
|
|
||||||
+ } else if (((net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal) this).lithium$findNearestBlock(this::lithium$isValidTargetBlock, IS_VALID_TARGET_ABOVE_BIPREDICATE, false)) { // Shiroha - Lithium Optimize remove block goal
|
|
||||||
this.nextStartTick = reducedTickDelay(20);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
Reference in New Issue
Block a user