Java Code Examples for net.minecraft.block.Block#isSideSolid()

The following examples show how to use net.minecraft.block.Block#isSideSolid() . 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 check out the related API usage on the sidebar.
Example 1
Source File: LanternRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderChain (IBlockAccess world, RenderBlocks renderer, BlockLantern block, int x, int y, int z) {
    Block lowerBlock = world.getBlock(x, y - 1, z);
    if (lowerBlock.isSideSolid(world, x, y - 1, z, ForgeDirection.UP))
        return;

    Block upperBlock = world.getBlock(x, y + 1, z);
    if (upperBlock instanceof IChainSingleAttachable) {
        Vec3 attach = ((IChainSingleAttachable) upperBlock).getChainAttachPoint(world, x, y + 1, z, 0);
        if (attach != null && attach != defaultAttachPoint) {
            RenderHelper.instance.setRenderBounds(0, 0, 0, 1, attach.yCoord, 1);
            RenderHelper.instance.renderCrossedSquares(world, ModBlocks.heavyChain, x, y + 1, z, ModBlocks.lightChain.getIcon(0, 4));
            return;
        }
    }

    IAttachable attachable = GardenAPI.instance().registries().attachable().getAttachable(upperBlock, world.getBlockMetadata(x, y + 1, z));
    if (attachable != null && attachable.isAttachable(world, x, y + 1, z, 0)) {
        double depth = attachable.getAttachDepth(world, x, y + 1, z, 0);
        if (depth > 0) {
            RenderHelper.instance.setRenderBounds(0, 0, 0, 1, depth, 1);
            RenderHelper.instance.renderCrossedSquares(world, ModBlocks.heavyChain, x, y + 1, z, ModBlocks.lightChain.getIcon(0, 4));
        }
    }
}
 
Example 2
Source File: BlockLattice.java    From GardenCollection with MIT License 6 votes vote down vote up
private boolean isNeighborHardConnection (IBlockAccess world, int x, int y, int z, Block block, ForgeDirection side) {
    if (block.getMaterial().isOpaque() && block.renderAsNormalBlock())
        return true;

    if (block.isSideSolid(world, x, y, z, side.getOpposite()))
        return true;

    if (block == this)
        return true;

    if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) {
        if (block instanceof BlockFence || block instanceof net.minecraft.block.BlockFence)
            return true;
    }

    return false;
}
 
Example 3
Source File: BlockThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean isNeighborHardConnection (IBlockAccess world, int x, int y, int z, Block block, ForgeDirection side) {
    if (block.getMaterial().isOpaque() && block.renderAsNormalBlock())
        return true;

    if (block.isSideSolid(world, x, y, z, side.getOpposite()))
        return true;

    //if (block == ModBlocks.largePot)
    //    return true;
    return false;
}
 
Example 4
Source File: BlockConnected.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean isNeighborHardConnection (IBlockAccess world, int x, int y, int z, Block block, ForgeDirection side) {
    if (block.getMaterial().isOpaque() && block.renderAsNormalBlock())
        return true;

    if (block.isSideSolid(world, x, y, z, side.getOpposite()))
        return true;

    if (block == this)
        return true;

    return false;
}
 
Example 5
Source File: MobileChunk.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean defaultvalue)
{
	if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000)
	{
		return defaultvalue;
	}
	
	Block block = getBlock(x, y, z);
	return block.isSideSolid(worldObj, x, y, z, side);
}
 
Example 6
Source File: TileEntityKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNeighborBlockUpdate(){
    super.onNeighborBlockUpdate();
    sideConnected = ForgeDirection.DOWN;
    for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        int x = xCoord + d.offsetX;
        int y = yCoord + d.offsetY;
        int z = zCoord + d.offsetZ;
        Block block = worldObj.getBlock(x, y, z);
        if(block.isSideSolid(worldObj, x, y, z, d.getOpposite())) {
            sideConnected = d;
            break;
        }
    }
}
 
Example 7
Source File: BlockIvy.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean canPlaceOnBlock (World world, int x, int y, int z, int side) {
    Block block = world.getBlock(x, y, z);
    return block.getMaterial().blocksMovement() && block.isSideSolid(world, x, y, z, ForgeDirection.getOrientation(side));
}
 
