Java 类net.minecraft.block.BlockSnow 实例源码

项目:Bewitchment    文件:SnowTrailBrew.java   
@Override
void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
    int box = 1 + (int) ((float) amplifier / 2F);

    BlockPos posI = pos.add(box, box, box);
    BlockPos posF = pos.add(-box, -box, -box);

    Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
    for (BlockPos spot : spots) {
        IBlockState state = world.getBlockState(spot);
        boolean place = amplifier > 2 || world.rand.nextInt(3) == 0;
        if (place && Blocks.SNOW_LAYER.canPlaceBlockAt(world, spot) && state.getBlock().isReplaceable(world, spot)) {
            world.setBlockState(spot, Blocks.SNOW_LAYER.getDefaultState()
                    .withProperty(BlockSnow.LAYERS, 1 + world.rand.nextInt(7)), 3);
        }
    }
}
项目:WinterWonderLand    文件:WinterWonderLand.java   
private static void incrementSnowHeight(WorldServer world, BlockPos pos) {
        pos = getSnowTopPosition(world, pos);

        int layers = snowHeightAt(world, pos);

        // Check if we can snow here if this is the first snow layer
    if(layers == 0 && !world.canSnowAt(pos, true)) {
        return;
    } else if (!isSnowyArea(world, pos)) {
        return;
    }

    if (layers >= Config.maxSnowLayers ) {
        return;
    }

    if (layers == 0 || layers % 8 != 0) {
        // Continue stacking on current stack
        world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, layers%8+1));
    } else {
        // Add onto stack on block above, this one is full
        world.setBlockState(pos.up(), Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, layers%8+1));
    }
}
项目:DrCyanosWonderfulWands    文件:WandOfIce.java   
protected int freezeBlock(World w, BlockPos coord){
    IBlockState bs = w.getBlockState(coord);
    Block target = bs.getBlock();
    if(target == Blocks.WATER || target == Blocks.FLOWING_WATER){
        w.setBlockState(coord, Blocks.ICE.getDefaultState());
        return 1;
    } else if(target == Blocks.LAVA || target == Blocks.FLOWING_LAVA){
        w.setBlockState(coord, Blocks.COBBLESTONE.getDefaultState());
        return 1;
    }else if(target == Blocks.SNOW_LAYER) {
        if(((Integer)bs.getValue(BlockSnow.LAYERS)) < 8){
            w.setBlockState(coord, Blocks.SNOW_LAYER.getDefaultState()
                    .withProperty(BlockSnow.LAYERS,(((Integer)bs.getValue(BlockSnow.LAYERS)) + 1)));
        } else {
            w.setBlockState(coord, Blocks.SNOW.getDefaultState());
        }
    }else if(target.isFullCube(bs) && w.isAirBlock(coord.up())){
        w.setBlockState(coord.up(), Blocks.SNOW_LAYER.getDefaultState());
        return 1;
    }
    return 0;
}
项目:OpenBlocks    文件:SnowmanBehavior.java   
@Override
public int executeActivateBehavior(TileEntityTrophy tile, EntityPlayer player) {
    final BlockPos base = tile.getPos();
    final World world = tile.getWorld();

    for (int x = -1; x <= 1; x++) {
        for (int z = -1; z <= 1; z++) {
            final BlockPos pos = base.add(x, 0, z);

            if (world.isAirBlock(pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)) {
                final Integer snowLayers = CollectionUtils.getRandom(BlockSnow.LAYERS.getAllowedValues());
                world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, snowLayers));
            }
        }
    }

    return 10;
}
项目:chesttransporter    文件:ItemChestTransporter.java   
private BlockPos getChestCoords(World world, BlockPos pos, EnumFacing facing)
{
    IBlockState iblockstate = world.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block != Blocks.SNOW_LAYER || iblockstate.getValue(BlockSnow.LAYERS) >= 1)
    {
        if (!block.isReplaceable(world, pos))
        {
            pos = pos.offset(facing);
        }
    }

    return pos;
}
项目:WinterWonderLand    文件:WinterWonderLand.java   
private static void onTickSnowDecrease(WorldServer world) {
        for (Iterator<Chunk> iterator = world.getPersistentChunkIterable(world.getPlayerChunkMap().getChunkIterator()); iterator.hasNext();) {
            Chunk chunk = iterator.next();

            if (r.nextInt(Config.snowMeltRate) != 0) {
                continue;
            }

BlockPos pos = getRandomPosInChunk(chunk);

            pos = getSnowTopPosition(world, pos);

            int layers = snowHeightAt(world, pos);

            if (layers <= Config.snowMinLayers) {
                continue;
            }

            if (layers % 8 != 1) {
                // decrement layer
                world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, (layers-1)%8));
            } else {
                //remove last layer
                world.setBlockToAir(pos);
            }
        }
    }
