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

The following examples show how to use net.minecraft.world.World#isSideSolid() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Translocators   File: BlockCraftingGrid.java    License: MIT License 6 votes vote down vote up
public boolean placeBlock(World world, EntityPlayer player, int x, int y, int z, int side) {
    if(disableCraftingGridKey)
        return false;

    Block block = world.getBlock(x, y, z);
    if(side != 1 && block != Blocks.snow_layer)
        return false;

    if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush
            && !block.isReplaceable(world, x, y, z))
        y++;

    if (!world.isSideSolid(x, y-1, z, ForgeDirection.UP))
        return false;

    if (!world.canPlaceEntityOnSide(this, x, y, z, false, 1, null, null))
        return false;

    player.swingItem();
    if(!world.setBlock(x, y, z, this))
        return false;

    onBlockPlacedBy(world, x, y, z, player, null);
    return true;
}
 
Example 2
Source Project: NEI-Integration   File: TrackInstanceBase.java    License: MIT License 5 votes vote down vote up
protected boolean isRailValid(World world, int x, int y, int z, int meta) {
    boolean valid = true;
    if (!world.isSideSolid(x, y - 1, z, ForgeDirection.UP))
        valid = false;
    if (meta == 2 && !world.isSideSolid(x + 1, y, z, ForgeDirection.UP))
        valid = false;
    else if (meta == 3 && !world.isSideSolid(x - 1, y, z, ForgeDirection.UP))
        valid = false;
    else if (meta == 4 && !world.isSideSolid(x, y, z - 1, ForgeDirection.UP))
        valid = false;
    else if (meta == 5 && !world.isSideSolid(x, y, z + 1, ForgeDirection.UP))
        valid = false;
    return valid;
}
 
Example 3
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) {
	if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
		player.openGui(Chisel.instance, 2, world, x, y, z);
		return true;
	}
	return false;
}
 
Example 4
Source Project: Translocators   File: BlockCraftingGrid.java    License: MIT License 5 votes vote down vote up
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    BlockCoord beneath = new BlockCoord(x, y, z).offset(0);
    if (!world.isSideSolid(beneath.x, beneath.y, beneath.z, ForgeDirection.UP)) {
        dropBlockAsItem(world, x, y, z, 0, 0);
        world.setBlockToAir(x, y, z);
    }
}
 
Example 5
Source Project: WirelessRedstone   File: ItemWirelessPart.java    License: MIT License 5 votes vote down vote up
@Override
public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vhit) {
    BlockCoord onPos = pos.copy().offset(side ^ 1);
    if (!world.isSideSolid(onPos.x, onPos.y, onPos.z, ForgeDirection.getOrientation(side)))
        return null;

    WirelessPart part = getPart(item.getItemDamage());
    part.setupPlacement(player, side);
    return part;
}
 
Example 6
Source Project: Artifacts   File: BlockWallPlate.java    License: MIT License 5 votes vote down vote up
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
{
	int newMeta = meta;

	if ((newMeta == 0 || side == 2) && world.isSideSolid(x, y, z + 1, NORTH))
	{
		newMeta = 2;
	}

	if ((newMeta == 0 || side == 3) && world.isSideSolid(x, y, z - 1, SOUTH))
	{
		newMeta = 3;
	}

	if ((newMeta == 0 || side == 4) && world.isSideSolid(x + 1, y, z, WEST))
	{
		newMeta = 4;
	}

	if ((newMeta == 0 || side == 5) && world.isSideSolid(x - 1, y, z, EAST))
	{
		newMeta = 5;
	}

	return newMeta;
}
 
Example 7
Source Project: Artifacts   File: BlockWallPlate.java    License: MIT License 5 votes vote down vote up
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
	int meta = world.getBlockMetadata(x, y, z) & 0x07;
	boolean flag = false;

	if (meta == 2 && world.isSideSolid(x, y, z+1, NORTH))
	{
		flag = true;
	}

	if (meta == 3 && world.isSideSolid(x, y, z-1, SOUTH))
	{
		flag = true;
	}

	if (meta == 4 && world.isSideSolid(x+1, y, z, WEST))
	{
		flag = true;
	}

	if (meta == 5 && world.isSideSolid(x-1, y, z, EAST))
	{
		flag = true;
	}

	if (!flag)
	{
		//System.out.println("Wall plate is invalid! Side is :" + meta);
		this.dropBlockAsItem(world, x, y, z, meta, 0);
		world.setBlockToAir(x, y, z);
	}

	//super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
}
 
Example 8
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
	return worldIn.isSideSolid(pos.down(), EnumFacing.UP);
}
 
Example 9
Source Project: TFC2   File: BlockGravity.java    License: GNU General Public License v3.0 4 votes vote down vote up
protected BlockPos slideScan(World world, BlockPos pos)
{
	if(pos.getY() == 0)
		return null;
	if(world.rand.nextFloat() < 1 - getSlideChance())
		return null;

	if(!world.isAirBlock(pos.up()) || !world.getBlockState(pos.up()).getBlock().isReplaceable(world, pos.up()))
		return null;

	if(getSlideHeight() == -1)
		return null;
	else
	{
		RandomCollection<BlockPos> pot = new RandomCollection<BlockPos>();
		int slideheightE = getSlideHeight();
		int slideheightW = getSlideHeight();
		int slideheightN = getSlideHeight();
		int slideheightS = getSlideHeight();

		boolean underWater = Core.isWater(world.getBlockState(pos.up()));

		if(Core.isWater(world.getBlockState(pos.east()))) slideheightE = slideheightE * (underWater ? 3 : 2);
		if(Core.isWater(world.getBlockState(pos.west()))) slideheightW  = slideheightW * (underWater ? 3 : 2);
		if(Core.isWater(world.getBlockState(pos.north()))) slideheightN = slideheightN * (underWater ? 3 : 2);
		if(Core.isWater(world.getBlockState(pos.south()))) slideheightS = slideheightS * (underWater ? 3 : 2);


		if(!world.isSideSolid(pos.east(), EnumFacing.WEST) && depthScan(world, pos.east()) >= slideheightE)
			pot.add(1.0, pos.east());
		if(!world.isSideSolid(pos.west(), EnumFacing.EAST) && depthScan(world, pos.west()) >= slideheightW)
			pot.add(1.0, pos.west());
		if(!world.isSideSolid(pos.north(), EnumFacing.SOUTH) && depthScan(world, pos.north()) >= slideheightN)
			pot.add(1.0, pos.north());
		if(!world.isSideSolid(pos.south(), EnumFacing.NORTH) && depthScan(world, pos.south()) >= slideheightS)
			pot.add(1.0, pos.south());

		if(pot.size() > 0)
			return pot.next();
	}

	return null;
}
 
Example 10
Source Project: Artifacts   File: BlockSpikes.java    License: MIT License 4 votes vote down vote up
@Override
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
   {
	return par1World.isSideSolid(par2, par3-1, par4, ForgeDirection.UP);
   }