mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
vanilla structures
This commit is contained in:
@@ -168,7 +168,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
return true;
|
return config.isDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+17
-15
@@ -90,23 +90,24 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
|
public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
|
||||||
String name = Objects.requireNonNull(Registry.STRUCTURE_FEATURE.getId(feature)).toString();
|
if(!pack.getTemplate().disableStructures()) {
|
||||||
TerraWorld terraWorld = TerraFabricPlugin.getInstance().getWorld((World) world);
|
String name = Objects.requireNonNull(Registry.STRUCTURE_FEATURE.getId(feature)).toString();
|
||||||
TerraStructure located = pack.getStructure(pack.getTemplate().getLocatable().get(name));
|
TerraWorld terraWorld = TerraFabricPlugin.getInstance().getWorld((World) world);
|
||||||
if(located != null) {
|
TerraStructure located = pack.getStructure(pack.getTemplate().getLocatable().get(name));
|
||||||
CompletableFuture<BlockPos> result = new CompletableFuture<>();
|
if(located != null) {
|
||||||
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center).toLocation((World) world), 0, 500, location -> {
|
CompletableFuture<BlockPos> result = new CompletableFuture<>();
|
||||||
result.complete(FabricAdapter.adapt(location));
|
AsyncStructureFinder finder = new AsyncStructureFinder(terraWorld.getBiomeProvider(), located, FabricAdapter.adapt(center).toLocation((World) world), 0, 500, location -> {
|
||||||
}, TerraFabricPlugin.getInstance());
|
result.complete(FabricAdapter.adapt(location));
|
||||||
finder.run(); // Do this synchronously.
|
}, TerraFabricPlugin.getInstance());
|
||||||
try {
|
finder.run(); // Do this synchronously.
|
||||||
return result.get();
|
try {
|
||||||
} catch(InterruptedException | ExecutionException e) {
|
return result.get();
|
||||||
throw new RuntimeException(e);
|
} catch(InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TerraFabricPlugin.getInstance().logger().warning("No overrides are defined for \"" + name + "\"");
|
return super.locateStructure(world, feature, center, radius, skipExistingChunks);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,6 +128,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
|
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
|
||||||
|
if(pack.getTemplate().vanillaStructures()) return super.isStrongholdStartingChunk(chunkPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,11 +59,13 @@ public final class FabricUtil {
|
|||||||
PackFeatureOptionsTemplate optionsTemplate = fabricAddon.getTemplates().get(pack);
|
PackFeatureOptionsTemplate optionsTemplate = fabricAddon.getTemplates().get(pack);
|
||||||
|
|
||||||
if(optionsTemplate.doBiomeInjection()) {
|
if(optionsTemplate.doBiomeInjection()) {
|
||||||
|
TerraFabricPlugin.getInstance().getDebugLogger().info("Injecting features into " + biome.getTemplate().getID());
|
||||||
for(int step = 0; step < vanilla.getGenerationSettings().getFeatures().size(); step++) {
|
for(int step = 0; step < vanilla.getGenerationSettings().getFeatures().size(); step++) {
|
||||||
for(Supplier<ConfiguredFeature<?, ?>> featureSupplier : vanilla.getGenerationSettings().getFeatures().get(step)) {
|
for(Supplier<ConfiguredFeature<?, ?>> featureSupplier : vanilla.getGenerationSettings().getFeatures().get(step)) {
|
||||||
Identifier key = BuiltinRegistries.CONFIGURED_FEATURE.getId(featureSupplier.get());
|
Identifier key = BuiltinRegistries.CONFIGURED_FEATURE.getId(featureSupplier.get());
|
||||||
if(!optionsTemplate.getExcludedBiomeFeatures().contains(key)) {
|
if(!optionsTemplate.getExcludedBiomeFeatures().contains(key)) {
|
||||||
generationSettings.feature(step, featureSupplier);
|
generationSettings.feature(step, featureSupplier);
|
||||||
|
TerraFabricPlugin.getInstance().getDebugLogger().info("Injected " + key + " at stage " + step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user