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

Configure fluid breaking redstone

This commit is contained in:
Samsuik
2023-12-09 00:15:05 +00:00
parent 25829fd55c
commit e70fee69e6
3 changed files with 32 additions and 7 deletions

View File

@@ -621,10 +621,10 @@ index 0000000000000000000000000000000000000000..5fc23a0b579d7cbe03baf5324bef887a
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..8edf0dd545b0664a8ae0079be7d92678f95374d0
index 0000000000000000000000000000000000000000..d2549a7907d341bbc7a9a317aa13f2df1a369870
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -0,0 +1,164 @@
@@ -0,0 +1,168 @@
+package me.samsuik.sakura.configuration;
+
+import com.mojang.logging.LogUtils;
@@ -732,9 +732,13 @@ index 0000000000000000000000000000000000000000..8edf0dd545b0664a8ae0079be7d92678
+
+ public Technical technical;
+ public class Technical extends ConfigurationPart {
+ @NestedSetting({"redstone", "redstone-cache"})
+ public boolean redstoneCache = false;
+ public boolean dispenserRandomItemSelection = true;
+
+ public Redstone redstone = new Redstone();
+ public class Redstone extends ConfigurationPart {
+ public boolean redstoneCache = false;
+ public boolean fluidsBreakRedstone = true;
+ }
+ }
+
+ public Players players;

View File

@@ -53,7 +53,7 @@ index 22a2547810d0c029f29685faddf7ac21cde2df0b..0fad13769f5727279430ac7f650f3d4d
diff --git a/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java b/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java
new file mode 100644
index 0000000000000000000000000000000000000000..f9ffc75f3c349c6a1cb614ed925b2e90b8bec06f
index 0000000000000000000000000000000000000000..455e51b93c50f8bf3e84d11f373be7b1dc9fc6eb
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java
@@ -0,0 +1,283 @@
@@ -129,7 +129,7 @@ index 0000000000000000000000000000000000000000..f9ffc75f3c349c6a1cb614ed925b2e90
+ }
+
+ public boolean applyFromCache(BlockPos position, int previous, int next) {
+ if (this.level.sakuraConfig().technical.redstoneCache) {
+ if (this.level.sakuraConfig().technical.redstone.redstoneCache) {
+ long key = cacheKey(position, previous, next);
+ RedstoneCache cache = this.wireCaches.get(key);
+
@@ -182,7 +182,7 @@ index 0000000000000000000000000000000000000000..f9ffc75f3c349c6a1cb614ed925b2e90
+ }
+
+ public void beginTracking(BlockPos position, int previous, int next) {
+ if (++this.depth == 1 && this.level.sakuraConfig().technical.redstoneCache) {
+ if (++this.depth == 1 && this.level.sakuraConfig().technical.redstone.redstoneCache) {
+ long key = cacheKey(position, previous, next);
+
+ if (this.wireCaches.containsKey(key)) {

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Sat, 9 Dec 2023 00:11:48 +0000
Subject: [PATCH] Configure fluids breaking redstone
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 96ccad764cb6424ffe561c558cd11200d89ff541..cc6f05998f2d73b09350c337e10ef3f57a9e0e68 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -480,6 +480,10 @@ public abstract class FlowingFluid extends Fluid {
LiquidBlockContainer ifluidcontainer = (LiquidBlockContainer) block;
return ifluidcontainer.canPlaceLiquid((Player) null, world, pos, state, fluid);
+ // Sakura start
+ } else if (world instanceof Level level && !level.sakuraConfig().technical.redstone.fluidsBreakRedstone && state.isSignalSource()) {
+ return false;
+ // Sakura end
} else {
return !(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN) ? (!state.is(Blocks.NETHER_PORTAL) && !state.is(Blocks.END_PORTAL) && !state.is(Blocks.END_GATEWAY) && !state.is(Blocks.STRUCTURE_VOID) ? !state.blocksMotion() : false) : false;
}