9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-28 03:09:07 +00:00

Make the redstone cache configurable

This commit is contained in:
Samsuik
2025-02-19 01:01:51 +00:00
parent a342cb1722
commit 65011d8900
2 changed files with 9 additions and 3 deletions

View File

@@ -13,8 +13,8 @@ public record RedstoneNetworkSource(WorldConfiguration.Misc.RedstoneImplementati
BlockPos position, @Nullable Orientation orientation,
int updateDepth, int newPower, int oldPower) {
public static RedstoneNetworkSource createNetworkSource(Level level, BlockPos pos, @Nullable Orientation orientation, int newPower, int oldPower) {
LocalValueConfig localConfig = level.localConfig().config(pos);
public static RedstoneNetworkSource createNetworkSource(Level level, LocalValueConfig localConfig, BlockPos pos,
@Nullable Orientation orientation, int newPower, int oldPower) {
WorldConfiguration.Misc.RedstoneImplementation redstoneImplementation = localConfig.redstoneImplementation;
int updateDepth = level.neighborUpdater.getUpdateDepth();
return new RedstoneNetworkSource(redstoneImplementation, pos, orientation, updateDepth, newPower, oldPower);

View File

@@ -1,6 +1,7 @@
package me.samsuik.sakura.redstone;
import it.unimi.dsi.fastutil.objects.*;
import me.samsuik.sakura.configuration.local.LocalValueConfig;
import me.samsuik.sakura.utils.TickExpiry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -37,11 +38,16 @@ public final class RedstoneWireCache {
public boolean tryApplyFromCache(BlockPos pos, @Nullable Orientation orientation, int newPower, int oldPower) {
if (!this.isTrackingWireUpdates()) {
LocalValueConfig localConfig = this.level.localConfig().config(pos);
if (!localConfig.redstoneCache) {
return false;
}
if (this.updatingNetwork != null) {
return true;
}
RedstoneNetworkSource networkSource = RedstoneNetworkSource.createNetworkSource(this.level, pos, orientation, newPower, oldPower);
RedstoneNetworkSource networkSource = RedstoneNetworkSource.createNetworkSource(this.level, localConfig, pos, orientation, newPower, oldPower);
RedstoneNetwork network = this.networkCache.get(networkSource);
if (network != null) {
try {