Java 类org.bukkit.craftbukkit.block.CraftBlockState 实例源码

项目:CraftBukkit    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = generateTree(loc, type);
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            net.minecraft.server.Block oldBlock = world.getType(x, y, z);
            int typeId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, typeId, data);
            net.minecraft.server.Block newBlock = world.getType(x, y, z);
            world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    } else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:Tweakkit-Server    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = generateTree(loc, type);
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            net.minecraft.server.Block oldBlock = world.getType(x, y, z);
            int typeId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, typeId, data);
            net.minecraft.server.Block newBlock = world.getType(x, y, z);
            world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    } else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Craftbukkit    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = generateTree(loc, type);
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            BlockPosition position = new BlockPosition(x, y, z);
            net.minecraft.server.Block oldBlock = world.getType(position).getBlock();
            int typeId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, typeId, data);
            net.minecraft.server.Block newBlock = world.getType(position).getBlock();
            world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    } else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:Craftbukkit    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, int type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(type);
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:SpigotSource    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = generateTree(loc, type);
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            BlockPosition position = new BlockPosition(x, y, z);
            net.minecraft.server.IBlockData oldBlock = world.getType(position);
            int typeId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, typeId, data);
            net.minecraft.server.IBlockData newBlock = world.getType(position);
            world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    } else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:SpigotSource    文件:CraftEventFactory.java   
public static boolean handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(net.minecraft.server.Block.getId(type));
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }

    return !event.isCancelled();
}
项目:Craft-city    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(World world, int x, int y, int z, int type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(type);
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:MCPBukkit    文件:CraftEventFactory.java   
public static void handleBlockGrowEvent(net.minecraft.world.World world, int x, int y, int z, int type, int data) {
    Block block = world.getWorld().getBlockAt(x, y, z);
    CraftBlockState state = (CraftBlockState) block.getState();
    state.setTypeId(type);
    state.setRawData((byte) data);

    BlockGrowEvent event = new BlockGrowEvent(block, state);
    Bukkit.getPluginManager().callEvent(event);

    if (!event.isCancelled()) {
        state.update(true);
    }
}
项目:Thermos    文件:BlockStateListPopulator.java   
public void setTypeAndData(int x, int y, int z, net.minecraft.block.Block block, int data, int light) {
    CraftBlockState state = (CraftBlockState)world.getBlockAt(x, y, z).getState();
    state.setTypeId(net.minecraft.block.Block.getIdFromBlock(block));
    state.setRawData((byte) data);
    list.add(state);
}
项目:CauldronGit    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    net.minecraft.world.gen.feature.WorldGenerator gen;
    switch (type) {
    case BIG_TREE:
        gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true);
        break;
    case BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false);
        break;
    case REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true);
        break;
    case TALL_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga1();
        break;
    case JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling
        break;
    case SMALL_JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
        break;
    case JUNGLE_BUSH:
        gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0);
        break;
    case RED_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1);
        break;
    case BROWN_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0);
        break;
    case SWAMP:
        gen = new net.minecraft.world.gen.feature.WorldGenSwamp();
        break;
    case ACACIA:
        gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true);
        break;
    case DARK_OAK:
        gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true);
        break;
    case MEGA_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean());
        break;
    case TALL_BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true);
        break;
    case TREE:
    default:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true);
        break;
    }

    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); 
            int newId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, newId, data);
            net.minecraft.block.Block newBlock = world.getBlock(x, y, z); 
            world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    }
    else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:Cauldron-Old    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    net.minecraft.world.gen.feature.WorldGenerator gen;
    switch (type) {
    case BIG_TREE:
        gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true);
        break;
    case BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false);
        break;
    case REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true);
        break;
    case TALL_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga1();
        break;
    case JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling
        break;
    case SMALL_JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
        break;
    case JUNGLE_BUSH:
        gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0);
        break;
    case RED_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1);
        break;
    case BROWN_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0);
        break;
    case SWAMP:
        gen = new net.minecraft.world.gen.feature.WorldGenSwamp();
        break;
    case ACACIA:
        gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true);
        break;
    case DARK_OAK:
        gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true);
        break;
    case MEGA_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean());
        break;
    case TALL_BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true);
        break;
    case TREE:
    default:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true);
        break;
    }

    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); 
            int newId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, newId, data);
            net.minecraft.block.Block newBlock = world.getBlock(x, y, z); 
            world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    }
    else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:CraftBukkit    文件:ItemFlintAndSteel.java   
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        if (world.getType(i, j, k).getMaterial() == Material.AIR) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, g.nextFloat() * 0.4F + 0.8F);
            world.setTypeUpdate(i, j, k, Blocks.FIRE);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}
