Java 类net.minecraft.server.Block 实例源码

项目:Craftbukkit    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:Tweakkit-Server    文件:AntiXray.java   
public AntiXray(SpigotWorldConfig config)
{
    // Set all listed blocks as true to be obfuscated
    for ( int id : ( config.engineMode == 1 ) ? config.hiddenBlocks : config.replaceBlocks )
    {
        obfuscateBlocks[id] = true;
    }

    // For every block
    TByteSet blocks = new TByteHashSet();
    for ( Integer i : config.hiddenBlocks )
    {
        Block block = Block.getById( i );
        // Check it exists and is not a tile entity
        if ( block != null && !block.isTileEntity() )
        {
            // Add it to the set of replacement blocks
            blocks.add( (byte) (int) i );
        }
    }
    // Bake it to a flat array of replacements
    replacementOres = blocks.toArray();
}
项目:SpigotSource    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:ProjectAres    文件:NMSHacks.java   
/**
 * Test if the given tool is capable of "efficiently" mining the given block.
 *
 * Derived from CraftBlock.itemCausesDrops()
 */
public static boolean canMineBlock(MaterialData blockMaterial, org.bukkit.inventory.ItemStack tool) {
    if(!blockMaterial.getItemType().isBlock()) {
        throw new IllegalArgumentException("Material '" + blockMaterial + "' is not a block");
    }

    net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(blockMaterial.getItemType());
    net.minecraft.server.Item nmsTool = tool == null ? null : CraftMagicNumbers.getItem(tool.getType());

    return nmsBlock != null && (nmsBlock.getBlockData().getMaterial().isAlwaysDestroyable() ||
                                (nmsTool != null && nmsTool.canDestroySpecialBlock(nmsBlock.getBlockData())));
}
项目:ProjectAres    文件:NMSHacks.java   
public static Set<MaterialData> getBlockStates(Material material) {
    ImmutableSet.Builder<MaterialData> materials = ImmutableSet.builder();
    Block nmsBlock = CraftMagicNumbers.getBlock(material);
    List<IBlockData> states = nmsBlock.s().a();
    if(states != null) {
        for(IBlockData state : states) {
            int data = nmsBlock.toLegacyData(state);
            materials.add(material.getNewData((byte) data));
        }
    }
    return materials.build();
}
项目:CraftBukkit    文件:StructureGrowDelegate.java   
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();
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
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;
}
项目:Craftbukkit    文件:StructureGrowDelegate.java   
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();
}
项目:Craftbukkit    文件:CraftMagicNumbers.java   
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;
}
项目:Craftbukkit    文件:PerMaterialTest.java   
@Test
public void isBurnable() {
    if (material.isBlock()) {
        Block block = CraftMagicNumbers.getBlock(material);
        assertThat(material.isBurnable(), is(fireValues.containsKey(block) && fireValues.get(block) > 0));
    } else {
        assertFalse(material.isBurnable());
    }
}
项目:Almura-Server    文件:AntiXray.java   
private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius)
{
    return !Block.l( world.getTypeId( x, y, z ) ) /* isSolidBlock */
            || ( radius > 0
            && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x - 1, y, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y + 1, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y - 1, z, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y, z + 1, radius - 1 )
            || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void isSolid() {
    if (material == Material.AIR) {
        assertFalse(material.isSolid());
    } else if (material.isBlock()) {
        assertThat(material.isSolid(), is(Block.byId[material.getId()].material.isSolid()));
    } else {
        assertFalse(material.isSolid());
    }
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void isTransparent() {
    if (material == Material.AIR) {
        assertTrue(material.isTransparent());
    } else if (material.isBlock()) {
        assertThat(material.isTransparent(), is(not(Block.byId[material.getId()].material.blocksLight())));
    } else {
        assertFalse(material.isTransparent());
    }
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void isFlammable() {
    if (material != Material.AIR && material.isBlock()) {
        assertThat(material.isFlammable(), is(Block.byId[material.getId()].material.isBurnable()));
    } else {
        assertFalse(material.isFlammable());
    }
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void isOccluding() {
    if (material.isBlock()) {
        assertThat(material.isOccluding(), is(Block.l(material.getId())));
    } else {
        assertFalse(material.isOccluding());
    }
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void hasGravity() {
    if (material.isBlock()) {
        assertThat(material.hasGravity(), is(Block.byId[material.getId()] instanceof BlockSand));
    } else {
        assertFalse(material.hasGravity());
    }
}
项目:Tweakkit-Server    文件:StructureGrowDelegate.java   
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();
}
项目:Tweakkit-Server    文件:CraftMagicNumbers.java   
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;
}
项目:Tweakkit-Server    文件:AntiXray.java   
private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
{
    // If the block in question is loaded
    if ( world.isLoaded( x, y, z ) )
    {
        // Get block id
        Block block = world.getType(x, y, z);

        // See if it needs update
        if ( updateSelf && obfuscateBlocks[Block.getId( block )] )
        {
            // Send the update
            world.notify( x, y, z );
        }

        // Check other blocks for updates
        if ( radius > 0 )
        {
            updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
            updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
            updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
            updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
        }
    }
}
项目:Tweakkit-Server    文件:AntiXray.java   
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;
}
项目:SpigotSource    文件:StructureGrowDelegate.java   
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();
}
项目:SpigotSource    文件:CraftMagicNumbers.java   
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;
}
项目:SpigotSource    文件:PerMaterialTest.java   
@Test
public void isBurnable() {
    if (material.isBlock()) {
        Block block = CraftMagicNumbers.getBlock(material);
        assertThat(material.isBurnable(), is(fireValues.containsKey(block) && fireValues.get(block) > 0));
    } else {
        assertFalse(material.isBurnable());
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void isSolid() {
    if (material == Material.AIR) {
        assertFalse(material.isSolid());
    } else if (material.isBlock()) {
        assertThat(material.isSolid(), is(Block.byId[material.getId()].material.isSolid()));
    } else {
        assertFalse(material.isSolid());
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void isTransparent() {
    if (material == Material.AIR) {
        assertTrue(material.isTransparent());
    } else if (material.isBlock()) {
        assertThat(material.isTransparent(), is(not(Block.byId[material.getId()].material.blocksLight())));
    } else {
        assertFalse(material.isTransparent());
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void isFlammable() {
    if (material != Material.AIR && material.isBlock()) {
        assertThat(material.isFlammable(), is(Block.byId[material.getId()].material.isBurnable()));
    } else {
        assertFalse(material.isFlammable());
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void isOccluding() {
    if (material.isBlock()) {
        assertThat(material.isOccluding(), is(Block.l(material.getId())));
    } else {
        assertFalse(material.isOccluding());
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void hasGravity() {
    if (material.isBlock()) {
        assertThat(material.hasGravity(), is(Block.byId[material.getId()] instanceof BlockSand));
    } else {
        assertFalse(material.hasGravity());
    }
}
项目:ProjectAres    文件:NMSHacks.java   
private static String getTranslationKey(Block nmsBlock) {
    return nmsBlock.a() + ".name";
}
项目:ProjectAres    文件:NMSHacks.java   
private static @Nullable String getBlockTranslationKey(Material material) {
    Block nmsBlock = CraftMagicNumbers.getBlock(material);
    return nmsBlock == null ? null : getTranslationKey(nmsBlock);
}
项目:CraftBukkit    文件:BlockStateListPopulator.java   
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getId(block));
    state.setRawData((byte) data);
    list.add(state);
}
项目:CraftBukkit    文件:BlockStateListPopulator.java   
public void setTypeUpdate(int x, int y, int z, Block block) {
    this.setType(x, y, z, block);
}
项目:CraftBukkit    文件:BlockStateListPopulator.java   
public void setType(int x, int y, int z, Block block) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getId(block));
    list.add(state);
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
public static Block getBlock(org.bukkit.block.Block block) {
    return getBlock(block.getType());
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
@Deprecated
// A bad method for bad magic.
public static Block getBlock(int id) {
    return getBlock(Material.getMaterial(id));
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
@Deprecated
// A bad method for bad magic.
public static int getId(Block block) {
    return Block.getId(block);
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
public static Material getMaterial(Block block) {
    return Material.getMaterial(Block.getId(block));
}
项目:Craftbukkit    文件:BlockStateListPopulator.java   
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getId(block));
    state.setRawData((byte) data);
    list.add(state);
}
项目:Craftbukkit    文件:BlockStateListPopulator.java   
public void setTypeUpdate(int x, int y, int z, Block block) {
    this.setType(x, y, z, block);
}
项目:Craftbukkit    文件:BlockStateListPopulator.java   
public void setType(int x, int y, int z, Block block) {
    BlockState state = world.getBlockAt(x, y, z).getState();
    state.setTypeId(Block.getId(block));
    list.add(state);
}