summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/ItemBucket.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemBucket.java')
-rw-r--r--src/main/java/net/minecraft/server/ItemBucket.java214
1 files changed, 113 insertions, 101 deletions
diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java
index 017fd0d4..94820138 100644
--- a/src/main/java/net/minecraft/server/ItemBucket.java
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock;
@@ -20,123 +18,137 @@ public class ItemBucket extends Item {
public ItemBucket(int i, int j) {
super(i);
- bb = 1;
- bc = 64;
- a = j;
+ this.maxStackSize = 1;
+ this.durability = 64;
+ this.a = j;
}
- public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) {
+ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F;
- float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f;
- float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f;
- double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f;
- double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H;
- double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f;
- Vec3D vec3d = Vec3D.b(d, d1, d2);
- float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F);
- float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F);
- float f5 = -MathHelper.b(-f1 * 0.01745329F);
- float f6 = MathHelper.a(-f1 * 0.01745329F);
+ float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
+ float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f;
+ double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
+ double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height;
+ double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
+ Vec3D vec3d = Vec3D.b(d0, d1, d2);
+ float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
+ float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
+ float f5 = -MathHelper.b(-f1 * 0.017453292F);
+ float f6 = MathHelper.a(-f1 * 0.017453292F);
float f7 = f4 * f5;
- float f8 = f6;
- float f9 = f3 * f5;
- double d3 = 5D;
- Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3);
- MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, a == 0);
+ float f8 = f3 * f5;
+ double d3 = 5.0D;
+ Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
+ MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, this.a == 0);
if (movingobjectposition == null) {
return itemstack;
- }
- if (movingobjectposition.a == EnumMovingObjectType.a) {
- int i = movingobjectposition.b;
- int j = movingobjectposition.c;
- int k = movingobjectposition.d;
-
- if (!world.a(entityplayer, i, j, k)) {
- return itemstack;
- }
+ } else {
+ if (movingobjectposition.a == EnumMovingObjectType.TILE) {
+ int i = movingobjectposition.b;
+ int j = movingobjectposition.c;
+ int k = movingobjectposition.d;
- // CraftBukkit start - Click == placed when handling an empty bucket!
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
- // CraftBukkit end
-
- if (a == 0) {
- if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) {
- // CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return itemstack;
- }
- // CraftBukkit end
- world.e(i, j, k, 0);
- return new ItemStack(Item.av);
+ if (!world.a(entityhuman, i, j, k)) {
+ return itemstack;
}
- if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
- // CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
- if (pie.isCancelled()) {
- return itemstack;
- }
- // CraftBukkit end
- world.e(i, j, k, 0);
- return new ItemStack(Item.aw);
- }
- } else {
- if (a < 0) {
- return new ItemStack(Item.au);
- }
- if (movingobjectposition.e == 0) {
- j--;
- }
- if (movingobjectposition.e == 1) {
- j++;
- }
- if (movingobjectposition.e == 2) {
- k--;
- }
- if (movingobjectposition.e == 3) {
- k++;
- }
- if (movingobjectposition.e == 4) {
- i--;
- }
- if (movingobjectposition.e == 5) {
- i++;
- }
- if (world.e(i, j, k) || !world.c(i, j, k).a()) {
- if (world.q.d && a == Block.A.bi) {
- world.a(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
- for (int l = 0; l < 8; l++) {
- world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
+ // CraftBukkit start - Click == placed when handling an empty bucket!
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
+ // CraftBukkit end
+
+ if (this.a == 0) {
+ if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) {
+ // CraftBukkit start
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return itemstack;
}
- } else {
- // CraftBukkit start - bucket empty.
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
+ // CraftBukkit end
+
+ world.e(i, j, k, 0);
+ return new ItemStack(Item.WATER_BUCKET);
+ }
- if (pie.isCancelled()) {
+ if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) {
+ // CraftBukkit start
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
- world.b(i, j, k, a, 0);
+
+ world.e(i, j, k, 0);
+ return new ItemStack(Item.LAVA_BUCKET);
+ }
+ } else {
+ if (this.a < 0) {
+ return new ItemStack(Item.BUCKET);
+ }
+
+ if (movingobjectposition.e == 0) {
+ --j;
+ }
+
+ if (movingobjectposition.e == 1) {
+ ++j;
+ }
+
+ if (movingobjectposition.e == 2) {
+ --k;
+ }
+
+ if (movingobjectposition.e == 3) {
+ ++k;
+ }
+
+ if (movingobjectposition.e == 4) {
+ --i;
+ }
+
+ if (movingobjectposition.e == 5) {
+ ++i;
+ }
+
+ if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) {
+ if (world.q.d && this.a == Block.WATER.id) {
+ world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
+
+ for (int l = 0; l < 8; ++l) {
+ world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
+ } else {
+ // CraftBukkit start - bucket empty.
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+ // CraftBukkit end
+
+ world.b(i, j, k, this.a, 0);
+ }
+
+ return new ItemStack(Item.BUCKET);
}
- return new ItemStack(Item.au);
}
+ } else if (this.a == 0 && movingobjectposition.g instanceof EntityCow) {
+ return new ItemStack(Item.MILK_BUCKET);
}
- } else if (a == 0 && (movingobjectposition.g instanceof EntityCow)) {
- return new ItemStack(Item.aE);
+
+ return itemstack;
}
- return itemstack;
}
}