Java Code Examples for net.minecraft.world.World.isSideSolid()

The following are Jave code examples for showing how to use isSideSolid() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: harshencastle   File: BloodPlacer.java   Source Code and License Vote up 6 votes
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
	if(worldIn.isBlockPowered(pos) && worldIn.getBlockState(pos.offset(state.getValue(FACING))).getBlock().canPlaceBlockAt(worldIn, pos.offset(state.getValue(FACING)))
			&& !(worldIn.getBlockState(pos.offset(state.getValue(FACING))).getBlock() instanceof BloodBlock)
			&& !blocksOnMap.containsKey(pos) && worldIn.isSideSolid(pos.offset(state.getValue(FACING)).down(), EnumFacing.UP)
			&& worldIn.getBlockState(pos.up()).getBlock() instanceof BloodVessel 
			&& ((TileEntityBloodVessel)worldIn.getTileEntity(pos.up())).canRemove(1))
	{
		blocksOnMap.put(pos, true);
		((TileEntityBloodVessel)worldIn.getTileEntity(pos.up())).change(-1);
		HarshenNetwork.sendToAll(new MessagePacketTileEntityBloodPlacerUpdated(pos.up(), ((TileEntityBloodVessel)worldIn.getTileEntity(pos.up())).getPossibleRemove()));
		worldIn.setBlockState(pos.offset(state.getValue(FACING)), HarshenBlocks.BLOOD_BLOCK.getDefaultState(), 3);
	}
	else if(!worldIn.isBlockPowered(pos) && blocksOnMap.containsKey(pos))
		blocksOnMap.remove(pos);
}
 
Example 2
Project: Torched   File: ItemTorchFirework.java   Source Code and License Vote up 6 votes
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack is = player.getHeldItem(hand);
    if(is.getItemDamage() == 0)
    {
        if(side == EnumFacing.UP)
        {
            if(world.isSideSolid(pos, side, false))
            {
                is.shrink(1);
                if(!world.isRemote)
                {
                    world.spawnEntity(new EntityTorchFirework(world, pos.getX(), pos.getY(), pos.getZ(), player.capabilities.isCreativeMode && player.isSneaking()));
                }
                return EnumActionResult.SUCCESS;
            }
        }
    }
    return EnumActionResult.PASS;
}
 
Example 3
Project: CustomWorldGen   File: BlockTorch.java   Source Code and License Vote up 6 votes
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    if (this.canPlaceAt(worldIn, pos, facing))
    {
        return this.getDefaultState().withProperty(FACING, facing);
    }
    else
    {
        for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
        {
            if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true))
            {
                return this.getDefaultState().withProperty(FACING, enumfacing);
            }
        }

        return this.getDefaultState();
    }
}
 
Example 4
Project: ExPetrum   File: PebbleGenerator.java   Source Code and License Vote up 6 votes
@Override
public boolean generate(World worldIn, Random rand, BlockPos position)
{
	for (int i = 0; i < 16; ++i)
	{
		BlockPos offset = position.add(rand.nextInt(6) - rand.nextInt(6), 6, rand.nextInt(6) - rand.nextInt(6));
		while (!worldIn.isSideSolid(offset.down(), EnumFacing.UP, false) && offset.getY() > 0)
		{
			offset = offset.down();
		}
		
		if (worldIn.isAirBlock(offset) && !worldIn.getBlockState(offset.down()).getBlock().isAssociatedBlock(Blocks.SAND))
		{
			EnumRockClass erc = GenerationHelper.getStoneTypeAt(worldIn, offset);
			worldIn.setBlockState(offset, ExPBlocks.pebble.getDefaultState().withProperty(ExPBlockProperties.ROCK_CLASS, erc), 2);
		}
	}
	
	return true;
}
 
Example 5
Project: ExPetrum   File: BoulderGenerator.java   Source Code and License Vote up 6 votes
@Override
public boolean generate(World worldIn, Random rand, BlockPos position)
{
	for (int i = 0; i < 4; ++i)
	{
		BlockPos offset = position.add(rand.nextInt(8) - rand.nextInt(8), 4, rand.nextInt(8) - rand.nextInt(8));
		while (!worldIn.isSideSolid(offset.down(), EnumFacing.UP, false) && offset.getY() > 0)
		{
			offset = offset.down();
		}
		
		if (worldIn.isAirBlock(offset) && !worldIn.getBlockState(offset.down()).getBlock().isAssociatedBlock(Blocks.SAND))
		{
			EnumRockClass erc = GenerationHelper.getStoneTypeAt(worldIn, offset);
			worldIn.setBlockState(offset, ExPBlocks.boulder.getDefaultState().withProperty(ExPBlockProperties.ROCK_CLASS, erc), 2);
		}
	}
	
	return true;
}
 
