aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0492-Add-recipeBrewTime.patch
blob: f6b6f5b0ca5a068f15f85e16461e629635842217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tamion <70228790+notTamion@users.noreply.github.com>
Date: Fri, 20 Sep 2024 17:39:22 +0200
Subject: [PATCH] Add recipeBrewTime


diff --git a/src/main/java/org/bukkit/block/BrewingStand.java b/src/main/java/org/bukkit/block/BrewingStand.java
index fe155f14de7f7efb519f0585897ef43ee6c16bb9..7f27f0660d5487689eb77c8617951d708452c4e1 100644
--- a/src/main/java/org/bukkit/block/BrewingStand.java
+++ b/src/main/java/org/bukkit/block/BrewingStand.java
@@ -22,6 +22,29 @@ public interface BrewingStand extends Container {
      */
     void setBrewingTime(int brewTime);
 
+    // Paper start - Add recipeBrewTime
+    /**
+     * Sets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTime()}.
+     *
+     * @param recipeBrewTime recipe brew time (in ticks)
+     * @throws IllegalArgumentException if the recipe brew time is non-positive
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    void setRecipeBrewTime(@org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int recipeBrewTime);
+
+    /**
+     * Gets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTime()}.
+     *
+     * @return recipe brew time (in ticks)
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    @org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int getRecipeBrewTime();
+    // Paper end - Add recipeBrewTime
+
     /**
      * Get the level of current fuel for brewing.
      *
diff --git a/src/main/java/org/bukkit/event/block/BrewingStartEvent.java b/src/main/java/org/bukkit/event/block/BrewingStartEvent.java
index 43eac972f45d1cbb6278b048f8e6d7882c0aabeb..f193ab698edc548ec7fad89a82d03f39bb6e80e0 100644
--- a/src/main/java/org/bukkit/event/block/BrewingStartEvent.java
+++ b/src/main/java/org/bukkit/event/block/BrewingStartEvent.java
@@ -13,7 +13,9 @@ public class BrewingStartEvent extends InventoryBlockStartEvent {
 
     // Paper - remove HandlerList
     private int brewingTime;
+    private int recipeBrewTime = 400; // Paper - Add recipeBrewTime
 
+    @org.jetbrains.annotations.ApiStatus.Internal // Paper
     public BrewingStartEvent(@NotNull final Block furnace, @NotNull ItemStack source, int brewingTime) {
         super(furnace, source);
         this.brewingTime = brewingTime;
@@ -23,7 +25,9 @@ public class BrewingStartEvent extends InventoryBlockStartEvent {
      * Gets the total brew time associated with this event.
      *
      * @return the total brew time
+     * @deprecated use {@link #getBrewingTime()} instead
      */
+    @Deprecated(since = "1.21", forRemoval = true) // Paper
     public int getTotalBrewTime() {
         return brewingTime;
     }
@@ -32,10 +36,60 @@ public class BrewingStartEvent extends InventoryBlockStartEvent {
      * Sets the total brew time for this event.
      *
      * @param brewTime the new total brew time
+     * @deprecated use {@link #setBrewingTime(int)} instead
      */
+    @Deprecated(since = "1.21", forRemoval = true) // Paper
     public void setTotalBrewTime(int brewTime) {
-        this.brewingTime = brewTime;
+        this.setBrewingTime(brewTime); // Paper - delegate to new method
     }
 
     // Paper - remove HandlerList
+
+    // Paper start - add recipeBrewTime
+    /**
+     * Gets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTime()}.
+     *
+     * @return recipe brew time (in ticks)
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    public @org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int getRecipeBrewTime() {
+        return this.recipeBrewTime;
+    }
+
+    /**
+     * Sets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTime()}.
+     *
+     * @param recipeBrewTime recipe brew time (in ticks)
+     * @throws IllegalArgumentException if the recipe brew time is non-positive
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    public void setRecipeBrewTime(@org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int recipeBrewTime) {
+        com.google.common.base.Preconditions.checkArgument(recipeBrewTime > 0, "recipeBrewTime must be positive");
+        this.recipeBrewTime = recipeBrewTime;
+    }
+
+    /**
+     * Gets the amount of brewing ticks left.
+     *
+     * @return The amount of ticks left for the brewing task
+     */
+    public @org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int getBrewingTime() {
+        return this.brewingTime;
+    }
+
+    /**
+     * Sets the brewing ticks left.
+     *
+     * @param brewTime the ticks left, which is no less than 0
+     * @throws IllegalArgumentException if the ticks are less than 0
+     */
+    public void setBrewingTime(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int brewTime) {
+        com.google.common.base.Preconditions.checkArgument(brewTime >= 0, "brewTime must be non-negative");
+        this.brewingTime = brewTime;
+    }
+    // Paper end - add recipeBrewTime
 }
diff --git a/src/main/java/org/bukkit/inventory/view/BrewingStandView.java b/src/main/java/org/bukkit/inventory/view/BrewingStandView.java
index 206e9befae9863f99f44ac0e1629c2af1905787a..bb7de0b1c602e96f5b34d44a9ffa8c04e4ab5e0e 100644
--- a/src/main/java/org/bukkit/inventory/view/BrewingStandView.java
+++ b/src/main/java/org/bukkit/inventory/view/BrewingStandView.java
@@ -39,4 +39,27 @@ public interface BrewingStandView extends InventoryView {
      * @throws IllegalArgumentException if the ticks are less than 0
      */
     void setBrewingTicks(final int ticks) throws IllegalArgumentException;
+
+    // Paper start - Add recipeBrewTime
+    /**
+     * Sets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTicks()}.
+     *
+     * @param recipeBrewTime recipe brew time (in ticks)
+     * @throws IllegalArgumentException if the recipe brew time is non-positive
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    void setRecipeBrewTime(@org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int recipeBrewTime);
+
+    /**
+     * Gets the recipe time for the brewing process which is
+     * used to compute the progress of the brewing process with
+     * {@link #getBrewingTicks()}.
+     *
+     * @return recipe brew time (in ticks)
+     */
+    @org.jetbrains.annotations.ApiStatus.Experimental
+    @org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int getRecipeBrewTime();
+    // Paper end - Add recipeBrewTime
 }