mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
57 lines
2.9 KiB
Diff
57 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
|
Date: Fri, 23 Aug 2024 16:20:45 -0300
|
|
Subject: [PATCH] SparklyPaper: Allow throttling hopper checks if the target
|
|
container is full
|
|
|
|
Original project: https://github.com/SparklyPower/SparklyPaper
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
index aa55698303f7ffc6542f34311234be6c6b400a9d..e2fad47c7d6ff1a547404abf6abea84ff8fa867c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
@@ -441,6 +441,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
|
Direction enumdirection = blockEntity.facing.getOpposite();
|
|
|
|
if (HopperBlockEntity.isFullContainer(iinventory, enumdirection)) {
|
|
+ // Leaf start - Throttle hopper when full
|
|
+ if (org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.enabled && org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks > 0) {
|
|
+ blockEntity.setCooldown(org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks);
|
|
+ }
|
|
+ // Leaf end - Throttle hopper when full
|
|
return false;
|
|
} else {
|
|
// Paper start - Perf: Optimize Hoppers
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleHopperWhenFull.java b/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleHopperWhenFull.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3facc08ed627a710a1cf26c67abfbfa1b380fe44
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/ThrottleHopperWhenFull.java
|
|
@@ -0,0 +1,26 @@
|
|
+package org.dreeam.leaf.config.modules.opt;
|
|
+
|
|
+import org.dreeam.leaf.config.ConfigModules;
|
|
+import org.dreeam.leaf.config.EnumConfigCategory;
|
|
+
|
|
+public class ThrottleHopperWhenFull extends ConfigModules {
|
|
+
|
|
+ public String getBasePath() {
|
|
+ return EnumConfigCategory.PERF.getBaseKeyName() + ".throttle-hopper-when-full";
|
|
+ }
|
|
+
|
|
+ public static boolean enabled = false;
|
|
+ public static int skipTicks = 0;
|
|
+
|
|
+ @Override
|
|
+ public void onLoaded() {
|
|
+ enabled = config.getBoolean(getBasePath() + ".enabled", enabled, config.pickStringRegionBased("""
|
|
+ Throttles the hopper if target container is full.""",
|
|
+ """
|
|
+ 是否在目标容器已满时阻塞漏斗."""));
|
|
+ skipTicks = config.getInt(getBasePath() + ".skip-ticks", skipTicks, config.pickStringRegionBased("""
|
|
+ How many ticks to throttle when the Hopper is throttled.""",
|
|
+ """
|
|
+ 每次阻塞多少 tick."""));
|
|
+ }
|
|
+}
|