项目:WinterWonderLand    文件:WinterWonderLand.java   
private static int snowHeightAt(WorldServer world, BlockPos pos) {
IBlockState currentBlock = world.getBlockState(pos);
if (currentBlock.getBlock() == Blocks.SNOW_LAYER) {
    return snowHeightAt(world, pos.down()) + currentBlock.getValue(BlockSnow.LAYERS);
}
if (currentBlock.getBlock() == Blocks.AIR && world.getBlockState(pos.down()).getBlock() != Blocks.AIR) {
    return snowHeightAt(world, pos.down());
}
return 0;
    }
项目:customstuff4    文件:ItemSnow.java   
@Override
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    IBlockState state = world.getBlockState(pos);
    return (state.getBlock() == block && state.getValue(BlockSnow.LAYERS) <= 7)
           || super.canPlaceBlockOnSide(world, pos, side, player, stack);
}
项目:FoodCraft-Reloaded    文件:ItemFruitCake.java   
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(fruitType.toString(), "cake")));

    if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1)
        facing = EnumFacing.UP;
    else if (!block.isReplaceable(worldIn, pos))
        pos = pos.offset(facing);

    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) {
        IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);

        if (!worldIn.setBlockState(pos, blockState, 11))
            return EnumActionResult.FAIL;
        else {
            blockState = worldIn.getBlockState(pos);

            if (blockState.getBlock() == cake) {
                ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack);
                blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack);
            }

            SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
        return EnumActionResult.FAIL;
}
项目:FoodCraft-Reloaded    文件:ItemVegetableCake.java   
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(vegetableType.toString(), "cake")));

    if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1)
        facing = EnumFacing.UP;
    else if (!block.isReplaceable(worldIn, pos))
        pos = pos.offset(facing);

    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) {
        IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand);

        if (!worldIn.setBlockState(pos, blockState, 11))
            return EnumActionResult.FAIL;
        else {
            blockState = worldIn.getBlockState(pos);

            if (blockState.getBlock() == cake) {
                ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack);
                blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack);
            }

            SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player);
            worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.shrink(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
        return EnumActionResult.FAIL;
}
项目:malmo    文件:BuildBattleDecoratorImplementation.java   
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    // Disallow creating or destroying events in the player structure:
    if (event instanceof PlayerInteractEvent.LeftClickBlock)
    {
        // Destroy block
        if (blockInBounds(event.getPos(), this.sourceBounds))
            event.setCanceled(true);
    }
    else if (event instanceof PlayerInteractEvent.RightClickBlock)
    {
        // Place block - need to work out *where* the block would be placed.
        // This code was cribbed from ItemBlock.onItemUse()
        IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
        Block block = iblockstate.getBlock();
        EnumFacing side = event.getFace();
        BlockPos pos = event.getPos();
        if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
        {
            side = EnumFacing.UP;
        }
        else if (!block.isReplaceable(event.getWorld(), pos))
        {
            pos = pos.offset(side);
        }
        if (blockInBounds(pos, this.sourceBounds))
            event.setCanceled(true);
    }
}
项目:NOVA-Core    文件:BWBlock.java   
@Override
public boolean shouldDisplacePlacement() {
    if (mcBlock == Blocks.snow_layer && ((int) blockState().getValue(BlockSnow.LAYERS) < 1)) {
        return false;
    }

    if (mcBlock == Blocks.vine || mcBlock == Blocks.tallgrass || mcBlock == Blocks.deadbush || mcBlock.isReplaceable((net.minecraft.world.World) blockAccess(), blockPos())) {
        return false;
    }
    return super.shouldDisplacePlacement();
}
项目:Cyclic    文件:EntitySnowballBolt.java   
private static void setMoreSnow(World world, BlockPos pos) {
  IBlockState hitState = world.getBlockState(pos);
  int m = hitState.getBlock().getMetaFromState(hitState) + 1;
  if (BlockSnow.LAYERS.getAllowedValues().contains(m + 1)) {
    world.setBlockState(pos,
        Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, m + 1));
    UtilSound.playSound(world, pos, SoundEvents.BLOCK_SNOW_PLACE, SoundCategory.BLOCKS);
  }
  else {
    setNewSnow(world, pos.up());
  }
}
项目:Resilience-Client-Source    文件:World.java   
/**
 * Returns true if the block at the given coordinate has a solid (buildable) top surface.
 */
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess p_147466_0_, int p_147466_1_, int p_147466_2_, int p_147466_3_)
{
    Block var4 = p_147466_0_.getBlock(p_147466_1_, p_147466_2_, p_147466_3_);
    int var5 = p_147466_0_.getBlockMetadata(p_147466_1_, p_147466_2_, p_147466_3_);
    return var4.getMaterial().isOpaque() && var4.renderAsNormalBlock() ? true : (var4 instanceof BlockStairs ? (var5 & 4) == 4 : (var4 instanceof BlockSlab ? (var5 & 8) == 8 : (var4 instanceof BlockHopper ? true : (var4 instanceof BlockSnow ? (var5 & 7) == 7 : false))));
}
项目:ZeldaSwordSkills    文件:ItemHeldBlock.java   
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
    IBlockState worldState = world.getBlockState(pos);
    Block worldBlock = worldState.getBlock();
    Block blockToPlace = getBlockFromStack(stack);
    if (worldBlock == Blocks.snow_layer && ((Integer) worldState.getValue(BlockSnow.LAYERS)).intValue() < 1) {
        side = EnumFacing.UP;
    } else if (!worldBlock.isReplaceable(world, pos)) {
        pos = pos.offset(side);
    }
    if (stack.stackSize == 0) {
        return false;
    } else if (!player.canPlayerEdit(pos, side, stack)) {
        return false;
    } else if (pos.getY() == 255 && blockToPlace.getMaterial().isSolid()) {
        return false;
    } else if (world.canBlockBePlaced(blockToPlace, pos, false, side, null, stack)) {
        int meta = getMetaFromStack(stack);
        IBlockState state = blockToPlace.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, meta, player);
        if (!world.isRemote && placeBlockAt(stack, player, world, pos, side, state)) {
            world.playSoundEffect((pos.getX() + 0.5D), (pos.getY() + 0.5D), (pos.getZ() + 0.5D), blockToPlace.stepSound.getBreakSound(), (blockToPlace.stepSound.getVolume() + 1.0F) / 2.0F, blockToPlace.stepSound.getFrequency() * 0.8F);
            ItemStack gauntlets = (stack.hasTagCompound() && stack.getTagCompound().hasKey("gauntlets") ?
                    ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("gauntlets")) : null);
            player.setCurrentItemOrArmor(0, gauntlets);
        }
        return true;
    } else {
        return false;
    }
}
项目:RuneCraftery    文件:World.java   
/**
 * Performs check to see if the block is a normal, solid block, or if the metadata of the block indicates that its
 * facing puts its solid side upwards. (inverted stairs, for example)
 */
