3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

Stackable Buckets

Dieser Commit ist enthalten in:
Byteflux 2015-06-01 22:27:22 -07:00
Ursprung 9ac5394f72
Commit 3cf6c48811
2 geänderte Dateien mit 217 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From 1485ddd960cb7aef077e350e6f6aac921f1c762e Mon Sep 17 00:00:00 2001
From ac9821545063d6507b166969b3c1be76471d91db Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Mon, 25 May 2015 15:37:00 -0500
Subject: [PATCH] mc-dev imports
@ -191,6 +191,47 @@ index 0000000..57b3d9d
+ return this.b(s);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ItemMilkBucket.java b/src/main/java/net/minecraft/server/ItemMilkBucket.java
new file mode 100644
index 0000000..91ea70d
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ItemMilkBucket.java
@@ -0,0 +1,35 @@
+package net.minecraft.server;
+
+public class ItemMilkBucket extends Item {
+
+ public ItemMilkBucket() {
+ this.c(1);
+ this.a(CreativeModeTab.f);
+ }
+
+ public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) {
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ --itemstack.count;
+ }
+
+ if (!world.isClientSide) {
+ entityhuman.removeAllEffects();
+ }
+
+ entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
+ return itemstack.count <= 0 ? new ItemStack(Items.BUCKET) : itemstack;
+ }
+
+ public int d(ItemStack itemstack) {
+ return 32;
+ }
+
+ public EnumAnimation e(ItemStack itemstack) {
+ return EnumAnimation.DRINK;
+ }
+
+ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
+ entityhuman.a(itemstack, this.d(itemstack));
+ return itemstack;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MobEffectAttackDamage.java b/src/main/java/net/minecraft/server/MobEffectAttackDamage.java
new file mode 100644
index 0000000..620685a
@ -325,5 +366,5 @@ index 0000000..f75e2de
+ }
+}
--
2.4.1.windows.1
1.9.5.msysgit.1

Datei anzeigen

@ -0,0 +1,174 @@
From 6fe5ba0882a8d943c3fbb78fb7619e5b77a1dc85 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 4d362ae..b62ea42 100644
--- a/src/main/java/net/minecraft/server/ItemBucket.java
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
@@ -7,6 +7,8 @@ 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;
@@ -93,6 +95,18 @@ 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 91ea70d..8e3d77e 100644
--- a/src/main/java/net/minecraft/server/ItemMilkBucket.java
+++ b/src/main/java/net/minecraft/server/ItemMilkBucket.java
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
+
public class ItemMilkBucket extends Item {
public ItemMilkBucket() {
@@ -17,6 +19,15 @@ 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 3b1be6f..7663049 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -61,6 +61,8 @@ 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();
@@ -1607,6 +1609,19 @@ 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 3ab2892..b189ba4 100644
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
@@ -3,14 +3,19 @@ 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;
@@ -178,4 +183,47 @@ 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();
+ }
+ }
}
--
1.9.5.msysgit.1