Java Code Examples for net.minecraft.init.Blocks.SNOW_LAYER

The following are Jave code examples for showing how to use SNOW_LAYER of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: ItemBlock.java   View Source Code Vote up 6 votes
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.SNOW_LAYER && block.isReplaceable(worldIn, pos))
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    return worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack);
}
 
Example 2
Project: Loot-Slash-Conquer   File: LSCWorldGenerator.java   View Source Code Vote up 5 votes
/**
 * Gets the Y-value of the ground at a specifix x/y coordinate.
 * @param world
 * @param x
 * @param z
 * @return
 */
public static int getGroundFromAbove(World world, int x, int z)
{
	int y = 255;
	boolean foundGround = false;
	while(!foundGround && y-- >= 63)
	{
		Block blockAt = world.getBlockState(new BlockPos(x,y,z)).getBlock();
		foundGround = blockAt == Blocks.DIRT || blockAt == Blocks.GRASS || blockAt == Blocks.SAND || blockAt == Blocks.SNOW || blockAt == Blocks.SNOW_LAYER || blockAt == Blocks.GLASS;
	}

	return y;
}
 
Example 3
Project: Bewitchment   File: FrostbiteBrew.java   View Source Code Vote up 5 votes
@Override
public 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.nextBoolean();
		if (place && state.getBlock() == Blocks.WATER && world.isAirBlock(spot.up())) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.ICE) {
			world.setBlockState(spot, Blocks.PACKED_ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.SNOW_LAYER) {
			world.setBlockState(spot, Blocks.SNOW.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.SNOW) {
			world.setBlockState(spot, Blocks.PACKED_ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FROSTED_ICE) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.LAVA) {
			world.setBlockState(spot, Blocks.OBSIDIAN.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FLOWING_LAVA) {
			world.setBlockState(spot, Blocks.OBSIDIAN.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.FLOWING_WATER) {
			world.setBlockState(spot, Blocks.ICE.getDefaultState(), 3);
		}
	}
}
 
Example 4
Project: chesttransporter   File: ItemChestTransporter.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: WinterWonderLand   File: WinterWonderLand.java   View Source Code Vote up 5 votes
private static BlockPos getSnowTopPosition(WorldServer world, BlockPos pos) {
	pos = world.getPrecipitationHeight(pos);
  		
  		// Precipitation height ignores snow blocks, need to loop to the top of the stack
  		while (world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER) {
  			pos = pos.up();
  		}
  		
  		return pos;
}
 
Example 6
Project: WinterWonderLand   File: WinterWonderLand.java   View Source Code Vote up 5 votes
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;
 	}
 
Example 7
Project: TheOink   File: OinkWorldGenerator.java   View Source Code Vote up 5 votes
private int getGroundFromAbove(World world, int x, int z)
{
    int y = 255;
    boolean foundGround = false;
    while(!foundGround && y-- >= 63)
    {
        Block blockAt = world.getBlockState(new BlockPos(x,y,z)).getBlock();
        foundGround = blockAt == Blocks.DIRT || blockAt == Blocks.GRASS || blockAt == Blocks.SAND || blockAt == Blocks.SNOW || blockAt == Blocks.SNOW_LAYER || blockAt == Blocks.STONE;
    }

    return y;
}
 
Example 8
Project: Backmemed   File: Entity.java   View Source Code Vote up 5 votes
protected void playStepSound(BlockPos pos, Block blockIn)
{
    SoundType soundtype = blockIn.getSoundType();

    if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
    {
        soundtype = Blocks.SNOW_LAYER.getSoundType();
        this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
    }
    else if (!blockIn.getDefaultState().getMaterial().isLiquid())
    {
        this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
    }
}
 
Example 9
Project: Backmemed   File: AbstractHorse.java   View Source Code Vote up 5 votes
protected void playStepSound(BlockPos pos, Block blockIn)
{
    if (!blockIn.getDefaultState().getMaterial().isLiquid())
    {
        SoundType soundtype = blockIn.getSoundType();

        if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
        {
            soundtype = Blocks.SNOW_LAYER.getSoundType();
        }

        if (this.isBeingRidden() && this.field_190688_bE)
        {
            ++this.gallopTime;

            if (this.gallopTime > 5 && this.gallopTime % 3 == 0)
            {
                this.func_190680_a(soundtype);
            }
            else if (this.gallopTime <= 5)
            {
                this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
            }
        }
        else if (soundtype == SoundType.WOOD)
        {
            this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
        }
        else
        {
            this.playSound(SoundEvents.ENTITY_HORSE_STEP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
        }
    }
}
 
Example 10
Project: Backmemed   File: ItemBlock.java   View Source Code Vote up 5 votes
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.SNOW_LAYER)
    {
        side = EnumFacing.UP;
    }
    else if (!block.isReplaceable(worldIn, pos))
    {
        pos = pos.offset(side);
    }

    return worldIn.func_190527_a(this.block, pos, false, side, (Entity)null);
}
 