项目:Craftbukkit    文件:CraftMetaBlockState.java   
@Override
public void setBlockState(BlockState blockState) {
    Validate.notNull(blockState, "blockState must not be null");
    TileEntity te = ((CraftBlockState) blockState).getTileEntity();
    Validate.notNull(te, "Invalid blockState");

    boolean valid;
    switch (material) {
    case SIGN:
    case SIGN_POST:
    case WALL_SIGN:
        valid = te instanceof TileEntitySign;
        break;
    case CHEST:
    case TRAPPED_CHEST:
        valid = te instanceof TileEntityChest;
        break;
    case BURNING_FURNACE:
    case FURNACE:
        valid = te instanceof TileEntityFurnace;
        break;
    case DISPENSER:
        valid = te instanceof TileEntityDispenser;
        break;
    case DROPPER:
        valid = te instanceof TileEntityDropper;
        break;
    case HOPPER:
        valid = te instanceof TileEntityHopper;
        break;
    case MOB_SPAWNER:
        valid = te instanceof TileEntityMobSpawner;
        break;
    case NOTE_BLOCK:
        valid = te instanceof TileEntityNote;
        break;
    case JUKEBOX:
        valid = te instanceof BlockJukeBox.TileEntityRecordPlayer;
        break;
    case BREWING_STAND:
        valid = te instanceof TileEntityBrewingStand;
        break;
    case SKULL:
        valid = te instanceof TileEntitySkull;
        break;
    case COMMAND:
        valid = te instanceof TileEntityCommand;
        break;
    case BEACON:
        valid = te instanceof TileEntityBeacon;
        break;
    case BANNER:
    case WALL_BANNER:
    case STANDING_BANNER:
        valid = te instanceof TileEntityBanner;
        break;
    default:
        valid = false;
        break;
    }

    Validate.isTrue(valid, "Invalid blockState for " + material);

    blockEntityTag = new NBTTagCompound();
    te.b(blockEntityTag);
}
项目:Almura-Server    文件:ItemFlintAndSteel.java   
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit

    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        int i1 = world.getTypeId(i, j, k);

        if (i1 == 0) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, Item.f.nextFloat() * 0.4F + 0.8F); // CraftBukkit - fix compilation
            world.setTypeIdUpdate(i, j, k, Block.FIRE.id);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}
项目:Tweakkit-Server    文件:ItemFlintAndSteel.java   
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        if (world.getType(i, j, k).getMaterial() == Material.AIR) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, g.nextFloat() * 0.4F + 0.8F);
            world.setTypeUpdate(i, j, k, Blocks.FIRE);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}
