From 2726696652179a5ead7dc07dd39edf7dfda687f7 Mon Sep 17 00:00:00 2001 From: mbax Date: Mon, 4 Nov 2013 07:07:38 -0600 Subject: Update CraftBukkit to Minecraft 1.7.2 --- src/main/java/net/minecraft/server/ItemBucket.java | 79 ++++++++++------------ 1 file changed, 35 insertions(+), 44 deletions(-) (limited to 'src/main/java/net/minecraft/server/ItemBucket.java') diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index b0440dd8..a58d4e73 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -9,23 +9,22 @@ import org.bukkit.event.player.PlayerBucketFillEvent; public class ItemBucket extends Item { - private int a; + private Block a; - public ItemBucket(int i, int j) { - super(i); + public ItemBucket(Block block) { this.maxStackSize = 1; - this.a = j; + this.a = block; this.a(CreativeModeTab.f); } public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - boolean flag = this.a == 0; + boolean flag = this.a == Blocks.AIR; MovingObjectPosition movingobjectposition = this.a(world, entityhuman, flag); if (movingobjectposition == null) { return itemstack; } else { - if (movingobjectposition.type == EnumMovingObjectType.TILE) { + if (movingobjectposition.type == EnumMovingObjectType.BLOCK) { int i = movingobjectposition.b; int j = movingobjectposition.c; int k = movingobjectposition.d; @@ -34,62 +33,39 @@ public class ItemBucket extends Item { return itemstack; } - if (this.a == 0) { + if (flag) { if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { return itemstack; } - if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) { + Material material = world.getType(i, j, k).getMaterial(); + int l = world.getData(i, j, k); + + if (material == Material.WATER && l == 0) { // CraftBukkit start - PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.WATER_BUCKET); + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Items.WATER_BUCKET); if (event.isCancelled()) { return itemstack; } // CraftBukkit end world.setAir(i, j, k); - if (entityhuman.abilities.canInstantlyBuild) { - return itemstack; - } - - ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); // CraftBukkit - TODO: Check this stuff later... Not sure how this behavior should work - if (--itemstack.count <= 0) { - return result; // CraftBukkit - } - - if (!entityhuman.inventory.pickup(result)) { // CraftBukkit - entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - } - - return itemstack; + return this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack } - if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) { + if (material == Material.LAVA && l == 0) { // CraftBukkit start - PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.LAVA_BUCKET); + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Items.LAVA_BUCKET); if (event.isCancelled()) { return itemstack; } // CraftBukkit end world.setAir(i, j, k); - if (entityhuman.abilities.canInstantlyBuild) { - return itemstack; - } - - ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); // CraftBukkit - TODO: Check this stuff later... Not sure how this behavior should work - if (--itemstack.count <= 0) { - return result; // CraftBukkit - } - - if (!entityhuman.inventory.pickup(result)) { // CraftBukkit - entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - } - - return itemstack; + return this.a(itemstack, entityhuman, Items.LAVA_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack } } else { - if (this.a < 0) { + if (this.a == Blocks.AIR) { // CraftBukkit start PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.face, itemstack); @@ -149,17 +125,32 @@ public class ItemBucket extends 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 if (--itemstack.count <= 0) { + return CraftItemStack.asNMSCopy(result); // CraftBukkit + } else { + if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) { // CraftBukkit + entityhuman.drop(CraftItemStack.asNMSCopy(result), false); // CraftBukkit + } + + return itemstack; + } + } + public boolean a(World world, int i, int j, int k) { - if (this.a <= 0) { + if (this.a == Blocks.AIR) { return false; } else { - Material material = world.getMaterial(i, j, k); + Material material = world.getType(i, j, k).getMaterial(); boolean flag = !material.isBuildable(); if (!world.isEmpty(i, j, k) && !flag) { return false; } else { - if (world.worldProvider.f && this.a == Block.WATER.id) { + if (world.worldProvider.f && this.a == Blocks.WATER) { world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { @@ -170,7 +161,7 @@ public class ItemBucket extends Item { world.setAir(i, j, k, true); } - world.setTypeIdAndData(i, j, k, this.a, 0, 3); + world.setTypeAndData(i, j, k, this.a, 0, 3); } return true; -- cgit v1.2.3