2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/TileEntityBrewingStand.java
|
|
|
|
+++ b/net/minecraft/server/TileEntityBrewingStand.java
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -3,6 +3,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.Arrays;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+import java.util.List;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.entity.HumanEntity;
|
|
|
|
+import org.bukkit.event.inventory.BrewEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
private static final int[] a = new int[] { 3};
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -14,9 +21,35 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
private Item k;
|
|
|
|
private String l;
|
|
|
|
private int m;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
|
|
|
|
|
|
|
public TileEntityBrewingStand() {}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +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
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public String getName() {
|
2016-02-29 22:32:46 +01:00
|
|
|
return this.hasCustomName() ? this.l : "container.brewing";
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -47,9 +80,14 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
boolean flag = this.n();
|
|
|
|
boolean flag1 = this.brewTime > 0;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start - Use wall time instead of ticks for brewing
|
|
|
|
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
|
|
|
+ this.lastTick = MinecraftServer.currentTick;
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
if (flag1) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- --this.brewTime;
|
2016-02-29 22:32:46 +01:00
|
|
|
- boolean flag2 = this.brewTime == 0;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.brewTime -= elapsedTicks;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ boolean flag2 = this.brewTime <= 0; // == -> <=
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
if (flag2 && flag) {
|
2014-11-25 22:32:16 +01:00
|
|
|
this.o();
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -125,6 +163,15 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
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;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
this.items[i] = PotionBrewer.d(itemstack, this.items[i]);
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -225,7 +272,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxStackSize() {
|
|
|
|
- return 64;
|
|
|
|
+ return this.maxStack; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|