aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorviciscat <[email protected]>2024-03-16 20:28:50 +0100
committerGitHub <[email protected]>2024-03-16 20:28:50 +0100
commit99a641690abd3d3669249ce10243e0739a13af33 (patch)
tree2adf28a87ba5cde8ed3af90c61b137ca46fd7f45
parentd361a7f60912250ceeee9461f1f97d23dd87ff76 (diff)
downloadPaper-99a641690abd3d3669249ce10243e0739a13af33.tar.gz
Paper-99a641690abd3d3669249ce10243e0739a13af33.zip
Expand Hopper BlockState API (#10328)
-rw-r--r--patches/api/0467-Expanded-Hopper-API.patch32
-rw-r--r--patches/server/1056-Expanded-Hopper-API.patch31
2 files changed, 63 insertions, 0 deletions
diff --git a/patches/api/0467-Expanded-Hopper-API.patch b/patches/api/0467-Expanded-Hopper-API.patch
new file mode 100644
index 0000000000..51cb6dfee2
--- /dev/null
+++ b/patches/api/0467-Expanded-Hopper-API.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: vicisacat <[email protected]>
+Date: Fri, 15 Mar 2024 17:35:18 +0100
+Subject: [PATCH] Expanded Hopper API
+
+
+diff --git a/src/main/java/org/bukkit/block/Hopper.java b/src/main/java/org/bukkit/block/Hopper.java
+index 7ade312f180b7e30871d3a3240c76325cc369c26..61ea33c1f2dbb546a66f945a01feae437b1381e0 100644
+--- a/src/main/java/org/bukkit/block/Hopper.java
++++ b/src/main/java/org/bukkit/block/Hopper.java
+@@ -6,4 +6,20 @@ import org.bukkit.loot.Lootable;
+ /**
+ * Represents a captured state of a hopper.
+ */
+-public interface Hopper extends Container, LootableBlockInventory { } // Paper
++public interface Hopper extends Container, LootableBlockInventory { // Paper
++ // Paper start - Expanded Hopper API
++ /**
++ * Sets the cooldown before the hopper transfers or sucks in another item
++ * @param cooldown the cooldown in ticks
++ * @throws IllegalArgumentException if the passed cooldown value is negative.
++ */
++ void setTransferCooldown(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int cooldown);
++
++ /**
++ * Returns the cooldown before the hopper transfers or sucks in another item
++ * @return the cooldown in ticks
++ */
++ int getTransferCooldown();
++ // Paper end - Expanded Hopper API
++}
++
diff --git a/patches/server/1056-Expanded-Hopper-API.patch b/patches/server/1056-Expanded-Hopper-API.patch
new file mode 100644
index 0000000000..67efc0d7a2
--- /dev/null
+++ b/patches/server/1056-Expanded-Hopper-API.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: vicisacat <[email protected]>
+Date: Fri, 15 Mar 2024 17:35:40 +0100
+Subject: [PATCH] Expanded Hopper API
+
+== AT ==
+public net.minecraft.world.level.block.entity.HopperBlockEntity setCooldown(I)V
+public net.minecraft.world.level.block.entity.HopperBlockEntity cooldownTime
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java b/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
+index d446f18df647484e2f05ab642b73e914b06fdfed..af5f27fb5ebad1e05da2b7d1a0710a2ef9c6ebbe 100644
+--- a/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
+@@ -34,4 +34,17 @@ public class CraftHopper extends CraftLootable<HopperBlockEntity> implements Hop
+ public CraftHopper copy() {
+ return new CraftHopper(this);
+ }
++
++ // Paper start - Expanded Hopper API
++ @Override
++ public void setTransferCooldown(final int cooldown) {
++ com.google.common.base.Preconditions.checkArgument(cooldown >= 0, "Hooper transfer cooldown cannot be negative (" + cooldown + ")");
++ getSnapshot().setCooldown(cooldown);
++ }
++
++ @Override
++ public int getTransferCooldown() {
++ return getSnapshot().cooldownTime;
++ }
++ // Paper end - Expanded Hopper API
+ }