summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/BlockJukeBox.java
diff options
context:
space:
mode:
authordurron597 <martin.jared@gmail.com>2011-01-08 08:33:54 -0500
committerdurron597 <martin.jared@gmail.com>2011-01-08 08:33:54 -0500
commiteb4b30185fb79aa07fc74e955134df1e5be35859 (patch)
tree91196cbe0f4a941ae914fd987ac1967330fb6adc /src/main/java/net/minecraft/server/BlockJukeBox.java
parentfab66092e2e5379c4f3fa9cf37f37320c8ac0e18 (diff)
downloadcraftbukkit-eb4b30185fb79aa07fc74e955134df1e5be35859.tar
craftbukkit-eb4b30185fb79aa07fc74e955134df1e5be35859.tar.gz
craftbukkit-eb4b30185fb79aa07fc74e955134df1e5be35859.tar.lz
craftbukkit-eb4b30185fb79aa07fc74e955134df1e5be35859.tar.xz
craftbukkit-eb4b30185fb79aa07fc74e955134df1e5be35859.zip
Added BLOCK_INTERACT event
Diffstat (limited to 'src/main/java/net/minecraft/server/BlockJukeBox.java')
-rw-r--r--src/main/java/net/minecraft/server/BlockJukeBox.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/BlockJukeBox.java b/src/main/java/net/minecraft/server/BlockJukeBox.java
new file mode 100644
index 00000000..8c7e61ad
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockJukeBox.java
@@ -0,0 +1,64 @@
+package net.minecraft.server;
+
+
+import org.bukkit.craftbukkit.CraftBlock;
+import org.bukkit.craftbukkit.CraftPlayer;
+import org.bukkit.event.Event.Type;
+import org.bukkit.event.block.BlockInteractEvent;
+
+
+public class BlockJukeBox extends Block {
+
+ protected BlockJukeBox(int i, int j) {
+ super(i, j, Material.c);
+ }
+
+ public int a(int i) {
+ return bg + (i != 1 ? 0 : 1);
+ }
+
+ public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
+ int l = world.b(i, j, k);
+
+ if (l > 0) {
+ // Craftbukkit start - Interact Jukebox
+ CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
+ CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
+ BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
+
+ ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
+
+ if (bie.isCancelled()) return true;
+
+ f(world, i, j, k, l);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void f(World world, int i, int j, int k, int l) {
+ world.a((String) null, i, j, k);
+ world.b(i, j, k, 0);
+ int i1 = (Item.aU.aW + l) - 1;
+ float f1 = 0.7F;
+ double d = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D;
+ double d1 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.20000000000000001D + 0.59999999999999998D;
+ double d2 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D;
+ EntityItem entityitem = new EntityItem(world, (double) i + d, (double) j + d1, (double) k + d2, new ItemStack(i1));
+
+ entityitem.c = 10;
+ world.a(entityitem);
+ }
+
+ public void a(World world, int i, int j, int k, int l, float f1) {
+ if (world.z) {
+ return;
+ }
+ if (l > 0) {
+ f(world, i, j, k, l);
+ }
+ super.a(world, i, j, k, l, f1);
+ }
+}
+