Bug fixes
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s

好罢有点多懒得总结了()
This commit is contained in:
2026-08-15 01:58:11 +08:00
parent f317990af4
commit 2734c91fca
6 changed files with 90 additions and 20 deletions
@@ -1,14 +1,33 @@
package io.nanachiyo0721.shiroha.config.modules.optimizations;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.mojang.logging.LogUtils;
import io.nanachiyo0721.shiroha.config.IConfigModule;
import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
import io.nanachiyo0721.shiroha.config.flags.DoNotLoad;
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import java.util.Set;
@ConfigClassInfo(category = EnumConfigCategory.OPTIMIZATIONS, name = "reduce_sensor_work", comments = "When it is enabled, it will delete the line of sight cache less often and use a faster nearby comparison.")
public class PetalReduceSensorWorkConfig implements IConfigModule {
@ConfigInfo(name = "enabled")
public static boolean enabled = true;
@ConfigInfo(name = "delay_ticks", comments = "The interval of each entity to drop the cache(in ticks)")
@ConfigInfo(name = "delay_ticks", comments = "The interval of each entity to drop the cache(in ticks (>0))")
public static int delayTicks = 10;
@DoNotLoad
private static final Logger LOGGER = LogUtils.getClassLogger();
@Override
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
if (delayTicks <= 0) {
LOGGER.info("Too small delay_ticks was set for reduce_sensor_work(expected > 0 but got {}), Clamping back to 1!", delayTicks);
delayTicks = 1;
}
}
}
@@ -12,7 +12,7 @@ public class Globals {
public static final int WORLD_SEED_LONGS = 16;
public static final int WORLD_SEED_BITS = WORLD_SEED_LONGS * 64;
public static final long[] worldSeed = new long[WORLD_SEED_LONGS];
public static final ThreadLocal<long[]> worldSeed = ThreadLocal.withInitial(() -> new long[WORLD_SEED_LONGS]);
public static final ThreadLocal<Integer> dimension = ThreadLocal.withInitial(() -> 0);
public enum Salt {
@@ -40,7 +40,7 @@ public class Globals {
if (!SecureSeedConfig.enabled) return;
long[] seed = world.worldGenSettings.options().featureSeed();
System.arraycopy(seed, 0, worldSeed, 0, WORLD_SEED_LONGS);
System.arraycopy(seed, 0, worldSeed.get(), 0, WORLD_SEED_LONGS);
int worldIndex = Iterables.indexOf(world.getServer().levelKeys(), it -> it == world.dimension());
if (worldIndex == -1)
worldIndex = world.getServer().levelKeys().size(); // if we are in world construction it may not have been added to the map yet
@@ -44,7 +44,7 @@ public class WorldgenCryptoRandom extends WorldgenRandom {
return;
}
System.arraycopy(Globals.worldSeed, 0, this.worldSeed, 0, Globals.WORLD_SEED_LONGS);
System.arraycopy(Globals.worldSeed.get(), 0, this.worldSeed, 0, Globals.WORLD_SEED_LONGS);
message[0] = ((long) x << 32) | ((long) z & 0xffffffffL);
message[1] = ((long) Globals.dimension.get() << 32) | ((long) salt & 0xffffffffL);
message[2] = typeSalt.ordinal();
@@ -100,7 +100,7 @@ public class WorldgenCryptoRandom extends WorldgenRandom {
WorldgenCryptoRandom fork = new WorldgenCryptoRandom(0, 0, null, 0);
System.arraycopy(Globals.worldSeed, 0, fork.worldSeed, 0, Globals.WORLD_SEED_LONGS);
System.arraycopy(Globals.worldSeed.get(), 0, fork.worldSeed, 0, Globals.WORLD_SEED_LONGS);
fork.message[0] = this.message[0];
fork.message[1] = this.message[1];
fork.message[2] = this.message[2];