mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 22:01:07 +00:00
add TopLocator
This commit is contained in:
+3
-1
@@ -20,6 +20,7 @@ import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
|||||||
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
||||||
|
import com.dfsek.terra.addons.feature.locator.config.TopLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.XorLocatorTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.XorLocatorTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.pattern.AirMatchPatternTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.pattern.AirMatchPatternTemplate;
|
||||||
import com.dfsek.terra.addons.feature.locator.config.pattern.AndPatternTemplate;
|
import com.dfsek.terra.addons.feature.locator.config.pattern.AndPatternTemplate;
|
||||||
@@ -60,7 +61,8 @@ public class LocatorAddon implements AddonInitializer {
|
|||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
CheckedRegistry<Supplier<ObjectTemplate<Locator>>> locatorRegistry = event.getPack().getOrCreateRegistry(LOCATOR_TOKEN);
|
||||||
locatorRegistry.register(addon.key("SURFACE"), () -> new SurfaceLocatorTemplate(platform));
|
locatorRegistry.register(addon.key("SURFACE"), SurfaceLocatorTemplate::new);
|
||||||
|
locatorRegistry.register(addon.key("TOP"), TopLocatorTemplate::new);
|
||||||
|
|
||||||
locatorRegistry.register(addon.key("RANDOM"), RandomLocatorTemplate::new);
|
locatorRegistry.register(addon.key("RANDOM"), RandomLocatorTemplate::new);
|
||||||
locatorRegistry.register(addon.key("GAUSSIAN_RANDOM"), GaussianRandomLocatorTemplate::new);
|
locatorRegistry.register(addon.key("GAUSSIAN_RANDOM"), GaussianRandomLocatorTemplate::new);
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020-2021 Polyhedral Development
|
||||||
|
*
|
||||||
|
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||||
|
* reference the LICENSE file in this module's root directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.dfsek.terra.addons.feature.locator.config;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.feature.locator.locators.SurfaceLocator;
|
||||||
|
import com.dfsek.terra.addons.feature.locator.locators.TopLocator;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.util.Range;
|
||||||
|
|
||||||
|
|
||||||
|
public class TopLocatorTemplate implements ObjectTemplate<Locator> {
|
||||||
|
|
||||||
|
@Value("range")
|
||||||
|
private @Meta Range range;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locator get() {
|
||||||
|
return new TopLocator(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020-2021 Polyhedral Development
|
||||||
|
*
|
||||||
|
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||||
|
* reference the LICENSE file in this module's root directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.dfsek.terra.addons.feature.locator.locators;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.util.Range;
|
||||||
|
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||||
|
|
||||||
|
|
||||||
|
public class TopLocator implements Locator {
|
||||||
|
private final Range search;
|
||||||
|
|
||||||
|
public TopLocator(Range search) {
|
||||||
|
this.search = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||||
|
BinaryColumn location = new BinaryColumn(column.getMinY(), column.getMaxY());
|
||||||
|
for(int y : search) {
|
||||||
|
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||||
|
location.set(y);
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user