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));
}
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);
}
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);
}
}
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);
}
});
}
}
}
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;
}
Aggregations