Example 11
Project: FoodCraft-Reloaded   File: ItemFruitCake.java   View Source Code Vote up 5 votes
@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;
}
 
Example 12
Project: Backmemed   File: ConnectedTextures.java   View Source Code Vote up 5 votes
private static boolean isNeighbourOverlay(ConnectedProperties p_isNeighbourOverlay_0_, IBlockAccess p_isNeighbourOverlay_1_, IBlockState p_isNeighbourOverlay_2_, BlockPos p_isNeighbourOverlay_3_, int p_isNeighbourOverlay_4_, TextureAtlasSprite p_isNeighbourOverlay_5_, int p_isNeighbourOverlay_6_)
{
    IBlockState iblockstate = p_isNeighbourOverlay_1_.getBlockState(p_isNeighbourOverlay_3_);

    if (!isFullCubeModel(iblockstate))
    {
        return false;
    }
    else
    {
        if (p_isNeighbourOverlay_0_.connectBlocks != null)
        {
            BlockStateBase blockstatebase = (BlockStateBase)iblockstate;

            if (!Matches.block(blockstatebase.getBlockId(), blockstatebase.getMetadata(), p_isNeighbourOverlay_0_.connectBlocks))
            {
                return false;
            }
        }

        if (p_isNeighbourOverlay_0_.connectTileIcons != null)
        {
            TextureAtlasSprite textureatlassprite = getNeighbourIcon(p_isNeighbourOverlay_1_, p_isNeighbourOverlay_2_, p_isNeighbourOverlay_3_, iblockstate, p_isNeighbourOverlay_4_);

            if (!Config.isSameOne(textureatlassprite, p_isNeighbourOverlay_0_.connectTileIcons))
            {
                return false;
            }
        }

        IBlockState iblockstate1 = p_isNeighbourOverlay_1_.getBlockState(p_isNeighbourOverlay_3_.offset(getFacing(p_isNeighbourOverlay_4_)));
        return iblockstate1.isOpaqueCube() ? false : (p_isNeighbourOverlay_4_ == 1 && iblockstate1.getBlock() == Blocks.SNOW_LAYER ? false : !isNeighbour(p_isNeighbourOverlay_0_, p_isNeighbourOverlay_1_, p_isNeighbourOverlay_2_, p_isNeighbourOverlay_3_, iblockstate, p_isNeighbourOverlay_4_, p_isNeighbourOverlay_5_, p_isNeighbourOverlay_6_));
    }
}
 
Example 13
Project: Backmemed   File: ConnectedTextures.java   View Source Code Vote up 5 votes
private static boolean isNeighbourMatching(ConnectedProperties p_isNeighbourMatching_0_, IBlockAccess p_isNeighbourMatching_1_, IBlockState p_isNeighbourMatching_2_, BlockPos p_isNeighbourMatching_3_, int p_isNeighbourMatching_4_, TextureAtlasSprite p_isNeighbourMatching_5_, int p_isNeighbourMatching_6_)
{
    IBlockState iblockstate = p_isNeighbourMatching_1_.getBlockState(p_isNeighbourMatching_3_);

    if (iblockstate == AIR_DEFAULT_STATE)
    {
        return false;
    }
    else
    {
        if (p_isNeighbourMatching_0_.matchBlocks != null && iblockstate instanceof BlockStateBase)
        {
            BlockStateBase blockstatebase = (BlockStateBase)iblockstate;

            if (!p_isNeighbourMatching_0_.matchesBlock(blockstatebase.getBlockId(), blockstatebase.getMetadata()))
            {
                return false;
            }
        }

        if (p_isNeighbourMatching_0_.matchTileIcons != null)
        {
            TextureAtlasSprite textureatlassprite = getNeighbourIcon(p_isNeighbourMatching_1_, p_isNeighbourMatching_2_, p_isNeighbourMatching_3_, iblockstate, p_isNeighbourMatching_4_);

            if (textureatlassprite != p_isNeighbourMatching_5_)
            {
                return false;
            }
        }

        IBlockState iblockstate1 = p_isNeighbourMatching_1_.getBlockState(p_isNeighbourMatching_3_.offset(getFacing(p_isNeighbourMatching_4_)));
        return iblockstate1.isOpaqueCube() ? false : p_isNeighbourMatching_4_ != 1 || iblockstate1.getBlock() != Blocks.SNOW_LAYER;
    }
}
 
