From 41a54f4b2542a0c7967a9fc258a3736563d3f458 Mon Sep 17 00:00:00 2001 From: dfsek Date: Mon, 17 May 2021 10:07:06 -0700 Subject: [PATCH] vanilla structures --- .../dfsek/terra/fabric/TerraFabricPlugin.java | 2 +- .../FabricChunkGeneratorWrapper.java | 32 ++++++++++--------- .../dfsek/terra/fabric/util/FabricUtil.java | 2 ++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java index 3573e8427..f5c5eb156 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/TerraFabricPlugin.java @@ -168,7 +168,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer { @Override public boolean isDebug() { - return true; + return config.isDebug(); } @Override diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java index b4efa496e..116c007ad 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java @@ -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 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 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; } diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricUtil.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricUtil.java index 224f616ba..72c8404c6 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricUtil.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/util/FabricUtil.java @@ -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> 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); } } }