mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
95 lines
2.9 KiB
Diff
95 lines
2.9 KiB
Diff
--- a/net/minecraft/server/TileEntityBrewingStand.java
|
|
+++ b/net/minecraft/server/TileEntityBrewingStand.java
|
|
@@ -3,6 +3,13 @@
|
|
import java.util.Arrays;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import java.util.List;
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
+import org.bukkit.event.inventory.BrewEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory {
|
|
|
|
private static final int[] a = new int[] { 3};
|
|
@@ -14,9 +21,35 @@
|
|
private Item k;
|
|
private String l;
|
|
private int m;
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
public TileEntityBrewingStand() {}
|
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+ private int maxStack = 64;
|
|
+
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
+ transaction.add(who);
|
|
+ }
|
|
+
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
+ transaction.remove(who);
|
|
+ }
|
|
+
|
|
+ public List<HumanEntity> getViewers() {
|
|
+ return transaction;
|
|
+ }
|
|
+
|
|
+ public ItemStack[] getContents() {
|
|
+ return this.items;
|
|
+ }
|
|
+
|
|
+ public void setMaxStackSize(int size) {
|
|
+ maxStack = size;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
public String getName() {
|
|
return this.hasCustomName() ? this.l : "container.brewing";
|
|
}
|
|
@@ -47,9 +80,14 @@
|
|
boolean flag = this.n();
|
|
boolean flag1 = this.brewTime > 0;
|
|
|
|
+ // CraftBukkit start - Use wall time instead of ticks for brewing
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
+ this.lastTick = MinecraftServer.currentTick;
|
|
+
|
|
if (flag1) {
|
|
- --this.brewTime;
|
|
- boolean flag2 = this.brewTime == 0;
|
|
+ this.brewTime -= elapsedTicks;
|
|
+ boolean flag2 = this.brewTime <= 0; // == -> <=
|
|
+ // CraftBukkit end
|
|
|
|
if (flag2 && flag) {
|
|
this.o();
|
|
@@ -125,6 +163,15 @@
|
|
|
|
private void o() {
|
|
ItemStack itemstack = this.items[3];
|
|
+ // CraftBukkit start
|
|
+ if (getOwner() != null) {
|
|
+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
this.items[i] = PotionBrewer.d(itemstack, this.items[i]);
|
|
@@ -225,7 +272,7 @@
|
|
}
|
|
|
|
public int getMaxStackSize() {
|
|
- return 64;
|
|
+ return this.maxStack; // CraftBukkit
|
|
}
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|