3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/TileEntityBrewingStand.patch

95 Zeilen
2.9 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/TileEntityBrewingStand.java
+++ b/net/minecraft/server/TileEntityBrewingStand.java
@@ -3,6 +3,12 @@
import java.util.Arrays;
import java.util.List;
+// CraftBukkit start
+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 IUpdatePlayerListBox, IWorldInventory {
private static final int[] a = new int[] { 3};
@@ -12,9 +18,35 @@
private boolean[] i;
private Item j;
private String k;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public TileEntityBrewingStand() {}
2015-02-26 23:41:06 +01:00
+ // 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
2015-02-26 23:41:06 +01:00
+
public String getName() {
return this.hasCustomName() ? this.k : "container.brewing";
2015-02-26 23:41:06 +01:00
}
@@ -32,9 +64,14 @@
}
public void c() {
+ // CraftBukkit start - Use wall time instead of ticks for brewing
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+
if (this.brewTime > 0) {
- --this.brewTime;
- if (this.brewTime == 0) {
+ this.brewTime -= elapsedTicks;
+ if (this.brewTime <= 0) { // == -> <=
+ // CraftBukkit end
this.o();
this.update();
} else if (!this.n()) {
2015-02-26 23:41:06 +01:00
@@ -110,6 +147,16 @@
if (this.n()) {
ItemStack itemstack = this.items[3];
2015-02-26 23:41:06 +01:00
+ // 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
2015-02-26 23:41:06 +01:00
+
for (int i = 0; i < 3; ++i) {
if (this.items[i] != null && this.items[i].getItem() == Items.POTION) {
2015-02-26 23:41:06 +01:00
int j = this.items[i].getData();
@@ -221,7 +268,7 @@
}
public int getMaxStackSize() {
- return 64;
+ return this.maxStack; // CraftBukkit
}
public boolean a(EntityHuman entityhuman) {