Example 8
Source File: CandelabraRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private void renderCandelabra (IBlockAccess world, int x, int y, int z, BlockCandelabra block, int level) {
    Block blockUpper = world.getBlock(x, y + 1, z);
    boolean hanging = level > 0 && (blockUpper instanceof IChain || blockUpper.isSideSolid(world, x, y + 1, z, ForgeDirection.DOWN));

    // Candelsticks
    RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1, 1);

    if (!hanging) {
        RenderHelper.instance.state.setRenderOffset(0, .0625f, 0);
        renderCandle(world, block, x, y, z);
    }

    if (level >= 1) {
        RenderHelper.instance.state.setRenderOffset(-.34375f, 0, 0);
        renderCandle(world, block, x, y, z);
        RenderHelper.instance.state.setRenderOffset(.34375f, 0, 0);
        renderCandle(world, block, x, y, z);
    }
    if (level >= 2) {
        RenderHelper.instance.state.setRenderOffset(0, 0, -.34375f);
        renderCandle(world, block, x, y, z);
        RenderHelper.instance.state.setRenderOffset(0, 0, .34375f);
        renderCandle(world, block, x, y, z);
    }

    // Hanger / Base
    RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1, 1);
    RenderHelper.instance.state.setRenderOffset(0, 0, 0);

    if (hanging)
        RenderHelper.instance.drawCrossedSquares(block.getIconHang(), x, y, z, 1);
    else
        RenderHelper.instance.drawCrossedSquares(block.getIconBase(), x, y, z, 1);

    // Arms
    if (level >= 1) {
        RenderHelper.instance.state.setRenderOffset(0, 0, 0);
        RenderHelper.instance.setRenderBounds(.5f, 0, .5f, 1, 1, 1);
        RenderHelper.instance.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(.5f, 0, 0);
        RenderHelper.instance.setRenderBounds(0, 0, 0, .5f, 1, .5f);
        RenderHelper.instance.renderFace(RenderHelper.ZPOS, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(0, 0, 0);
        RenderHelper.instance.setRenderBounds(0, 0, .5f, .5f, 1, 1);
        RenderHelper.instance.renderFace(RenderHelper.ZNEG, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(-.5f, 0, 0);
        RenderHelper.instance.setRenderBounds(.5f, 0, 0, 1, 1, .5f);
        RenderHelper.instance.renderFace(RenderHelper.ZPOS, world, block, x, y, z, block.getIconArmExt());

    }
    if (level >= 2) {
        RenderHelper.instance.state.setRenderOffset(0, 0, -.5f);
        RenderHelper.instance.setRenderBounds(.5f, 0, .5f, 1, 1, 1);
        RenderHelper.instance.renderFace(RenderHelper.XNEG, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(0, 0, 0);
        RenderHelper.instance.setRenderBounds(0, 0, 0, .5f, 1, .5f);
        RenderHelper.instance.renderFace(RenderHelper.XPOS, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(0, 0, .5f);
        RenderHelper.instance.setRenderBounds(.5f, 0, 0, 1, 1, .5f);
        RenderHelper.instance.renderFace(RenderHelper.XNEG, world, block, x, y, z, block.getIconArmExt());

        RenderHelper.instance.state.setRenderOffset(0, 0, 0);
        RenderHelper.instance.setRenderBounds(0, 0, .5f, .5f, 1, 1);
        RenderHelper.instance.renderFace(RenderHelper.XPOS, world, block, x, y, z, block.getIconArmExt());
    }

    RenderHelper.instance.state.clearRenderOffset();
}
 
Example 9
Source File: BlockCandelabra.java    From GardenCollection with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
    TileEntityCandelabra tile = getTileEntity(world, x, y, z);
    if (tile == null)
        return;

    double[] c = new double[3];
    int level = tile.getLevel();
    int dir = tile.getDirection();

    float flameDepth = 0.96875f;

    if (tile.isSconce()) {
        if (level == 0) {
            RenderHelper.instance.state.transformCoord(.5f, flameDepth, .25f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
        if (level == 1 || level == 2) {
            RenderHelper.instance.state.transformCoord(.25f, flameDepth, .25f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
            RenderHelper.instance.state.transformCoord(.75f, flameDepth, .25f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
        if (level == 2) {
            RenderHelper.instance.state.transformCoord(.5f, flameDepth, .375f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
    }
    else {
        Block blockUpper = world.getBlock(x, y + 1, z);
        boolean hanging = level > 0 && (blockUpper instanceof IChain || blockUpper.isSideSolid(world, x, y + 1, z, ForgeDirection.DOWN));

        if (level >= 0 && !hanging) {
            RenderHelper.instance.state.transformCoord(.5f, flameDepth + .0625f, .5f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
        if (level >= 1) {
            RenderHelper.instance.state.transformCoord(.15625f, flameDepth, .5f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
            RenderHelper.instance.state.transformCoord(.84375, flameDepth, .5f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
        if (level >= 2) {
            RenderHelper.instance.state.transformCoord(.5f, flameDepth, .15625f, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
            RenderHelper.instance.state.transformCoord(.5f, flameDepth, .84375, c, RenderHelperState.ROTATION_BY_FACE_FACE[2][dir]);
            renderParticleAt(world, x + c[0], y + c[1], z + c[2]);
        }
    }
}