From 0b72df25869d76b7b8c0105f965f43b176a0fcf2 Mon Sep 17 00:00:00 2001 From: Tamion <70228790+notTamion@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:08:46 +0200 Subject: [PATCH] requests --- patches/api/0490-Add-startingBrewTime.patch | 58 +++++++ .../server/1058-Add-startingBrewTime.patch | 115 +++++++++++++ .../server/1060-Add-startingBrewTime.patch | 158 ------------------ 3 files changed, 173 insertions(+), 158 deletions(-) create mode 100644 patches/api/0490-Add-startingBrewTime.patch create mode 100644 patches/server/1058-Add-startingBrewTime.patch delete mode 100644 patches/server/1060-Add-startingBrewTime.patch diff --git a/patches/api/0490-Add-startingBrewTime.patch b/patches/api/0490-Add-startingBrewTime.patch new file mode 100644 index 0000000000000..5fe6a8c239f07 --- /dev/null +++ b/patches/api/0490-Add-startingBrewTime.patch @@ -0,0 +1,58 @@ +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 startingBrewTime + + +diff --git a/src/main/java/org/bukkit/block/BrewingStand.java b/src/main/java/org/bukkit/block/BrewingStand.java +index fe155f14de7f7efb519f0585897ef43ee6c16bb9..cff88ace46205da32f4d1f785de59ff022baa2c1 100644 +--- a/src/main/java/org/bukkit/block/BrewingStand.java ++++ b/src/main/java/org/bukkit/block/BrewingStand.java +@@ -22,6 +22,22 @@ public interface BrewingStand extends Container { + */ + void setBrewingTime(int brewTime); + ++ /** ++ * Sets the time the brewing process started with. ++ * This only affects the visual progress on the client. ++ * ++ * @param startingBrewTime Starting Brew time ++ */ ++ void setStartingBrewTime(int startingBrewTime); ++ ++ /** ++ * Gets the time the brewing process started with. ++ * This only affects the visual progress on the client. ++ * ++ * @return Starting Brew time ++ */ ++ int getStartingBrewTime(); ++ + /** + * Get the level of current fuel for brewing. + * +diff --git a/src/main/java/org/bukkit/inventory/view/BrewingStandView.java b/src/main/java/org/bukkit/inventory/view/BrewingStandView.java +index 206e9befae9863f99f44ac0e1629c2af1905787a..4771c2b9059ff55bb8205df0e253c03ed372c238 100644 +--- a/src/main/java/org/bukkit/inventory/view/BrewingStandView.java ++++ b/src/main/java/org/bukkit/inventory/view/BrewingStandView.java +@@ -39,4 +39,20 @@ public interface BrewingStandView extends InventoryView { + * @throws IllegalArgumentException if the ticks are less than 0 + */ + void setBrewingTicks(final int ticks) throws IllegalArgumentException; ++ ++ /** ++ * Sets the time the brewing process started with. ++ * This only affects the visual progress on the client. ++ * ++ * @param startingBrewTime Starting Brew time ++ */ ++ void setStartingBrewTime(int startingBrewTime); ++ ++ /** ++ * Gets the time the brewing process started with. ++ * This only affects the visual progress on the client. ++ * ++ * @return Starting Brew time ++ */ ++ int getStartingBrewTime(); + } diff --git a/patches/server/1058-Add-startingBrewTime.patch b/patches/server/1058-Add-startingBrewTime.patch new file mode 100644 index 0000000000000..a58345e8b595d --- /dev/null +++ b/patches/server/1058-Add-startingBrewTime.patch @@ -0,0 +1,115 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tamion <70228790+notTamion@users.noreply.github.com> +Date: Sun, 15 Sep 2024 19:17:12 +0200 +Subject: [PATCH] Add startingBrewTime + +== AT == +public net.minecraft.world.inventory.BrewingStandMenu brewingStandData + +diff --git a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java b/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java +index 68c529cb38d61cd3a0f39bef0f666057fc219c9b..7ca84f720bc6bbe9d108534436bfc36d261c2dbd 100644 +--- a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java +@@ -60,7 +60,18 @@ public class BrewingStandMenu extends AbstractContainerMenu { + // Paper end - custom potion mixes + this.ingredientSlot = this.addSlot(new BrewingStandMenu.IngredientsSlot(potionbrewer, inventory, 3, 79, 17)); + this.addSlot(new BrewingStandMenu.FuelSlot(inventory, 4, 17, 17)); +- this.addDataSlots(propertyDelegate); ++ this.addDataSlots(new SimpleContainerData(2) { ++ @Override ++ public int get(final int index) { ++ if (index == 0) return 400 * propertyDelegate.get(index) / propertyDelegate.get(-1); ++ return propertyDelegate.get(index); ++ } ++ ++ @Override ++ public void set(final int index, final int value) { ++ propertyDelegate.set(index, value); ++ } ++ }); + + int j; + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +index bf2c303a314205590a2839e0f729af3a9ff40a86..63db3e401a0f5935e5a2478e268c3b667b5c1ce7 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +@@ -49,6 +49,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements + public static final int NUM_DATA_VALUES = 2; + private NonNullList items; + public int brewTime; ++ public int startingBrewTime = 400; // Paper - Add startingBrewTime + private boolean[] lastPotionCount; + private Item ingredient; + public int fuel; +@@ -93,6 +94,9 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements + int j; + + switch (index) { ++ case -1: ++ j = BrewingStandBlockEntity.this.startingBrewTime; ++ break; + case 0: + j = BrewingStandBlockEntity.this.brewTime; + break; +@@ -109,6 +113,9 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements + @Override + public void set(int index, int value) { + switch (index) { ++ case -1: ++ BrewingStandBlockEntity.this.startingBrewTime = value; ++ break; + case 0: + BrewingStandBlockEntity.this.brewTime = value; + break; +@@ -188,6 +195,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements + // CraftBukkit start + BrewingStartEvent event = new BrewingStartEvent(CraftBlock.at(world, pos), CraftItemStack.asCraftMirror(itemstack1), 400); + world.getCraftServer().getPluginManager().callEvent(event); ++ blockEntity.startingBrewTime = event.getTotalBrewTime(); // Paper - Add startingBrewTime + blockEntity.brewTime = event.getTotalBrewTime(); // 400 -> event.getTotalBrewTime() + // CraftBukkit end + blockEntity.ingredient = itemstack1.getItem(); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +index e9f55c898de827afe6c9f951cbe1b46eea5f4149..0f803778c33b2003d302d9a57a93d7630fee757b 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +@@ -39,6 +39,17 @@ public class CraftBrewingStand extends CraftContainer i + @Override + public void setBrewingTime(int brewTime) { + this.getSnapshot().brewTime = brewTime; ++ if (brewTime > this.getSnapshot().startingBrewTime) this.getSnapshot().startingBrewTime = brewTime; // Paper - Add startingBrewTime ++ } ++ ++ @Override ++ public void setStartingBrewTime(int startingBrewTime) { ++ this.getSnapshot().startingBrewTime = startingBrewTime; ++ } ++ ++ @Override ++ public int getStartingBrewTime() { ++ return this.getSnapshot().startingBrewTime; + } + + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java +index c92e51227cf2c0046a558b012c078c46582aed44..af05a648f699ca0df945a86f6985cf0604351a99 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java +@@ -34,5 +34,16 @@ public class CraftBrewingStandView extends CraftInventoryView + public void setBrewingTicks(final int brewingTicks) { + Preconditions.checkArgument(brewingTicks > 0, "The given brewing ticks must be greater than 0"); + this.container.setData(BrewingStandBlockEntity.DATA_BREW_TIME, brewingTicks); ++ if (brewingTicks > this.container.brewingStandData.get(-1)) this.container.brewingStandData.set(-1, brewingTicks); // Paper - Add startingBrewTime ++ } ++ ++ @Override ++ public void setStartingBrewTime(final int startingBrewTime) { ++ this.container.brewingStandData.set(-1, startingBrewTime); ++ } ++ ++ @Override ++ public int getStartingBrewTime() { ++ return this.container.brewingStandData.get(-1); + } + } diff --git a/patches/server/1060-Add-startingBrewTime.patch b/patches/server/1060-Add-startingBrewTime.patch deleted file mode 100644 index 572b964137040..0000000000000 --- a/patches/server/1060-Add-startingBrewTime.patch +++ /dev/null @@ -1,158 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Tamion <70228790+notTamion@users.noreply.github.com> -Date: Sun, 15 Sep 2024 19:17:12 +0200 -Subject: [PATCH] Add startingBrewTime - -== AT == -public net.minecraft.world.inventory.BrewingStandMenu brewingStand - -diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index dd4218e108f87f3305b76fbc8d88f488b447c609..b68ef8e6d59f25ab24ddcf65aad1fc04dcd5f60f 100644 ---- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -195,7 +195,13 @@ public abstract class AbstractContainerMenu { - i = 0; - - for (j = this.dataSlots.size(); i < j; ++i) { -- this.remoteDataSlots.set(i, ((DataSlot) this.dataSlots.get(i)).get()); -+ // Paper start - Add startingBrewTime -+ if (this instanceof BrewingStandMenu menu && i == 0) { -+ this.remoteDataSlots.set(i, this.dataSlots.get(i).get() * 400 / menu.startingBrewTime.getValue()); -+ } else { -+ this.remoteDataSlots.set(i, ((DataSlot) this.dataSlots.get(i)).get()); -+ } -+ // Paper end - Add startingBrewTime - } - - if (this.synchronizer != null) { -@@ -249,6 +255,11 @@ public abstract class AbstractContainerMenu { - for (i = 0; i < this.dataSlots.size(); ++i) { - DataSlot containerproperty = (DataSlot) this.dataSlots.get(i); - int j = containerproperty.get(); -+ // Paper start - Add startingBrewTime -+ if (this instanceof BrewingStandMenu menu && i == 0) { -+ j = j * 400 / menu.startingBrewTime.getValue(); -+ } -+ // Paper end - Add startingBrewTime - - if (containerproperty.checkAndClearUpdateFlag()) { - this.updateDataSlotListeners(i, j); -@@ -273,7 +284,13 @@ public abstract class AbstractContainerMenu { - DataSlot containerproperty = (DataSlot) this.dataSlots.get(i); - - if (containerproperty.checkAndClearUpdateFlag()) { -- this.updateDataSlotListeners(i, containerproperty.get()); -+ // Paper start - Add startingBrewTime -+ if (this instanceof BrewingStandMenu menu && i == 0) { -+ this.updateDataSlotListeners(i, containerproperty.get() * 400 / menu.startingBrewTime.getValue()); -+ } else { -+ this.updateDataSlotListeners(i, containerproperty.get()); -+ } -+ // Paper end - Add startingBrewTime - } - } - -diff --git a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java b/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java -index 74e607b9ddf509ae5024dd51f242bb0802061dc4..5a4cbaff95502f4e63b52b7b5d5c45070467f40f 100644 ---- a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java -+++ b/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java -@@ -34,6 +34,7 @@ public class BrewingStandMenu extends AbstractContainerMenu { - public final Container brewingStand; - private final ContainerData brewingStandData; - private final Slot ingredientSlot; -+ public org.apache.commons.lang3.mutable.MutableInt startingBrewTime; // Paper - Add startingBrewTime - - // CraftBukkit start - private CraftBrewingStandView bukkitEntity = null; -@@ -41,16 +42,17 @@ public class BrewingStandMenu extends AbstractContainerMenu { - // CraftBukkit end - - public BrewingStandMenu(int syncId, Inventory playerInventory) { -- this(syncId, playerInventory, new SimpleContainer(5), new SimpleContainerData(2)); -+ this(syncId, playerInventory, new SimpleContainer(5), new SimpleContainerData(2), new org.apache.commons.lang3.mutable.MutableInt(400)); // Paper - Add startingBrewTime - } - -- public BrewingStandMenu(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate) { -+ public BrewingStandMenu(int syncId, Inventory playerInventory, Container inventory, ContainerData propertyDelegate, org.apache.commons.lang3.mutable.MutableInt startingBrewTime) { // Paper - Add startingBrewTime - super(MenuType.BREWING_STAND, syncId); - this.player = playerInventory; // CraftBukkit - checkContainerSize(inventory, 5); - checkContainerDataCount(propertyDelegate, 2); - this.brewingStand = inventory; - this.brewingStandData = propertyDelegate; -+ this.startingBrewTime = startingBrewTime; // Paper - Add startingBrewTime - PotionBrewing potionbrewer = playerInventory.player.level().potionBrewing(); - - // Paper start - custom potion mixes -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index a2fafef89d5354e2cb02f5672810909950a57777..3aa69efe237a0e8fab71dd640f804c07776a16a2 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -49,6 +49,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements - public static final int NUM_DATA_VALUES = 2; - private NonNullList items; - public int brewTime; -+ public org.apache.commons.lang3.mutable.MutableInt startingBrewTime; // Paper - Add startingBrewTime - private boolean[] lastPotionCount; - private Item ingredient; - public int fuel; -@@ -87,6 +88,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements - public BrewingStandBlockEntity(BlockPos pos, BlockState state) { - super(BlockEntityType.BREWING_STAND, pos, state); - this.items = NonNullList.withSize(5, ItemStack.EMPTY); -+ this.startingBrewTime = new org.apache.commons.lang3.mutable.MutableInt(400); // Paper - Add startingBrewTime - this.dataAccess = new ContainerData() { - @Override - public int get(int index) { -@@ -190,6 +192,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements - // CraftBukkit start - BrewingStartEvent event = new BrewingStartEvent(CraftBlock.at(world, pos), CraftItemStack.asCraftMirror(itemstack1), 400); - world.getCraftServer().getPluginManager().callEvent(event); -+ blockEntity.startingBrewTime.setValue(event.getTotalBrewTime()); // Paper - Add startingBrewTime - blockEntity.brewTime = event.getTotalBrewTime(); // 400 -> event.getTotalBrewTime() - // CraftBukkit end - blockEntity.ingredient = itemstack1.getItem(); -@@ -341,6 +344,6 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements - - @Override - protected AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) { -- return new BrewingStandMenu(syncId, playerInventory, this, this.dataAccess); -+ return new BrewingStandMenu(syncId, playerInventory, this, this.dataAccess, this.startingBrewTime); // Paper - Add startingBrewTime - } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java -index e9f55c898de827afe6c9f951cbe1b46eea5f4149..43dd5e654b18a91e07c91a56c848a312515a975b 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java -@@ -39,6 +39,7 @@ public class CraftBrewingStand extends CraftContainer i - @Override - public void setBrewingTime(int brewTime) { - this.getSnapshot().brewTime = brewTime; -+ if (brewTime > this.getSnapshot().startingBrewTime.getValue()) this.getSnapshot().startingBrewTime.setValue(brewTime); // Paper - Add startingBrewTime - } - - @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -index 10a5b1853d3984427209c87bdec1d471dddb1244..9479460081aa9e6f26068126e46f1808733a141e 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -@@ -201,7 +201,7 @@ public class CraftContainer extends AbstractContainerMenu { - this.delegate = new EnchantmentMenu(windowId, bottom); - break; - case BREWING: -- this.delegate = new BrewingStandMenu(windowId, bottom, top, new SimpleContainerData(2)); -+ this.delegate = new BrewingStandMenu(windowId, bottom, top, new SimpleContainerData(2), new org.apache.commons.lang3.mutable.MutableInt(400)); // Paper - Add startingBrewTime - break; - case HOPPER: - this.delegate = new HopperMenu(windowId, bottom, top); -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java -index c92e51227cf2c0046a558b012c078c46582aed44..9d69ba1d82be9d00f4b553f14d49fc1c3ae3191d 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/view/CraftBrewingStandView.java -@@ -34,5 +34,6 @@ public class CraftBrewingStandView extends CraftInventoryView - public void setBrewingTicks(final int brewingTicks) { - Preconditions.checkArgument(brewingTicks > 0, "The given brewing ticks must be greater than 0"); - this.container.setData(BrewingStandBlockEntity.DATA_BREW_TIME, brewingTicks); -+ if (brewingTicks > this.container.startingBrewTime.getValue()) this.container.startingBrewTime.setValue(brewingTicks); // Paper - Add startingBrewTime - } - }