Example 6
Project: WirelessRedstone   File: ItemWirelessPart.java   Source Code and License Vote up 5 votes
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockPos pos, int side, Vector3 vhit) {
    BlockPos onPos = pos.offset(EnumFacing.VALUES[side ^ 1]);
    if (!world.isSideSolid(onPos, EnumFacing.VALUES[side]))
        return null;

    WirelessPart part = getPart(item.getItemDamage());
    part.setupPlacement(player, side);
    return part;
}
 
Example 7
Project: GardenStuff   File: BlockCandelabra.java   Source Code and License Vote up 5 votes
private boolean canPlaceAt (World world, BlockPos pos, EnumFacing facing) {
    BlockPos blockPos = pos.offset(facing.getOpposite());
    if (facing.getAxis().isHorizontal())
        return world.isSideSolid(blockPos, facing, true);
    if (facing == EnumFacing.UP)
        return canPlaceOn(world, blockPos);
    if (facing == EnumFacing.DOWN)
        return true;

    return false;
}
 
Example 8
Project: CustomWorldGen   File: BlockTorch.java   Source Code and License Vote up 5 votes
protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state)
{
    if (!this.checkForDrop(worldIn, pos, state))
    {
        return true;
    }
    else
    {
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
        EnumFacing.Axis enumfacing$axis = enumfacing.getAxis();
        EnumFacing enumfacing1 = enumfacing.getOpposite();
        boolean flag = false;

        if (enumfacing$axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true))
        {
            flag = true;
        }
        else if (enumfacing$axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1)))
        {
            flag = true;
        }

        if (flag)
        {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
            return true;
        }
        else
        {
            return false;
        }
    }
}
 
Example 9
Project: EndermanEvolution   File: ItemSkullBase.java   Source Code and License Vote up 4 votes
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (facing == EnumFacing.DOWN) {
		return EnumActionResult.FAIL;
	}
	else {
		if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
			facing = EnumFacing.UP;
			pos = pos.down();
		}
		IBlockState iblockstate = worldIn.getBlockState(pos);
		Block block = iblockstate.getBlock();
		boolean flag = block.isReplaceable(worldIn, pos);
		if (!flag) {
			if (!worldIn.getBlockState(pos).getMaterial().isSolid() && !worldIn.isSideSolid(pos, facing, true)) {
				return EnumActionResult.FAIL;
			}

			pos = pos.offset(facing);
		}
		ItemStack stack = player.getHeldItem(hand);
		if (player.canPlayerEdit(pos, facing, stack) && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
			if (worldIn.isRemote || skullBlock == null) {
				return EnumActionResult.SUCCESS;
			}
			else {
				worldIn.setBlockState(pos, skullBlock.getDefaultState().withProperty(BlockSkull.FACING, facing), 11);
				int i = 0;

				if (facing == EnumFacing.UP) {
					i = MathUtils.floor(player.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
				}
				TileEntity tileentity = worldIn.getTileEntity(pos);
				if (tileentity instanceof TileBlockSkull) {
					TileBlockSkull tileentityskull = (TileBlockSkull) tileentity;
					tileentityskull.setSkullRotation(i);
				}
				stack.shrink(1);
				return EnumActionResult.SUCCESS;
			}
		}
		else {
			return EnumActionResult.FAIL;
		}
	}
}
 
Example 10
Project: BetterBeginningsReborn   File: BlockCampfire.java   Source Code and License Vote up 4 votes
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
    return world.getBlockState(pos).getBlock().isReplaceable(world, pos) &&
        world.isSideSolid(pos.offset(EnumFacing.DOWN), EnumFacing.UP);
}
 
Example 11
Project: CustomWorldGen   File: BlockLever.java   Source Code and License Vote up 4 votes
private boolean canAttach(World world, BlockPos pos, EnumFacing side)
{
    return world.isSideSolid(pos, side);
}
 
Example 12
Project: CustomWorldGen   File: BlockTorch.java   Source Code and License Vote up 4 votes
private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing)
{
    BlockPos blockpos = pos.offset(facing.getOpposite());
    boolean flag = facing.getAxis().isHorizontal();
    return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos);
}