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:
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user