@Deprecated //DO NOT USE THIS!!! USE doesBlockHaveSolidTopSurface
public boolean isBlockTopFacingSurfaceSolid(Block par1Block, int par2)
{
    // -.-  Mojang PLEASE make this location sensitive, you have no reason not to.
    return par1Block == null ? false : (par1Block.blockMaterial.isOpaque() && par1Block.renderAsNormalBlock() ? true : (par1Block instanceof BlockStairs ? (par2 & 4) == 4 : (par1Block instanceof BlockHalfSlab ? (par2 & 8) == 8 : (par1Block instanceof BlockHopper ? true : (par1Block instanceof BlockSnow ? (par2 & 7) == 7 : false)))));
}
项目:IceAndShadow2    文件:NyxItemExousium.java   
@Override
public boolean onItemUse(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int dmg, float a, float b,
        float c) {
    final Block bl = w.getBlock(x, y, z);
    if (is.getItemDamage() >= 1) {
        boolean converted = false;
        if (bl.getMaterial() == Material.ice) {
            w.setBlockToAir(x, y, z);
            w.setBlock(x, y, z, NyxBlocks.exousicWater, 14, 3);
            converted = true;
        } else if (bl instanceof BlockSnow) {
            w.setBlockToAir(x, y, z);
            w.setBlock(x, y, z, NyxBlocks.exousicWater, w.getBlockMetadata(x, y, z) / 2, 3);
            converted = true;
        } else if (bl.getMaterial() == Material.snow || bl.getMaterial() == Material.craftedSnow) {
            w.setBlockToAir(x, y, z);
            w.setBlock(x, y, z, NyxBlocks.exousicWater, 8, 3);
            converted = true;
        }
        if (converted) {
            is.stackSize -= 1;
            if (is.getItemDamage() >= 2) {
                IaSPlayerHelper.giveItem(p, new ItemStack(NyxItems.exousium, 3, 1));
            }
        }
        return converted;
    } else if (is.getItemDamage() >= 2 && w.getBlock(x, y, z) instanceof NyxBlockStone) {
        w.setBlock(x, y, z, NyxBlocks.oreExousium, 1, 0);
        is.stackSize -= 1;
        return true;
    }
    return super.onItemUse(is, p, w, x, y, z, dmg, a, b, c);
}
项目:BetterNutritionMod    文件:World.java   
/**
 * Performs check to see if the block is a normal, solid block, or if the metadata of the block indicates that its
 * facing puts its solid side upwards. (inverted stairs, for example)
 */
