public int getBlockPower(BlockFace face) { int power = 0; BlockRedstoneWire wire = Blocks.REDSTONE_WIRE; net.minecraft.server.World world = chunk.getHandle().world; if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(x, y - 1, z, 0)) power = wire.getPower(world, x, y - 1, z, power); if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(x, y + 1, z, 1)) power = wire.getPower(world, x, y + 1, z, power); if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(x + 1, y, z, 2)) power = wire.getPower(world, x + 1, y, z, power); if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(x - 1, y, z, 3)) power = wire.getPower(world, x - 1, y, z, power); if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z - 1, 4)) power = wire.getPower(world, x, y, z - 1, power); if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z + 1, 5)) power = wire.getPower(world, x, y, z - 1, power); return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0; }
public boolean breakNaturally() { // Order matters here, need to drop before setting to air so skulls can get their data net.minecraft.server.Block block = this.getNMSBlock(); byte data = getData(); boolean result = false; if (block != null && block != Blocks.AIR) { block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0); result = true; } setTypeId(Material.AIR.getId()); return result; }
public Collection<ItemStack> getDrops() { List<ItemStack> drops = new ArrayList<ItemStack>(); net.minecraft.server.Block block = this.getNMSBlock(); if (block != Blocks.AIR) { byte data = getData(); // based on nms.Block.dropNaturally int count = block.getDropCount(0, chunk.getHandle().world.random); for (int i = 0; i < count; ++i) { Item item = block.getDropType(data, chunk.getHandle().world.random, 0); if (item != null) { // Skulls are special, their data is based on the tile entity if (Blocks.SKULL == block) { net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z)); TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z); if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { nmsStack.setTag(new NBTTagCompound()); NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); nmsStack.getTag().set("SkullOwner", nbttagcompound); } drops.add(CraftItemStack.asBukkitCopy(nmsStack)); // We don't want to drop cocoa blocks, we want to drop cocoa beans. } else if (Blocks.COCOA == block) { int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1); for (int j = 0; j < dropAmount; ++j) { drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3)); } } else { drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data))); } } } } return drops; }
public boolean isEmpty(int x, int y, int z) { for (BlockState state : blocks) { if (state.getX() == x && state.getY() == y && state.getZ() == z) { return Block.getById(state.getTypeId()) == Blocks.AIR; } } return world.getBlockAt(x, y, z).isEmpty(); }
public static Block getBlock(Material material) { // TODO: Don't use ID Block block = Block.getById(material.getId()); if (block == null) { return Blocks.AIR; } return block; }
public void setDisplayBlock(MaterialData material) { if(material != null) { IBlockData block = CraftMagicNumbers.getBlock(material.getItemTypeId()).fromLegacyData(material.getData()); this.getHandle().setDisplayBlock(block); } else { // Set block to air (default) and set the flag to not have a display block. this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData()); this.getHandle().a(false); } }
private static boolean isSolidBlock(Block block) { // Mob spawners are treated as solid blocks as far as the // game is concerned for lighting and other tasks but for // rendering they can be seen through therefor we special // case them so that the antixray doesn't show the fake // blocks around them. return block.r() && block != Blocks.MOB_SPAWNER; }
public static Block getBlock(Material material) { if (material == null) { return null; } // TODO: Don't use ID Block block = Block.getById(material.getId()); if (block == null) { return Blocks.AIR; } return block; }
public boolean eject() { boolean result = isPlaying(); ((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ()); return result; }
@BeforeClass public static void getFireValues() { fireValues = Util.getInternalState(BlockFire.class, Blocks.FIRE, "a"); }
@BeforeClass public static void getFireValues() { fireValues = Util.getInternalState(BlockFire.class, Blocks.FIRE, "flameChances"); }