Java Code Examples for net.minecraft.block.state.IBlockState#isOpaqueCube()

The following examples show how to use net.minecraft.block.state.IBlockState#isOpaqueCube() . 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: SurfaceRockPopulator.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
    int stonesCount = random.nextInt(2);
    if (world.getWorldType() != WorldType.FLAT && stonesCount > 0) {
        Set<Material> undergroundMaterials = findUndergroundMaterials(gridEntryInfo.getGeneratedBlocks(definition, chunkX, chunkZ));
        if (undergroundMaterials.isEmpty())
            return;

        for (int i = 0; i < stonesCount; i++) {
            int randomX = chunkX * 16 + random.nextInt(16);
            int randomZ = chunkZ * 16 + random.nextInt(16);
            BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
            topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
            IBlockState blockState = world.getBlockState(topBlockPos);
            if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
                !blockState.isOpaqueCube() || !blockState.isFullBlock())
                continue;
            BlockPos surfaceRockPos = topBlockPos.up();
            setStoneBlock(world, surfaceRockPos, undergroundMaterials);
        }
    }
}
 
Example 2
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
{
	if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
		return super.doesSideBlockRendering(state, world, pos, face);

	if ( state.isOpaqueCube() )
		return true;

	state = this.getActualState(state, world, pos);

	EnumHalf half = state.getValue(BlockStairs.HALF);
	EnumFacing side = state.getValue(BlockStairs.FACING);
	EnumShape shape = state.getValue(BlockStairs.SHAPE);
	if (face == EnumFacing.UP) return half == EnumHalf.TOP;
	if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM;
	if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false;
	if (face == side) return true;
	if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true;
	if (shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side) return true;
	return false;
}
 
Example 3
Source File: BlockWisdomWoodStairs.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
	if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
		return super.doesSideBlockRendering(state, world, pos, face);

	if (state.isOpaqueCube())
		return true;

	state = this.getActualState(state, world, pos);

	EnumHalf half = state.getValue(HALF);
	EnumFacing side = state.getValue(FACING);
	EnumShape shape = state.getValue(SHAPE);
	if (face == EnumFacing.UP) return half == EnumHalf.TOP;
	if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM;
	if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false;
	if (face == side) return true;
	if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true;
	return shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side;
}
 
Example 4
Source File: SurfaceBlockPopulator.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
    if (world.getWorldType() != WorldType.FLAT) {
        int stonesCount = minIndicatorAmount + (minIndicatorAmount >= maxIndicatorAmount ? 0 : random.nextInt(maxIndicatorAmount - minIndicatorAmount));
        for (int i = 0; i < stonesCount; i++) {
            int randomX = chunkX * 16 + random.nextInt(16);
            int randomZ = chunkZ * 16 + random.nextInt(16);
            BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
            topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
            IBlockState blockState = world.getBlockState(topBlockPos);
            if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
                !blockState.isOpaqueCube() || !blockState.isFullBlock())
                continue;
            BlockPos surfaceRockPos = topBlockPos.up();
            world.setBlockState(surfaceRockPos, this.blockState, 16);
        }
    }
}
 
Example 5
Source File: BlockTofuFarmLand.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
    switch (side)
    {
        case UP:
            return true;
        case NORTH:
        case SOUTH:
        case WEST:
        case EAST:
            IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
            Block block = iblockstate.getBlock();
            return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH;
        default:
            return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
    }
}
 
Example 6
Source File: BlockSlab.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
{
    if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
        return super.doesSideBlockRendering(state, world, pos, face);

    if (state.isOpaqueCube())
        return true;

    net.minecraft.block.BlockSlab.EnumBlockHalf side = state.getValue(HALF);
    return (side == net.minecraft.block.BlockSlab.EnumBlockHalf.TOP && face == EnumFacing.UP) || (side == net.minecraft.block.BlockSlab.EnumBlockHalf.BOTTOM && face == EnumFacing.DOWN);
}
 
Example 7
Source File: GraveyardGenerator.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {
	if (blockState == null || blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() == Blocks.LOG2
			|| blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 8
Source File: MonolithGenerator.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {

		if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
			return false;
		}

		return blockState.isOpaqueCube();
	}
 
Example 9
Source File: Visualization.java    From GriefPrevention with MIT License 5 votes vote down vote up
private static boolean isTransparent(BlockState blockstate, boolean waterIsTransparent) {
    if (blockstate.getType() == BlockTypes.SNOW_LAYER) {
        return false;
    }

    IBlockState iblockstate = (IBlockState)(Object) blockstate;
    Optional<MatterProperty> matterProperty = blockstate.getProperty(MatterProperty.class);
    if (!waterIsTransparent && matterProperty.isPresent() && matterProperty.get().getValue() == MatterProperty.Matter.LIQUID) {
        return false;
    }
    return !iblockstate.isOpaqueCube();
}
 
Example 10
Source File: BastionsLairEntranceGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 11
Source File: BastionsLairGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 12
Source File: TileEntityToroSpawner.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 13
Source File: QuestBase.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected static boolean isGroundBlock(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 14
Source File: QuestBase.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected static boolean cantBuildOver(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 15
Source File: CivilizationHandlers.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {
	if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() instanceof BlockBush) {
		return false;
	}
	return blockState.isOpaqueCube();
}
 
Example 16
Source File: BlockMap.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean onAirBlock() {
	IBlockState currentBlock = world.getBlockState(cursorCoords());
	return !currentBlock.isOpaqueCube();
}
 
Example 17
Source File: Canvas.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean onAirBlock() {
	IBlockState currentBlock = world.getBlockState(cursorCoords());
	return !currentBlock.isOpaqueCube();
}
 
Example 18
Source File: MageTowerGenerator.java    From ToroQuest with GNU General Public License v3.0 3 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {

		if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG || blockState.getBlock() instanceof BlockBush) {
			return false;
		}

		return blockState.isOpaqueCube();

	}
 
Example 19
Source File: EventHandlers.java    From ToroQuest with GNU General Public License v3.0 3 votes vote down vote up
private boolean isGroundBlock(IBlockState blockState) {

		if (blockState.getBlock() == Blocks.LEAVES || blockState.getBlock() == Blocks.LEAVES2 || blockState.getBlock() == Blocks.LOG
				|| blockState.getBlock() instanceof BlockBush) {
			return false;
		}

		return blockState.isOpaqueCube();

	}