PaperMC/src/main/java/net/minecraft/server/BlockJukeBox.java

73 lines
2.4 KiB
Java
Raw Normal View History

2011-01-08 14:33:54 +01:00
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
2011-01-08 14:33:54 +01:00
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
2011-01-08 14:33:54 +01:00
public class BlockJukeBox extends Block {
protected BlockJukeBox(int i, int j) {
super(i, j, Material.c);
}
public int a(int i) {
2011-01-14 14:31:10 +01:00
return bh + (i != 1 ? 0 : 1);
2011-01-08 14:33:54 +01:00
}
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
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) {
return true;
}
// CraftBukkit end
2011-01-08 14:33:54 +01:00
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);
2011-01-14 14:31:10 +01:00
world.c(i, j, k, 0);
int i1 = (Item.aY.ba + l) - 1;
2011-01-08 14:33:54 +01:00
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;
2011-01-14 14:31:10 +01:00
EntityItem entityitem = new EntityItem(world, (double) i + d, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
2011-01-08 14:33:54 +01:00
entityitem.c = 10;
world.a(((Entity) (entityitem)));
2011-01-08 14:33:54 +01:00
}
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);
}
}