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

128 Zeilen
3.3 KiB
Java

2011-03-07 19:52:25 +01:00
package net.minecraft.server;
import java.util.Random;
2011-03-31 22:40:00 +02:00
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
2011-03-07 19:52:25 +01:00
public class BlockSign extends BlockContainer {
private Class a;
private boolean b;
2013-11-04 14:07:38 +01:00
protected BlockSign(Class oclass, boolean flag) {
super(Material.WOOD);
2011-03-07 19:52:25 +01:00
this.b = flag;
this.a = oclass;
float f = 0.25F;
float f1 = 1.0F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
}
2013-11-04 14:07:38 +01:00
public AxisAlignedBB a(World world, int i, int j, int k) {
2011-03-07 19:52:25 +01:00
return null;
}
public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {
2011-03-07 19:52:25 +01:00
if (!this.b) {
int l = iblockaccess.getData(i, j, k);
float f = 0.28125F;
float f1 = 0.78125F;
float f2 = 0.0F;
float f3 = 1.0F;
float f4 = 0.125F;
this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
if (l == 2) {
this.a(f2, f, 1.0F - f4, f3, f1, 1.0F);
}
if (l == 3) {
this.a(f2, f, 0.0F, f3, f1, f4);
}
if (l == 4) {
this.a(1.0F - f4, f, f2, 1.0F, f1, f3);
}
if (l == 5) {
this.a(0.0F, f, f2, f4, f1, f3);
}
}
}
2013-11-04 14:07:38 +01:00
public int b() {
2011-11-20 09:01:14 +01:00
return -1;
}
2013-11-04 14:07:38 +01:00
public boolean d() {
2011-05-26 14:48:22 +02:00
return false;
}
2013-03-13 23:33:27 +01:00
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return true;
}
public boolean c() {
2011-03-07 19:52:25 +01:00
return false;
}
2013-11-04 14:07:38 +01:00
public TileEntity a(World world, int i) {
2011-03-07 19:52:25 +01:00
try {
return (TileEntity) this.a.newInstance();
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
2013-11-04 14:07:38 +01:00
public Item getDropType(int i, Random random, int j) {
return Items.SIGN;
2011-03-07 19:52:25 +01:00
}
2013-11-04 14:07:38 +01:00
public void doPhysics(World world, int i, int j, int k, Block block) {
2011-03-07 19:52:25 +01:00
boolean flag = false;
if (this.b) {
2013-11-04 14:07:38 +01:00
if (!world.getType(i, j - 1, k).getMaterial().isBuildable()) {
2011-03-07 19:52:25 +01:00
flag = true;
}
} else {
2013-11-04 14:07:38 +01:00
int l = world.getData(i, j, k);
2011-03-07 19:52:25 +01:00
flag = true;
2013-11-04 14:07:38 +01:00
if (l == 2 && world.getType(i, j, k + 1).getMaterial().isBuildable()) {
2011-03-07 19:52:25 +01:00
flag = false;
}
2013-11-04 14:07:38 +01:00
if (l == 3 && world.getType(i, j, k - 1).getMaterial().isBuildable()) {
2011-03-07 19:52:25 +01:00
flag = false;
}
2013-11-04 14:07:38 +01:00
if (l == 4 && world.getType(i + 1, j, k).getMaterial().isBuildable()) {
2011-03-07 19:52:25 +01:00
flag = false;
}
2013-11-04 14:07:38 +01:00
if (l == 5 && world.getType(i - 1, j, k).getMaterial().isBuildable()) {
2011-03-07 19:52:25 +01:00
flag = false;
}
}
if (flag) {
2013-11-04 14:07:38 +01:00
this.b(world, i, j, k, world.getData(i, j, k), 0);
2013-03-13 23:33:27 +01:00
world.setAir(i, j, k);
2011-03-07 19:52:25 +01:00
}
2013-11-04 14:07:38 +01:00
super.doPhysics(world, i, j, k, block);
2011-03-31 22:40:00 +02:00
// CraftBukkit start
2013-11-04 14:07:38 +01:00
if (block != null && block.isPowerSource()) {
org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
int power = bukkitBlock.getBlockPower();
2013-11-04 14:07:38 +01:00
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
world.getServer().getPluginManager().callEvent(eventRedstone);
2011-03-07 19:52:25 +01:00
}
2011-03-31 22:40:00 +02:00
// CraftBukkit end
2011-03-07 19:52:25 +01:00
}
}