Search in sources :

Example 1 with StoneType

use of gregtech.api.unification.ore.StoneType in project GregTech by GregTechCE.

the class GTWorldGen method generateOreBlock.

public static void generateOreBlock(World world, BlockPos pos, DustMaterial material, boolean small, boolean force) {
    IBlockState target = world.getBlockState(pos);
    if (target.getBlock() == Blocks.AIR && !force)
        return;
    StoneType stoneType = StoneType.computeStoneType(target);
    if (stoneType == StoneTypes._NULL) {
        if (force)
            stoneType = StoneTypes.STONE;
        else
            return;
    }
    getOreBlock(material, stoneType, small).ifPresent(ore -> world.setBlockState(pos, ore, 18));
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) StoneType(gregtech.api.unification.ore.StoneType)

Example 2 with StoneType

use of gregtech.api.unification.ore.StoneType in project GregTech by GregTechCE.

the class MetaBlocks method init.

public static void init() {
    MACHINE = new BlockMachine();
    MACHINE.setRegistryName("machine");
    CABLE = new BlockCable(64, 2, 0);
    CABLE.setRegistryName("cable");
    BOILER_CASING = new BlockBoilerCasing();
    BOILER_CASING.setRegistryName("boiler_casing");
    METAL_CASING = new BlockMetalCasing();
    METAL_CASING.setRegistryName("metal_casing");
    TURBINE_CASING = new BlockTurbineCasing();
    TURBINE_CASING.setRegistryName("turbine_casing");
    MACHINE_CASING = new BlockMachineCasing();
    MACHINE_CASING.setRegistryName("machine_casing");
    MUTLIBLOCK_CASING = new BlockMultiblockCasing();
    MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
    WIRE_COIL = new BlockWireCoil();
    WIRE_COIL.setRegistryName("wire_coil");
    WARNING_SIGN = new BlockWarningSign();
    WARNING_SIGN.setRegistryName("warning_sign");
    GRANITE = new BlockGranite();
    GRANITE.setRegistryName("granite");
    BLACK_GRANITE = new StoneType(12, "black_granite", OrePrefix.oreBlackgranite, Materials.GraniteBlack, "gregtech:blocks/stones/granite/granite_black_stone", () -> GRANITE.withVariant(GraniteVariant.BLACK_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.BLACK_GRANITE);
    RED_GRANITE = new StoneType(13, "red_granite", OrePrefix.oreRedgranite, Materials.GraniteRed, "gregtech:blocks/stones/granite/granite_red_stone", () -> GRANITE.withVariant(GraniteVariant.RED_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.RED_GRANITE);
    MINERAL = new BlockMineral();
    MINERAL.setRegistryName("mineral");
    MARBLE = new StoneType(14, "marble", OrePrefix.oreMarble, Materials.Marble, "gregtech:blocks/stones/marble/marble_stone", () -> MINERAL.withVariant(MineralVariant.MARBLE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.MARBLE);
    BASALT = new StoneType(15, "basalt", OrePrefix.oreBasalt, Materials.Basalt, "gregtech:blocks/stones/basalt/basalt_stone", () -> MINERAL.withVariant(MineralVariant.BASALT, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.BASALT);
    CONCRETE = new BlockConcrete();
    CONCRETE.setRegistryName("concrete");
    COMPRESSED = new HashMap<>();
    ORES = new ArrayList<>();
    StoneType.init();
    Material[] materialBuffer = new Material[16];
    Arrays.fill(materialBuffer, Materials._NULL);
    int generationIndex = 0;
    for (Material material : Material.MATERIAL_REGISTRY.getObjectsWithIds()) {
        if (material instanceof DustMaterial) {
            int id = Material.MATERIAL_REGISTRY.getIDForObject(material);
            int index = id / 16;
            if (index > generationIndex) {
                createCompressedBlock(materialBuffer, generationIndex);
                Arrays.fill(materialBuffer, Materials._NULL);
            }
            if (!OrePrefix.block.isIgnored(material)) {
                materialBuffer[id % 16] = material;
                generationIndex = index;
            }
            if (material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
                createOreBlock((DustMaterial) material);
            }
        }
    }
    createCompressedBlock(materialBuffer, generationIndex);
}
Also used : java.util(java.util) GraniteVariant(gregtech.common.blocks.BlockGranite.GraniteVariant) Item(net.minecraft.item.Item) MetaTileEntities(gregtech.common.metatileentities.MetaTileEntities) MetaTileEntityRenderer(gregtech.api.render.MetaTileEntityRenderer) Materials(gregtech.api.unification.material.Materials) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) StoneTypes(gregtech.api.unification.ore.StoneTypes) IProperty(net.minecraft.block.properties.IProperty) GregTechAPI(gregtech.api.GregTechAPI) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ChiselingVariant(gregtech.common.blocks.StoneBlock.ChiselingVariant) OrePrefix(gregtech.api.unification.ore.OrePrefix) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) ClientProxy(gregtech.common.ClientProxy) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) IBlockState(net.minecraft.block.state.IBlockState) DustMaterial(gregtech.api.unification.material.type.DustMaterial) MineralVariant(gregtech.common.blocks.BlockMineral.MineralVariant) BlockMachine(gregtech.api.block.machines.BlockMachine) BlockMachine(gregtech.api.block.machines.BlockMachine) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) DustMaterial(gregtech.api.unification.material.type.DustMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial)

