use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.
the class WorldGenRegistry method createVeinPopulator.
public IVeinPopulator createVeinPopulator(JsonObject object) {
String identifier = object.get("type").getAsString();
if (!veinPopulatorRegistry.containsKey(identifier))
throw new IllegalArgumentException("No vein populator found for type " + identifier);
IVeinPopulator veinPopulator = veinPopulatorRegistry.get(identifier).get();
veinPopulator.loadFromConfig(object);
return veinPopulator;
}
use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.
the class CachedGridEntry method doGenerateVein.
private void doGenerateVein(OreDepositDefinition definition) {
this.currentOreVein = definition;
int topHeightOffset = currentOreVein.getShapeGenerator().getMaxSize().getY() / 2 + 4;
int maximumHeight = Math.min(masterEntry.getMaxBottomHeight(), currentOreVein.getHeightLimit()[1] - topHeightOffset);
int minimumHeight = Math.max(3, currentOreVein.getHeightLimit()[0]);
if (minimumHeight >= maximumHeight) {
return;
}
this.veinCenterX = calculateVeinCenterX();
this.veinCenterY = minimumHeight + gridRandom.nextInt(maximumHeight - minimumHeight);
this.veinCenterZ = calculateVeinCenterZ();
this.currentOreVein.getShapeGenerator().generate(gridRandom, this);
this.veinGeneratedMap.put(definition, new BlockPos(veinCenterX, veinCenterY, veinCenterZ));
IVeinPopulator veinPopulator = currentOreVein.getVeinPopulator();
if (veinPopulator instanceof VeinBufferPopulator) {
((VeinBufferPopulator) veinPopulator).populateBlockBuffer(gridRandom, this, this, currentOreVein);
}
this.currentOreVein = null;
}
use of gregtech.api.worldgen.populator.IVeinPopulator in project GregTech by GregTechCE.
the class CachedGridEntry method populateChunk.
public boolean populateChunk(World world, int chunkX, int chunkZ, Random random) {
long chunkId = (long) chunkX << 32 | chunkZ & 0xFFFFFFFFL;
ChunkDataEntry chunkDataEntry = dataByChunkPos.get(chunkId);
GTWorldGenCapability capability = retrieveCapability(world, chunkX, chunkZ);
capability.setFrom(masterEntry);
if (chunkDataEntry != null && chunkDataEntry.populateChunk(world)) {
for (OreDepositDefinition definition : chunkDataEntry.generatedOres) {
IVeinPopulator veinPopulator = definition.getVeinPopulator();
if (veinPopulator instanceof VeinChunkPopulator) {
((VeinChunkPopulator) veinPopulator).populateChunk(world, chunkX, chunkZ, random, definition, this);
}
}
return true;
}
return false;
}
Aggregations