3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Additional redstone hooks

Dieser Commit ist enthalten in:
Tahg 2011-03-07 13:48:03 -05:00
Ursprung 719038fcee
Commit df02c501a4

Datei anzeigen

@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import net.minecraft.server.BiomeBase;
import net.minecraft.server.BlockRedstoneWire;
import org.bukkit.*;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftChunk;
@ -326,7 +327,6 @@ public class CraftBlock implements Block {
}
public Biome getBiome() {
// TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk
BiomeBase base = chunk.getHandle().d.a().a(chunk.getX(), chunk.getZ());
if (base == BiomeBase.RAINFOREST) {
@ -378,4 +378,21 @@ public class CraftBlock implements Block {
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
return chunk.getHandle().d.j(x, y, z, blockFaceToNotch(face));
}
public int getBlockPower(BlockFace face) {
int power = 0;
BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE;
net.minecraft.server.World world = chunk.getHandle().d;
if((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.g(world, x, y - 1, z, power);
if((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.g(world, x, y + 1, z, power);
if((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.g(world, x, y, z - 1, power);
if((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.g(world, x, y, z + 1, power);
if((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.g(world, x - 1, y, z, power);
if((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.g(world, x + 1, y, z, power);
return face == BlockFace.SELF ? power - 1 : power;
}
public int getBlockPower() {
return getBlockPower(BlockFace.SELF);
}
}