Files
CatServer/patches/net/minecraft/tileentity/TileEntityBrewingStand.java.patch
2018-09-08 15:37:15 +08:00

92 lines
3.2 KiB
Diff

--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java
@@ -17,14 +17,27 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.PotionHelper;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.datafix.FixTypes;
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
import net.minecraft.util.math.BlockPos;
+import luohuayu.CatServer.tileentity.CBTileEntityLockable;
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
-public class TileEntityBrewingStand extends TileEntityLockable implements ITickable, ISidedInventory
+//CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.inventory.BrewEvent;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
+public class TileEntityBrewingStand extends CBTileEntityLockable implements ITickable, ISidedInventory
{
private static final int[] SLOTS_FOR_UP = new int[] {3};
private static final int[] SLOTS_FOR_DOWN = new int[] {0, 1, 2, 3};
@@ -35,6 +48,32 @@
private Item ingredientID;
private String customName;
private int fuel;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
+
+ // 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.brewingItemStacks;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+ // CraftBukkit end
public String getName()
{
@@ -178,6 +217,17 @@
if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(brewingItemStacks)) return;
ItemStack itemstack = this.brewingItemStacks[3];
+ // CraftBukkit start
+ InventoryHolder owner = this.getOwner();
+ if (owner != null) {
+ BrewEvent event = new BrewEvent(worldObj.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), (org.bukkit.inventory.BrewerInventory) owner.getInventory());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
+
net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(brewingItemStacks, brewingItemStacks[3], OUTPUT_SLOTS);
--itemstack.stackSize;
@@ -295,7 +345,7 @@
public int getInventoryStackLimit()
{
- return 64;
+ return this.maxStack; // CraftBukkit
}
public boolean isUseableByPlayer(EntityPlayer player)