Example 14
Project: Adventurers-Toolbox   File: ItemATShovel.java   View Source Code Vote up 4 votes
@Override
public boolean canHarvestBlock(IBlockState blockIn) {
	Block block = blockIn.getBlock();
	return block == Blocks.SNOW_LAYER ? true : block == Blocks.SNOW;
}
 
Example 15
Project: Backmemed   File: MapGenCaves.java   View Source Code Vote up 4 votes
protected boolean canReplaceBlock(IBlockState p_175793_1_, IBlockState p_175793_2_)
{
    return p_175793_1_.getBlock() == Blocks.STONE ? true : (p_175793_1_.getBlock() == Blocks.DIRT ? true : (p_175793_1_.getBlock() == Blocks.GRASS ? true : (p_175793_1_.getBlock() == Blocks.HARDENED_CLAY ? true : (p_175793_1_.getBlock() == Blocks.STAINED_HARDENED_CLAY ? true : (p_175793_1_.getBlock() == Blocks.SANDSTONE ? true : (p_175793_1_.getBlock() == Blocks.RED_SANDSTONE ? true : (p_175793_1_.getBlock() == Blocks.MYCELIUM ? true : (p_175793_1_.getBlock() == Blocks.SNOW_LAYER ? true : (p_175793_1_.getBlock() == Blocks.SAND || p_175793_1_.getBlock() == Blocks.GRAVEL) && p_175793_2_.getMaterial() != Material.WATER))))))));
}
 
Example 16
Project: Backmemed   File: ItemSpade.java   View Source Code Vote up 4 votes
/**
 * Check whether this Item can harvest the given Block
 */
public boolean canHarvestBlock(IBlockState blockIn)
{
    Block block = blockIn.getBlock();
    return block == Blocks.SNOW_LAYER ? true : block == Blocks.SNOW;
}
 
Example 17
Project: CustomWorldGen   File: BlockFluidBase.java   View Source Code Vote up 4 votes
/**
 * Attempt to displace the block at (pos), return true if it was displaced.
 */
public boolean displaceIfPossible(World world, BlockPos pos)
{
    if (world.isAirBlock(pos))
    {
        return true;
    }

    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block == this)
    {
        return false;
    }

    if (displacements.containsKey(block))
    {
        if (displacements.get(block))
        {
            if (state.getBlock() != Blocks.SNOW_LAYER) //Forge: Vanilla has a 'bug' where snowballs don't drop like every other block. So special case because ewww...
                block.dropBlockAsItem(world, pos, state, 0);
            return true;
        }
        return false;
    }

    Material material = state.getMaterial();
    if (material.blocksMovement() || material == Material.PORTAL)
    {
        return false;
    }

    int density = getDensity(world, pos);
    if (density == Integer.MAX_VALUE)
    {
        block.dropBlockAsItem(world, pos, state, 0);
        return true;
    }

    if (this.density > density)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 18
Project: CustomWorldGen   File: ItemBlockSpecial.java   View Source Code Vote up 4 votes
/**
 * 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;
    }
}
 
Example 19
Project: CustomWorldGen   File: MapGenCaves.java   View Source Code Vote up 4 votes
protected boolean canReplaceBlock(IBlockState p_175793_1_, IBlockState p_175793_2_)
{
    return p_175793_1_.getBlock() == Blocks.STONE ? true : (p_175793_1_.getBlock() == Blocks.DIRT ? true : (p_175793_1_.getBlock() == Blocks.GRASS ? true : (p_175793_1_.getBlock() == Blocks.HARDENED_CLAY ? true : (p_175793_1_.getBlock() == Blocks.STAINED_HARDENED_CLAY ? true : (p_175793_1_.getBlock() == Blocks.SANDSTONE ? true : (p_175793_1_.getBlock() == Blocks.RED_SANDSTONE ? true : (p_175793_1_.getBlock() == Blocks.MYCELIUM ? true : (p_175793_1_.getBlock() == Blocks.SNOW_LAYER ? true : (p_175793_1_.getBlock() == Blocks.SAND || p_175793_1_.getBlock() == Blocks.GRAVEL) && p_175793_2_.getMaterial() != Material.WATER))))))));
}
 
Example 20
Project: ExPetrum   File: BlockSnow.java   View Source Code Vote up 4 votes
@Override
public boolean isAssociatedBlock(Block other)
{
	return super.isAssociatedBlock(other) || other == Blocks.SNOW_LAYER;
}