mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 10:44:39 +01:00
b2aaf31f9e
Removes ArmorStand Marker API as that was added to Bukkit
172 lines
No EOL
8.5 KiB
Diff
172 lines
No EOL
8.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Byteflux <byte@byteflux.net>
|
|
Date: Mon, 1 Jun 2015 22:21:52 -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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemBucket.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
|
|
@@ -0,0 +0,0 @@ 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;
|
|
@@ -0,0 +0,0 @@ public class ItemBucket extends Item {
|
|
|
|
if (this.a(world, blockposition1) && !entityhuman.abilities.canInstantlyBuild) {
|
|
entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
|
|
+ // PaperSpigot start - Stackable Buckets
|
|
+ if ((this == Items.LAVA_BUCKET && PaperSpigotConfig.stackableLavaBuckets) ||
|
|
+ (this == Items.WATER_BUCKET && PaperSpigotConfig.stackableWaterBuckets)) {
|
|
+ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemMilkBucket.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemMilkBucket.java
|
|
@@ -0,0 +0,0 @@
|
|
package net.minecraft.server;
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
+
|
|
public class ItemMilkBucket extends Item {
|
|
|
|
public ItemMilkBucket() {
|
|
@@ -0,0 +0,0 @@ public class ItemMilkBucket extends Item {
|
|
}
|
|
|
|
entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
|
|
+ // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -0,0 +0,0 @@ import org.bukkit.inventory.InventoryView;
|
|
import org.bukkit.util.NumberConversions;
|
|
// CraftBukkit end
|
|
|
|
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
|
+
|
|
public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerListBox {
|
|
|
|
private static final Logger c = LogManager.getLogger();
|
|
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
case ALLOW:
|
|
case DEFAULT:
|
|
itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), 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.b(), this.player.activeContainer.getSlot(packetplayinwindowclick.b()).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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
|
@@ -0,0 +0,0 @@ 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;
|
|
import java.util.*;
|
|
import java.util.logging.Level;
|
|
+
|
|
+import net.minecraft.server.Item;
|
|
+import net.minecraft.server.Items;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.bukkit.Bukkit;
|
|
+import org.bukkit.Material;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
@@ -0,0 +0,0 @@ public class PaperSpigotConfig
|
|
dataValueAllowedItems = new HashSet<Integer>( getList( "data-value-allowed-items", Collections.emptyList() ) );
|
|
Bukkit.getLogger().info( "Data value allowed items: " + StringUtils.join(dataValueAllowedItems, ", ") );
|
|
}
|
|
+
|
|
+ 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());
|
|
+ Items.LAVA_BUCKET.c(Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+
|
|
+ if (stackableWaterBuckets) {
|
|
+ maxStack.set(Material.WATER_BUCKET, Material.BUCKET.getMaxStackSize());
|
|
+ Items.WATER_BUCKET.c(Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+
|
|
+ if (stackableMilkBuckets) {
|
|
+ maxStack.set(Material.MILK_BUCKET, Material.BUCKET.getMaxStackSize());
|
|
+ Items.MILK_BUCKET.c(Material.BUCKET.getMaxStackSize());
|
|
+ }
|
|
+ } catch (Exception e) {
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ }
|
|
}
|
|
--
|