vanilla structures

This commit is contained in:
dfsek
2021-05-17 10:07:06 -07:00
parent f96740f1fa
commit 41a54f4b25
3 changed files with 20 additions and 16 deletions

View File

@@ -168,7 +168,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
@Override
public boolean isDebug() {
return true;
return config.isDebug();
}
@Override

View File

@@ -90,23 +90,24 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
@Nullable
@Override
public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
String name = Objects.requireNonNull(Registry.STRUCTURE_FEATURE.getId(feature)).toString();
TerraWorld terraWorld = TerraFabricPlugin.getInstance().getWorld((World) world);
TerraStructure located = pack.getStructure(pack.getTemplate().getLocatable().get(name));
if(located != null) {
CompletableFuture<BlockPos> result = new CompletableFuture<>();
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center).toLocation((World) world), 0, 500, location -> {
result.complete(FabricAdapter.adapt(location));
}, TerraFabricPlugin.getInstance());
finder.run(); // Do this synchronously.
try {
return result.get();
} catch(InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
if(!pack.getTemplate().disableStructures()) {
String name = Objects.requireNonNull(Registry.STRUCTURE_FEATURE.getId(feature)).toString();
TerraWorld terraWorld = TerraFabricPlugin.getInstance().getWorld((World) world);
TerraStructure located = pack.getStructure(pack.getTemplate().getLocatable().get(name));
if(located != null) {
CompletableFuture<BlockPos> result = new CompletableFuture<>();
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center).toLocation((World) world), 0, 500, location -> {
result.complete(FabricAdapter.adapt(location));
}, TerraFabricPlugin.getInstance());
finder.run(); // Do this synchronously.
try {
return result.get();
} catch(InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}
TerraFabricPlugin.getInstance().logger().warning("No overrides are defined for \"" + name + "\"");
return null;
return super.locateStructure(world, feature, center, radius, skipExistingChunks);
}
@Override
@@ -127,6 +128,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
@Override
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
if(pack.getTemplate().vanillaStructures()) return super.isStrongholdStartingChunk(chunkPos);
return false;
}

View File

@@ -59,11 +59,13 @@ public final class FabricUtil {
PackFeatureOptionsTemplate optionsTemplate = fabricAddon.getTemplates().get(pack);
if(optionsTemplate.doBiomeInjection()) {
TerraFabricPlugin.getInstance().getDebugLogger().info("Injecting features into " + biome.getTemplate().getID());
for(int step = 0; step < vanilla.getGenerationSettings().getFeatures().size(); step++) {
for(Supplier<ConfiguredFeature<?, ?>> featureSupplier : vanilla.getGenerationSettings().getFeatures().get(step)) {
Identifier key = BuiltinRegistries.CONFIGURED_FEATURE.getId(featureSupplier.get());
if(!optionsTemplate.getExcludedBiomeFeatures().contains(key)) {
generationSettings.feature(step, featureSupplier);
TerraFabricPlugin.getInstance().getDebugLogger().info("Injected " + key + " at stage " + step);
}
}
}