2012-04-02 14:43:59 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
2012-04-02 16:01:48 +02:00
|
|
|
|
2012-04-02 14:43:59 +02:00
|
|
|
public class BlockRedstoneLamp extends Block {
|
|
|
|
|
|
|
|
private final boolean a;
|
|
|
|
|
|
|
|
public BlockRedstoneLamp(int i, boolean flag) {
|
2013-03-13 23:33:27 +01:00
|
|
|
super(i, Material.BUILDABLE_GLASS);
|
2012-04-02 14:43:59 +02:00
|
|
|
this.a = flag;
|
|
|
|
if (flag) {
|
|
|
|
this.a(1.0F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onPlace(World world, int i, int j, int k) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
world.a(i, j, k, this.id, 4);
|
2012-04-02 14:43:59 +02:00
|
|
|
} else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) {
|
2012-04-02 16:01:48 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdAndData(i, j, k, Block.REDSTONE_LAMP_ON.id, 0, 2);
|
2012-04-02 14:43:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
if (this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
|
2012-07-29 09:33:13 +02:00
|
|
|
world.a(i, j, k, this.id, 4);
|
2012-04-02 14:43:59 +02:00
|
|
|
} else if (!this.a && world.isBlockIndirectlyPowered(i, j, k)) {
|
2012-04-02 16:01:48 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (CraftEventFactory.callRedstoneChange(world, i, j, k, 0, 15).getNewCurrent() != 15) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdAndData(i, j, k, Block.REDSTONE_LAMP_ON.id, 0, 2);
|
2012-04-02 14:43:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(World world, int i, int j, int k, Random random) {
|
2012-04-02 14:43:59 +02:00
|
|
|
if (!world.isStatic && this.a && !world.isBlockIndirectlyPowered(i, j, k)) {
|
2012-04-02 16:01:48 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (CraftEventFactory.callRedstoneChange(world, i, j, k, 15, 0).getNewCurrent() != 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
world.setTypeIdAndData(i, j, k, Block.REDSTONE_LAMP_OFF.id, 0, 2);
|
2012-04-02 14:43:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDropType(int i, Random random, int j) {
|
|
|
|
return Block.REDSTONE_LAMP_OFF.id;
|
|
|
|
}
|
|
|
|
}
|