Example 3 with StoneType

use of gregtech.api.unification.ore.StoneType in project GregTech by GregTechCE.

the class OreItemBlock method getItemStackDisplayName.

@Override
@SideOnly(Side.CLIENT)
public String getItemStackDisplayName(ItemStack stack) {
    IBlockState blockState = getBlockState(stack);
    boolean small = blockState.getValue(BlockOre.SMALL);
    if (small) {
        return OrePrefix.oreSmall.getLocalNameForItem(block.material);
    } else {
        StoneType stoneType = blockState.getValue(block.STONE_TYPE);
        return stoneType.processingPrefix.getLocalNameForItem(block.material);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) StoneType(gregtech.api.unification.ore.StoneType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with StoneType

use of gregtech.api.unification.ore.StoneType in project GregTech by GregTechCE.

the class GTWorldGenStone method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, Biome biome, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!this.isGenerationAllowed(world, biome) || this.probability <= 0)
        return;
    for (int i = 0; i < this.amount; i++) {
        if (random.nextInt(this.probability) == 0) {
            this.generate(random, chunkX, chunkZ, world, true, pos -> this.air || !world.isAirBlock(pos), (pos, r, rnd) -> {
                IBlockState blockState = world.getBlockState(pos);
                Block block = blockState.getBlock();
                if (this.stoneType != StoneTypes._NULL && block instanceof BlockOre) {
                    if (blockState.getValue(((BlockOre) block).STONE_TYPE) != this.stoneType) {
                        getOreBlock(((BlockOre) block).material, this.stoneType, blockState.getValue((BlockOre.SMALL))).ifPresent(ore -> world.setBlockState(pos, ore, 18));
                    }
                    return;
                }
                StoneType stoneType;
                if ((this.air && blockState.getBlock().isAir(blockState, world, pos)) || ((stoneType = StoneType.computeStoneType(blockState)) != StoneTypes._NULL && stoneType.harvestTool.equals("pickaxe"))) {
                    world.setBlockState(pos, this.stone);
                }
            });
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) StoneType(gregtech.api.unification.ore.StoneType) BlockOre(gregtech.common.blocks.BlockOre) Block(net.minecraft.block.Block)

Example 5 with StoneType

use of gregtech.api.unification.ore.StoneType in project GregTech by GregTechCE.

the class BlockOre method getHarvestLevel.

@Override
public int getHarvestLevel(IBlockState state) {
    StoneType stoneType = state.getValue(STONE_TYPE);
    boolean small = state.getValue(SMALL);
    if (material instanceof SolidMaterial) {
        int toolQuality = ((SolidMaterial) material).harvestLevel;
        return Math.max(stoneType.stoneMaterial.harvestLevel, toolQuality > 1 ? toolQuality - 1 : toolQuality);
    }
    return 1;
}
Also used : StoneType(gregtech.api.unification.ore.StoneType) PropertyStoneType(gregtech.common.blocks.properties.PropertyStoneType) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial)

Aggregations

StoneType (gregtech.api.unification.ore.StoneType)7 IBlockState (net.minecraft.block.state.IBlockState)5 Block (net.minecraft.block.Block)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Streams (com.google.common.collect.Streams)2 GregTechAPI (gregtech.api.GregTechAPI)2 BlockMachine (gregtech.api.block.machines.BlockMachine)2 MetaTileEntityRenderer (gregtech.api.render.MetaTileEntityRenderer)2 Materials (gregtech.api.unification.material.Materials)2 DustMaterial (gregtech.api.unification.material.type.DustMaterial)2 Material (gregtech.api.unification.material.type.Material)2 OrePrefix (gregtech.api.unification.ore.OrePrefix)2 StoneTypes (gregtech.api.unification.ore.StoneTypes)2 ClientProxy (gregtech.common.ClientProxy)2 GraniteVariant (gregtech.common.blocks.BlockGranite.GraniteVariant)2 MineralVariant (gregtech.common.blocks.BlockMineral.MineralVariant)2 ChiselingVariant (gregtech.common.blocks.StoneBlock.ChiselingVariant)2 MetaTileEntities (gregtech.common.metatileentities.MetaTileEntities)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2