use of gregtech.api.worldgen.populator.SurfaceRockPopulator in project GregTech by GregTechCE.
the class WorldGenRegistry method initializeRegistry.
public void initializeRegistry() {
GTLog.logger.info("Initializing ore generation registry...");
registerShapeGenerator("ellipsoid", EllipsoidGenerator::new);
registerShapeGenerator("sphere", SphereGenerator::new);
registerShapeGenerator("plate", PlateGenerator::new);
registerShapeGenerator("single", SingleBlockGenerator::new);
registerBlockFiller("simple", SimpleBlockFiller::new);
registerBlockFiller("ignore_bedrock", () -> new BlacklistedBlockFiller(Lists.newArrayList(Blocks.BEDROCK.getDefaultState())));
registerVeinPopulator("surface_rock", SurfaceRockPopulator::new);
registerVeinPopulator("fluid_spring", FluidSpringPopulator::new);
registerVeinPopulator("surface_block", SurfaceBlockPopulator::new);
WorldGeneratorImpl worldGenerator = new WorldGeneratorImpl();
GameRegistry.registerWorldGenerator(worldGenerator, 1);
MinecraftForge.ORE_GEN_BUS.register(worldGenerator);
try {
reinitializeRegisteredVeins();
} catch (IOException | RuntimeException exception) {
GTLog.logger.fatal("Failed to initialize worldgen registry.", exception);
}
}
use of gregtech.api.worldgen.populator.SurfaceRockPopulator in project GregTech by GregTechCE.
the class GTOreInfo method findSurfaceBlock.
// Finds the generated surface block or material. In the case of Fluid generation, finds a bucket of the fluid
public ItemStack findSurfaceBlock(IVeinPopulator veinPopulator) {
Material mat;
IBlockState state;
ItemStack stack = new ItemStack(Items.AIR);
FluidStack fStack;
// Legacy Surface rock Support
if (veinPopulator instanceof SurfaceRockPopulator) {
mat = ((SurfaceRockPopulator) veinPopulator).getMaterial();
// Create a Tiny Dust for the Identifier.
stack = OreDictUnifier.getDust(mat.createMaterialStack(M / 9));
return stack.isEmpty() ? new ItemStack(Items.AIR) : stack;
} else // Surface Block support
if (veinPopulator instanceof SurfaceBlockPopulator) {
state = ((SurfaceBlockPopulator) veinPopulator).getBlockState();
stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
return stack;
} else // Fluid generation support
if (veinPopulator instanceof FluidSpringPopulator) {
state = ((FluidSpringPopulator) veinPopulator).getFluidState();
Block temp = state.getBlock();
if (temp instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) temp).getFluid();
fStack = new FluidStack(fluid, 1000);
stack = FluidUtil.getFilledBucket(fStack);
return stack;
}
}
// No defined surface rock
return stack;
}
use of gregtech.api.worldgen.populator.SurfaceRockPopulator in project GregTech by GregTechCE.
the class OreDepositDefinition method initializeFromConfig.
public void initializeFromConfig(JsonObject configRoot) {
this.weight = configRoot.get("weight").getAsInt();
this.density = configRoot.get("density").getAsFloat();
if (configRoot.has("name")) {
this.assignedName = configRoot.get("name").getAsString();
}
if (configRoot.has("description")) {
this.description = configRoot.get("description").getAsString();
}
if (configRoot.has("priority")) {
this.priority = configRoot.get("priority").getAsInt();
}
if (configRoot.has("count_as_vein")) {
this.countAsVein = configRoot.get("count_as_vein").getAsBoolean();
}
if (configRoot.has("min_height")) {
this.heightLimit[0] = configRoot.get("min_height").getAsInt();
}
if (configRoot.has("max_height")) {
this.heightLimit[1] = configRoot.get("max_height").getAsInt();
}
if (configRoot.has("biome_modifier")) {
this.biomeWeightModifier = WorldConfigUtils.createBiomeWeightModifier(configRoot.get("biome_modifier"));
}
if (configRoot.has("dimension_filter")) {
this.dimensionFilter = WorldConfigUtils.createWorldPredicate(configRoot.get("dimension_filter"));
}
if (configRoot.has("generation_predicate")) {
this.generationPredicate = PredicateConfigUtils.createBlockStatePredicate(configRoot.get("generation_predicate"));
}
// legacy surface rock specifier support
if (configRoot.has("surface_stone_material")) {
DustMaterial surfaceStoneMaterial = OreConfigUtils.getMaterialByName(configRoot.get("surface_stone_material").getAsString());
if (!surfaceStoneMaterial.hasFlag(MatFlags.GENERATE_ORE)) {
throw new IllegalArgumentException("Material " + surfaceStoneMaterial + " doesn't have surface rock variant");
}
this.veinPopulator = new SurfaceRockPopulator(surfaceStoneMaterial);
}
if (configRoot.has("vein_populator")) {
JsonObject object = configRoot.get("vein_populator").getAsJsonObject();
this.veinPopulator = WorldGenRegistry.INSTANCE.createVeinPopulator(object);
}
this.blockFiller = WorldGenRegistry.INSTANCE.createBlockFiller(configRoot.get("filler").getAsJsonObject());
this.shapeGenerator = WorldGenRegistry.INSTANCE.createShapeGenerator(configRoot.get("generator").getAsJsonObject());
if (veinPopulator != null) {
veinPopulator.initializeForVein(this);
}
}
Aggregations