Paper/src/main/java/net/minecraft/server/BlockCommand.java

88 Zeilen
2.8 KiB
Java

package net.minecraft.server;
2012-11-06 13:05:28 +01:00
import java.util.Random;
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class BlockCommand extends BlockContainer {
public BlockCommand(int i) {
2013-03-13 23:33:27 +01:00
super(i, Material.ORE);
}
2013-03-13 23:33:27 +01:00
public TileEntity b(World world) {
return new TileEntityCommand();
}
public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic) {
boolean flag = world.isBlockIndirectlyPowered(i, j, k);
int i1 = world.getData(i, j, k);
boolean flag1 = (i1 & 1) != 0;
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
2013-03-13 23:33:27 +01:00
int old = flag1 ? 15 : 0;
int current = flag ? 15 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
world.getServer().getPluginManager().callEvent(eventRedstone);
// CraftBukkit end
if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
2013-03-13 23:33:27 +01:00
world.setData(i, j, k, i1 | 1, 4);
world.a(i, j, k, this.id, this.a(world));
} else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
2013-03-13 23:33:27 +01:00
world.setData(i, j, k, i1 & -2, 4);
}
}
}
2013-03-13 23:33:27 +01:00
public void a(World world, int i, int j, int k, Random random) {
2012-11-06 13:05:28 +01:00
TileEntity tileentity = world.getTileEntity(i, j, k);
if (tileentity != null && tileentity instanceof TileEntityCommand) {
2013-03-13 23:33:27 +01:00
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
tileentitycommand.a(tileentitycommand.a(world));
world.m(i, j, k, this.id);
2012-11-06 13:05:28 +01:00
}
}
2013-03-13 23:33:27 +01:00
public int a(World world) {
2012-11-06 13:05:28 +01:00
return 1;
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
TileEntityCommand tileentitycommand = (TileEntityCommand) world.getTileEntity(i, j, k);
if (tileentitycommand != null) {
entityhuman.a((TileEntity) tileentitycommand);
}
return true;
}
2013-03-13 23:33:27 +01:00
public boolean q_() {
return true;
}
public int b_(World world, int i, int j, int k, int l) {
TileEntity tileentity = world.getTileEntity(i, j, k);
2013-07-01 13:03:00 +02:00
return tileentity != null && tileentity instanceof TileEntityCommand ? ((TileEntityCommand) tileentity).f() : 0;
2013-03-13 23:33:27 +01:00
}
public void postPlace(World world, int i, int j, int k, EntityLiving entityliving, ItemStack itemstack) {
TileEntityCommand tileentitycommand = (TileEntityCommand) world.getTileEntity(i, j, k);
if (itemstack.hasName()) {
2013-07-01 13:03:00 +02:00
tileentitycommand.b(itemstack.getName());
2013-03-13 23:33:27 +01:00
}
}
2013-07-01 13:03:00 +02:00
public int a(Random random) {
return 0;
}
}