@Deprecated //DO NOT USE THIS!!! USE doesBlockHaveSolidTopSurface
public boolean isBlockTopFacingSurfaceSolid(Block par1Block, int par2)
{
    // -.-  Mojang PLEASE make this location sensitive, you have no reason not to.
    return par1Block == null ? false : (par1Block.blockMaterial.isOpaque() && par1Block.renderAsNormalBlock() ? true : (par1Block instanceof BlockStairs ? (par2 & 4) == 4 : (par1Block instanceof BlockHalfSlab ? (par2 & 8) == 8 : (par1Block instanceof BlockHopper ? true : (par1Block instanceof BlockSnow ? (par2 & 7) == 7 : false)))));
}
项目:DecompiledMinecraft    文件:World.java   
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos)
{
    IBlockState iblockstate = blockAccess.getBlockState(pos);
    Block block = iblockstate.getBlock();
    return block.getMaterial().isOpaque() && block.isFullCube() ? true : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab ? iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() == 7 : false))));
}
项目:DecompiledMinecraft    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(side);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);

                if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
                {
                    worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                    return true;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
    }
}
项目:DecompiledMinecraft    文件:ItemReed.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.snow_layer && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else if (stack.stackSize == 0)
    {
        return false;
    }
    else
    {
        if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
        {
            IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);

            if (worldIn.setBlockState(pos, iblockstate1, 3))
            {
                iblockstate1 = worldIn.getBlockState(pos);

                if (iblockstate1.getBlock() == this.block)
                {
                    ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                    iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
                }

                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                return true;
            }
        }

        return false;
    }
}
项目:DecompiledMinecraft    文件:World.java   
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos)
{
    IBlockState iblockstate = blockAccess.getBlockState(pos);
    Block block = iblockstate.getBlock();
    return block.getMaterial().isOpaque() && block.isFullCube() ? true : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab ? iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() == 7 : false))));
}
项目:DecompiledMinecraft    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(side);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);

                if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
                {
                    worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                    return true;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
    }
}
项目:DecompiledMinecraft    文件:ItemReed.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.snow_layer && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else if (stack.stackSize == 0)
    {
        return false;
    }
    else
    {
        if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
        {
            IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);

            if (worldIn.setBlockState(pos, iblockstate1, 3))
            {
                iblockstate1 = worldIn.getBlockState(pos);

                if (iblockstate1.getBlock() == this.block)
                {
                    ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                    iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
                }

                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                return true;
            }
        }

        return false;
    }
}
项目:BaseClient    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_0_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_0_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:BaseClient    文件:World.java   
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos)
{
    IBlockState iblockstate = blockAccess.getBlockState(pos);
    Block block = iblockstate.getBlock();
    return block.getMaterial().isOpaque() && block.isFullCube() ? true : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab ? iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() == 7 : false))));
}
项目:BaseClient    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(side);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);

                if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
                {
                    worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                    return true;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
    }
}
项目:BaseClient    文件:ItemReed.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.snow_layer && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else if (stack.stackSize == 0)
    {
        return false;
    }
    else
    {
        if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
        {
            IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);

            if (worldIn.setBlockState(pos, iblockstate1, 3))
            {
                iblockstate1 = worldIn.getBlockState(pos);

                if (iblockstate1.getBlock() == this.block)
                {
                    ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                    iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
                }

                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                return true;
            }
        }

        return false;
    }
}
项目:BaseClient    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_0_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_0_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:BaseClient    文件:World.java   
public static boolean doesBlockHaveSolidTopSurface(IBlockAccess blockAccess, BlockPos pos)
{
    IBlockState iblockstate = blockAccess.getBlockState(pos);
    Block block = iblockstate.getBlock();
    return block.getMaterial().isOpaque() && block.isFullCube() ? true : (block instanceof BlockStairs ? iblockstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab ? iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() == 7 : false))));
}
项目:BaseClient    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize == 0)
    {
        return false;
    }
    else if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(side);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);

                if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
                {
                    worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                    return true;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
    }
}
项目:BaseClient    文件:ItemReed.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.snow_layer && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    if (!playerIn.canPlayerEdit(pos, side, stack))
    {
        return false;
    }
    else if (stack.stackSize == 0)
    {
        return false;
    }
    else
    {
        if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
        {
            IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);

            if (worldIn.setBlockState(pos, iblockstate1, 3))
            {
                iblockstate1 = worldIn.getBlockState(pos);

                if (iblockstate1.getBlock() == this.block)
                {
                    ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                    iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
                }

                worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
                --stack.stackSize;
                return true;
            }
        }

        return false;
    }
}
项目:customstuff4    文件:ItemSnow.java   
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack))
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(facing);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = iblockstate.getValue(BlockSnow.LAYERS);

            if (i < 8)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1);
                AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);

                if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
                {
                    SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player);
                    worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);

                    if (player instanceof EntityPlayerMP)
                    {
                        CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack);
                    }

                    itemstack.shrink(1);
                    return EnumActionResult.SUCCESS;
                }
            }
        }

        return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Backmemed    文件:ItemBlockSpecial.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);
    Block block = iblockstate.getBlock();

    if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        hand = EnumFacing.UP;
    }
    else if (!block.isReplaceable(playerIn, worldIn))
    {
        worldIn = worldIn.offset(hand);
    }

    ItemStack itemstack = stack.getHeldItem(pos);

    if (!itemstack.func_190926_b() && stack.canPlayerEdit(worldIn, hand, itemstack) && playerIn.func_190527_a(this.block, worldIn, false, hand, (Entity)null))
    {
        IBlockState iblockstate1 = this.block.onBlockPlaced(playerIn, worldIn, hand, facing, hitX, hitY, 0, stack);

        if (!playerIn.setBlockState(worldIn, iblockstate1, 11))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            iblockstate1 = playerIn.getBlockState(worldIn);

            if (iblockstate1.getBlock() == this.block)
            {
                ItemBlock.setTileEntityNBT(playerIn, stack, worldIn, itemstack);
                iblockstate1.getBlock().onBlockPlacedBy(playerIn, worldIn, iblockstate1, stack, itemstack);
            }

            SoundType soundtype = this.block.getSoundType();
            playerIn.playSound(stack, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.func_190918_g(1);
            return EnumActionResult.SUCCESS;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Backmemed    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    ItemStack itemstack = stack.getHeldItem(pos);

    if (!itemstack.func_190926_b() && stack.canPlayerEdit(worldIn, hand, itemstack))
    {
        IBlockState iblockstate = playerIn.getBlockState(worldIn);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = worldIn;

        if ((hand != EnumFacing.UP || block != this.block) && !block.isReplaceable(playerIn, worldIn))
        {
            blockpos = worldIn.offset(hand);
            iblockstate = playerIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i < 8)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(playerIn, blockpos);

                if (axisalignedbb != Block.NULL_AABB && playerIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && playerIn.setBlockState(blockpos, iblockstate1, 10))
                {
                    SoundType soundtype = this.block.getSoundType();
                    playerIn.playSound(stack, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                    itemstack.func_190918_g(1);
                    return EnumActionResult.SUCCESS;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY);
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:Backmemed    文件:BetterSnow.java   
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_)
{
    if (p_checkBlock_1_.isFullCube())
    {
        return false;
    }
    else if (p_checkBlock_1_.isOpaqueCube())
    {
        return false;
    }
    else if (p_checkBlock_0_ instanceof BlockSnow)
    {
        return false;
    }
    else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass))
    {
        if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall))
        {
            if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP)
            {
                return true;
            }
            else
            {
                if (p_checkBlock_0_ instanceof BlockLever)
                {
                    Object object = p_checkBlock_1_.getValue(BlockLever.FACING);

                    if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z)
                    {
                        return true;
                    }
                }

                return false;
            }
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:CustomWorldGen    文件:ItemBlockSpecial.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();

    if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
    {
        facing = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(facing);
    }

    if (playerIn.canPlayerEdit(pos, facing, stack) && stack.stackSize != 0 && worldIn.canBlockBePlaced(this.block, pos, false, facing, (Entity)null, stack))
    {
        IBlockState iblockstate1 = this.block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, playerIn, stack);

        if (!worldIn.setBlockState(pos, iblockstate1, 11))
        {
            return EnumActionResult.FAIL;
        }
        else
        {
            iblockstate1 = worldIn.getBlockState(pos);

            if (iblockstate1.getBlock() == this.block)
            {
                ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
                iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
            }

            SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, playerIn);
            worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:CustomWorldGen    文件:ItemSnow.java   
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (stack.stackSize != 0 && playerIn.canPlayerEdit(pos, facing, stack))
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();
        BlockPos blockpos = pos;

        if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
        {
            blockpos = pos.offset(facing);
            iblockstate = worldIn.getBlockState(blockpos);
            block = iblockstate.getBlock();
        }

        if (block == this.block)
        {
            int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();

            if (i <= 7)
            {
                IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
                AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos);

                if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10))
                {
                    SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, blockpos, playerIn);
                    worldIn.playSound(playerIn, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                    --stack.stackSize;
                    return EnumActionResult.SUCCESS;
                }
            }
        }

        return super.onItemUse(stack, playerIn, worldIn, blockpos, hand, facing, hitX, hitY, hitZ);
    }
    else
    {
        return EnumActionResult.FAIL;
    }
}
项目:CustomWorldGen    文件:ItemSnow.java   
public boolean canPlaceBlockOnSide(World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    IBlockState state = world.getBlockState(pos);
    return (state.getBlock() != net.minecraft.init.Blocks.SNOW_LAYER || ((Integer)state.getValue(BlockSnow.LAYERS)) > 7) ? super.canPlaceBlockOnSide(world, pos, side, player, stack) : true;
}
项目:ExtraUtilities    文件:ActivationRitual.java   
public static void startRitual(final World world, final int x, final int y, final int z, final EntityPlayer player) {
    world.addWeatherEffect((Entity)new EntityLightningBolt(world, (double)x, (double)y, (double)z));
    if (ExtraUtils.cursedEarth != null) {
        BlockCursedEarth.powered = 16;
        for (int dx = -ActivationRitual.max_range; dx <= ActivationRitual.max_range; ++dx) {
            for (int dz = -ActivationRitual.max_range; dz <= ActivationRitual.max_range; ++dz) {
                if (dx * dx + dz * dz < ActivationRitual.max_range * ActivationRitual.max_range) {
                    for (int dy = ActivationRitual.max_range; dy > -ActivationRitual.max_range; --dy) {
                        if (dx * dx + dy * dy + dz * dz <= ActivationRitual.max_range * ActivationRitual.max_range) {
                            final Block id = world.getBlock(x + dx, y + dy, z + dz);
                            if (id != Blocks.air) {
                                if (id == Blocks.dirt || id == Blocks.grass) {
                                    world.setBlock(x + dx, y + dy, z + dz, ExtraUtils.cursedEarth, 0, 3);
                                    break;
                                }
                                if (id instanceof BlockLeaves) {
                                    id.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
                                    world.setBlock(x + dx, y + dy, z + dz, Blocks.air);
                                }
                                else if (id instanceof BlockSnow) {
                                    world.setBlock(x + dx, y + dy, z + dz, Blocks.air);
                                }
                                else if (id.getMobilityFlag() == 1 && id != Blocks.redstone_wire) {
                                    world.func_147480_a(x + dx, y + dy, z + dz, true);
                                }
                                else if (id.isOpaqueCube()) {
                                    break;
                                }
                            }
                        }
                        else if (dy < 0) {
                            break;
                        }
                    }
                }
                else if (dz > 0) {
                    break;
                }
            }
        }
        BlockCursedEarth.powered = 0;
    }
}