198 lines
8.5 KiB
Diff
198 lines
8.5 KiB
Diff
From 1c90b91023250f036d38b080f15415ee40254573 Mon Sep 17 00:00:00 2001
|
|
From: Byteflux <byte@byteflux.net>
|
|
Date: Wed, 22 Apr 2015 01:36:02 -0700
|
|
Subject: [PATCH] Stackable Buckets
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java
|
|
index a58d4e73c..68d31b6bc 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemBucket.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
|
|
@@ -7,12 +7,21 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
|
// CraftBukkit end
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
+
|
|
public class ItemBucket extends Item {
|
|
|
|
private Block a;
|
|
|
|
public ItemBucket(Block block) {
|
|
- this.maxStackSize = 1;
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if ((block == Blocks.LAVA && PaperSpigotConfig.stackableLavaBuckets) ||
|
|
+ (block == Blocks.WATER && PaperSpigotConfig.stackableWaterBuckets)) {
|
|
+ this.maxStackSize = org.bukkit.Material.BUCKET.getMaxStackSize();
|
|
+ } else {
|
|
+ this.maxStackSize = 1;
|
|
+ }
|
|
+ // PaperSpigot end
|
|
this.a = block;
|
|
this.a(CreativeModeTab.f);
|
|
}
|
|
@@ -116,6 +125,19 @@ public class ItemBucket extends Item {
|
|
// CraftBukkit end
|
|
|
|
if (this.a(world, i, j, k) && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if ((this == Items.LAVA_BUCKET && PaperSpigotConfig.stackableLavaBuckets) ||
|
|
+ (this == Items.WATER_BUCKET && PaperSpigotConfig.stackableWaterBuckets)) {
|
|
+ --itemstack.count;
|
|
+ if (itemstack.count <= 0) {
|
|
+ return CraftItemStack.asNMSCopy(event.getItemStack());
|
|
+ }
|
|
+ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(event.getItemStack()))) {
|
|
+ entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()), false);
|
|
+ }
|
|
+ return itemstack;
|
|
+ }
|
|
+ // PaperSpigot end
|
|
return CraftItemStack.asNMSCopy(event.getItemStack()); // CraftBukkit
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/ItemMilkBucket.java b/src/main/java/net/minecraft/server/ItemMilkBucket.java
|
|
index 39f1bc031..862768e7a 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemMilkBucket.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemMilkBucket.java
|
|
@@ -1,9 +1,17 @@
|
|
package net.minecraft.server;
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
+
|
|
public class ItemMilkBucket extends Item {
|
|
|
|
public ItemMilkBucket() {
|
|
- this.e(1);
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if (PaperSpigotConfig.stackableMilkBuckets) {
|
|
+ this.e(org.bukkit.Material.BUCKET.getMaxStackSize());
|
|
+ } else {
|
|
+ this.e(1);
|
|
+ }
|
|
+ // PaperSpigot end
|
|
this.a(CreativeModeTab.f);
|
|
}
|
|
|
|
@@ -16,6 +24,16 @@ public class ItemMilkBucket extends Item {
|
|
entityhuman.removeAllEffects();
|
|
}
|
|
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if (PaperSpigotConfig.stackableMilkBuckets) {
|
|
+ if (itemstack.count <= 0) {
|
|
+ return new ItemStack(Items.BUCKET);
|
|
+ } else if (!entityhuman.inventory.pickup(new ItemStack(Items.BUCKET))) {
|
|
+ entityhuman.drop(new ItemStack(Items.BUCKET), false);
|
|
+ }
|
|
+ }
|
|
+ // PaperSpigot end
|
|
+
|
|
return itemstack.count <= 0 ? new ItemStack(Items.BUCKET) : itemstack;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index 8d6036656..4bca04b26 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -59,6 +59,8 @@ import org.bukkit.inventory.InventoryView;
|
|
import org.bukkit.util.NumberConversions;
|
|
// CraftBukkit end
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
+
|
|
public class PlayerConnection implements PacketPlayInListener {
|
|
|
|
private static final Logger c = LogManager.getLogger();
|
|
@@ -1481,6 +1483,19 @@ public class PlayerConnection implements PacketPlayInListener {
|
|
case ALLOW:
|
|
case DEFAULT:
|
|
itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), packetplayinwindowclick.e(), packetplayinwindowclick.h(), this.player);
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if (itemstack != null &&
|
|
+ ((itemstack.getItem() == Items.LAVA_BUCKET && PaperSpigotConfig.stackableLavaBuckets) ||
|
|
+ (itemstack.getItem() == Items.WATER_BUCKET && PaperSpigotConfig.stackableWaterBuckets) ||
|
|
+ (itemstack.getItem() == Items.MILK_BUCKET && PaperSpigotConfig.stackableMilkBuckets))) {
|
|
+ if (action == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
|
+ this.player.updateInventory(this.player.activeContainer);
|
|
+ } else {
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried()));
|
|
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.d(), this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem()));
|
|
+ }
|
|
+ }
|
|
+ // PaperSpigot end
|
|
break;
|
|
case DENY:
|
|
/* Needs enum constructor in InventoryAction
|
|
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
index e23430bf9..a44a7f68c 100644
|
|
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
@@ -3,6 +3,7 @@ package org.github.paperspigot;
|
|
import com.google.common.base.Throwables;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.lang.reflect.Field;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
@@ -10,8 +11,10 @@ import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.logging.Level;
|
|
+
|
|
import net.minecraft.server.MinecraftServer;
|
|
import org.bukkit.Bukkit;
|
|
+import org.bukkit.Material;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
@@ -177,4 +180,44 @@ public class PaperSpigotConfig
|
|
{
|
|
maxPacketsPerPlayer = getInt( "max-packets-per-player", 1000 );
|
|
}
|
|
+
|
|
+ public static boolean stackableLavaBuckets;
|
|
+ public static boolean stackableWaterBuckets;
|
|
+ public static boolean stackableMilkBuckets;
|
|
+ private static void stackableBuckets()
|
|
+ {
|
|
+ stackableLavaBuckets = getBoolean( "stackable-buckets.lava", false );
|
|
+ stackableWaterBuckets = getBoolean( "stackable-buckets.water", false );
|
|
+ stackableMilkBuckets = getBoolean( "stackable-buckets.milk", false );
|
|
+
|
|
+ Field maxStack;
|
|
+
|
|
+ try {
|
|
+ maxStack = Material.class.getDeclaredField("maxStack");
|
|
+ maxStack.setAccessible(true);
|
|
+
|
|
+ Field modifiers = Field.class.getDeclaredField("modifiers");
|
|
+ modifiers.setAccessible(true);
|
|
+ modifiers.setInt(maxStack, maxStack.getModifiers() & ~Modifier.FINAL);
|
|
+ } catch (Exception e) {
|
|
+ e.printStackTrace();
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ if (stackableLavaBuckets) {
|
|
+ maxStack.set(Material.LAVA_BUCKET, Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+
|
|
+ if (stackableWaterBuckets) {
|
|
+ maxStack.set(Material.WATER_BUCKET, Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+
|
|
+ if (stackableMilkBuckets) {
|
|
+ maxStack.set(Material.MILK_BUCKET, Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+ } catch (Exception e) {
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ }
|
|
}
|
|
--
|
|
2.13.3
|
|
|