项目:Cauldron    文件:ItemFlintAndSteel.java   
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    int clickedX = p_77648_4_, clickedY = p_77648_5_, clickedZ = p_77648_6_; // CraftBukkit

    if (p_77648_7_ == 0)
    {
        --p_77648_5_;
    }

    if (p_77648_7_ == 1)
    {
        ++p_77648_5_;
    }

    if (p_77648_7_ == 2)
    {
        --p_77648_6_;
    }

    if (p_77648_7_ == 3)
    {
        ++p_77648_6_;
    }

    if (p_77648_7_ == 4)
    {
        --p_77648_4_;
    }

    if (p_77648_7_ == 5)
    {
        ++p_77648_4_;
    }

    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        if (p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_))
        {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, p_77648_2_).isCancelled())
            {
                p_77648_1_.damageItem(1, p_77648_2_);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
            // CraftBukkit end
            p_77648_3_.playSoundEffect((double)p_77648_4_ + 0.5D, (double)p_77648_5_ + 0.5D, (double)p_77648_6_ + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, Blocks.fire);
            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(p_77648_3_, p_77648_2_, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild())
            {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }

            // CraftBukkit end
        }

        p_77648_1_.damageItem(1, p_77648_2_);
        return true;
    }
}
项目:Cauldron    文件:CraftWorld.java   
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
    net.minecraft.world.gen.feature.WorldGenerator gen;
    switch (type) {
    case BIG_TREE:
        gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true);
        break;
    case BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false);
        break;
    case REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true);
        break;
    case TALL_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenTaiga1();
        break;
    case JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling
        break;
    case SMALL_JUNGLE:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
        break;
    case JUNGLE_BUSH:
        gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0);
        break;
    case RED_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1);
        break;
    case BROWN_MUSHROOM:
        gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0);
        break;
    case SWAMP:
        gen = new net.minecraft.world.gen.feature.WorldGenSwamp();
        break;
    case ACACIA:
        gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true);
        break;
    case DARK_OAK:
        gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true);
        break;
    case MEGA_REDWOOD:
        gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean());
        break;
    case TALL_BIRCH:
        gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true);
        break;
    case TREE:
    default:
        gen = new net.minecraft.world.gen.feature.WorldGenTrees(true);
        break;
    }

    world.captureTreeGeneration = true;
    world.captureBlockStates = true;
    boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    world.captureBlockStates = false;
    world.captureTreeGeneration = false;
    if (grownTree) { // Copy block data to delegate
        for (BlockState blockstate : world.capturedBlockStates) {
            int x = blockstate.getX();
            int y = blockstate.getY();
            int z = blockstate.getZ();
            net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); 
            int newId = blockstate.getTypeId();
            int data = blockstate.getRawData();
            int flag = ((CraftBlockState)blockstate).getFlag();
            delegate.setTypeIdAndData(x, y, z, newId, data);
            net.minecraft.block.Block newBlock = world.getBlock(x, y, z); 
            world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
        }
        world.capturedBlockStates.clear();
        return true;
    }
    else {
        world.capturedBlockStates.clear();
        return false;
    }
}
项目:SpigotSource    文件:CraftMetaBlockState.java   
@Override
public void setBlockState(BlockState blockState) {
    Validate.notNull(blockState, "blockState must not be null");
    TileEntity te = ((CraftBlockState) blockState).getTileEntity();
    Validate.notNull(te, "Invalid blockState");

    boolean valid;
    switch (material) {
    case SIGN:
    case SIGN_POST:
    case WALL_SIGN:
        valid = te instanceof TileEntitySign;
        break;
    case CHEST:
    case TRAPPED_CHEST:
        valid = te instanceof TileEntityChest;
        break;
    case BURNING_FURNACE:
    case FURNACE:
        valid = te instanceof TileEntityFurnace;
        break;
    case DISPENSER:
        valid = te instanceof TileEntityDispenser;
        break;
    case DROPPER:
        valid = te instanceof TileEntityDropper;
        break;
    case END_GATEWAY:
        valid = te instanceof TileEntityEndGateway;
        break;
    case HOPPER:
        valid = te instanceof TileEntityHopper;
        break;
    case MOB_SPAWNER:
        valid = te instanceof TileEntityMobSpawner;
        break;
    case NOTE_BLOCK:
        valid = te instanceof TileEntityNote;
        break;
    case JUKEBOX:
        valid = te instanceof BlockJukeBox.TileEntityRecordPlayer;
        break;
    case BREWING_STAND:
        valid = te instanceof TileEntityBrewingStand;
        break;
    case SKULL:
        valid = te instanceof TileEntitySkull;
        break;
    case COMMAND:
    case COMMAND_REPEATING:
    case COMMAND_CHAIN:
        valid = te instanceof TileEntityCommand;
        break;
    case BEACON:
        valid = te instanceof TileEntityBeacon;
        break;
    case SHIELD:
    case BANNER:
    case WALL_BANNER:
    case STANDING_BANNER:
        valid = te instanceof TileEntityBanner;
        break;
    case FLOWER_POT_ITEM:
        valid = te instanceof TileEntityFlowerPot;
        break;
    default:
        valid = false;
        break;
    }

    Validate.isTrue(valid, "Invalid blockState for " + material);

    blockEntityTag = new NBTTagCompound();
    te.save(blockEntityTag);
}
项目:Craft-city    文件:ItemFlintAndSteel.java   
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit

    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        int i1 = world.getTypeId(i, j, k);

        if (i1 == 0) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, e.nextFloat() * 0.4F + 0.8F);
            world.setTypeIdUpdate(i, j, k, Block.FIRE.id);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}