2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/ItemBucket.java
|
|
|
|
+++ b/net/minecraft/server/ItemBucket.java
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1,6 +1,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
2018-07-15 02:00:00 +02:00
|
|
|
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
|
|
|
+// CraftBukkit end
|
2016-05-10 13:47:39 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public class ItemBucket extends Item {
|
|
|
|
|
2019-07-13 04:07:15 +02:00
|
|
|
@@ -30,12 +37,22 @@
|
2018-12-25 22:00:00 +01:00
|
|
|
if (this.fluidType == FluidTypes.EMPTY) {
|
2018-07-15 02:00:00 +02:00
|
|
|
iblockdata = world.getType(blockposition);
|
|
|
|
if (iblockdata.getBlock() instanceof IFluidSource) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-12-25 22:00:00 +01:00
|
|
|
+ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
|
2019-08-23 12:30:16 +02:00
|
|
|
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.b());
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
2019-07-13 04:07:15 +02:00
|
|
|
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
2018-12-22 00:12:16 +01:00
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-12-25 22:00:00 +01:00
|
|
|
FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition, iblockdata);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-12-25 22:00:00 +01:00
|
|
|
if (fluidtype != FluidTypes.EMPTY) {
|
2018-07-15 02:00:00 +02:00
|
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
2018-08-26 04:00:00 +02:00
|
|
|
entityhuman.a(fluidtype.a(TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F);
|
2018-07-15 02:00:00 +02:00
|
|
|
- ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b());
|
|
|
|
+ ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b(), event.getItemStack()); // CraftBukkit
|
|
|
|
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b()));
|
2019-07-13 04:07:15 +02:00
|
|
|
@@ -50,7 +67,7 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
iblockdata = world.getType(blockposition);
|
2019-04-23 04:00:00 +02:00
|
|
|
BlockPosition blockposition1 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection());
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
- if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock)) {
|
|
|
|
+ if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a(world, itemstack, blockposition1);
|
|
|
|
if (entityhuman instanceof EntityPlayer) {
|
|
|
|
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack);
|
2019-07-13 04:07:15 +02:00
|
|
|
@@ -74,16 +91,19 @@
|
2018-07-15 02:00:00 +02:00
|
|
|
|
|
|
|
public void a(World world, ItemStack itemstack, BlockPosition blockposition) {}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
- private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item) {
|
|
|
|
+ // CraftBukkit - added ob.ItemStack result - TODO: Is this... the right way to handle this?
|
|
|
|
+ private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item, org.bukkit.inventory.ItemStack result) {
|
|
|
|
if (entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
2016-11-17 02:41:03 +01:00
|
|
|
itemstack.subtract(1);
|
|
|
|
if (itemstack.isEmpty()) {
|
|
|
|
- return new ItemStack(item);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ return CraftItemStack.asNMSCopy(result);
|
|
|
|
} else {
|
|
|
|
- if (!entityhuman.inventory.pickup(new ItemStack(item))) {
|
|
|
|
- entityhuman.drop(new ItemStack(item), false);
|
|
|
|
+ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) {
|
|
|
|
+ entityhuman.drop(CraftItemStack.asNMSCopy(result), false);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
return itemstack;
|
2019-07-13 04:07:15 +02:00
|
|
|
@@ -91,7 +111,13 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
2019-04-23 04:00:00 +02:00
|
|
|
public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
|
|
|
+ return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit end
|
2018-08-26 04:00:00 +02:00
|
|
|
if (!(this.fluidType instanceof FluidTypeFlowing)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2019-07-13 04:07:15 +02:00
|
|
|
@@ -101,8 +127,18 @@
|
2018-07-18 09:48:17 +02:00
|
|
|
boolean flag1 = material.isReplaceable();
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) {
|
2019-04-23 04:00:00 +02:00
|
|
|
- return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null);
|
|
|
|
+ return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit
|
2016-02-29 22:32:46 +01:00
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (entityhuman != null) {
|
2019-08-23 12:30:16 +02:00
|
|
|
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(world, entityhuman, blockposition, clicked, enumdirection, itemstack);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (event.isCancelled()) {
|
2018-08-07 13:17:49 +02:00
|
|
|
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
|
2018-12-22 00:12:16 +01:00
|
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-08-26 04:00:00 +02:00
|
|
|
if (world.worldProvider.isNether() && this.fluidType.a(TagsFluid.WATER)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
int i = blockposition.getX();
|
|
|
|
int j = blockposition.getY();
|