mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
Merge submodule contents for common/addons/config-feature/master
This commit is contained in:
commit
6ad29f5002
21
common/addons/config-feature/LICENSE
Normal file
21
common/addons/config-feature/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-2021 Polyhedral Development
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
3
common/addons/config-feature/build.gradle.kts
Normal file
3
common/addons/config-feature/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies {
|
||||||
|
"shadedApi"(project(":common:addons:manifest-addon-loader"))
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Feature;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
|
|
||||||
|
public class ConfiguredFeature implements Feature {
|
||||||
|
private final ProbabilityCollection<Structure> structures;
|
||||||
|
|
||||||
|
private final NoiseSampler structureSelector;
|
||||||
|
private final Distributor distributor;
|
||||||
|
private final Locator locator;
|
||||||
|
|
||||||
|
public ConfiguredFeature(ProbabilityCollection<Structure> structures, NoiseSampler structureSelector, Distributor distributor,
|
||||||
|
Locator locator) {
|
||||||
|
this.structures = structures;
|
||||||
|
this.structureSelector = structureSelector;
|
||||||
|
this.distributor = distributor;
|
||||||
|
this.locator = locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Structure getStructure(World world, int x, int y, int z) {
|
||||||
|
return structures.get(structureSelector, x, y, z, world.getSeed());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Distributor getDistributor() {
|
||||||
|
return distributor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locator getLocator() {
|
||||||
|
return locator;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
|
||||||
|
|
||||||
|
public class FeatureAddon implements AddonInitializer {
|
||||||
|
@Inject
|
||||||
|
private Platform platform;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BaseAddon addon;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
platform.getEventManager()
|
||||||
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
|
.then(event -> event.getPack().registerConfigType(new FeatureConfigType(), "FEATURE", 3))
|
||||||
|
.failThrough();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.api.config.ConfigType;
|
||||||
|
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Feature;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
|
public class FeatureConfigType implements ConfigType<FeatureTemplate, Feature> {
|
||||||
|
public static final TypeKey<Feature> FEATURE_TYPE_KEY = new TypeKey<>() {
|
||||||
|
};
|
||||||
|
|
||||||
|
private final FeatureFactory factory = new FeatureFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||||
|
return new FeatureTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigFactory<FeatureTemplate, Feature> getFactory() {
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeKey<Feature> getTypeKey() {
|
||||||
|
return FEATURE_TYPE_KEY;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.exception.LoadException;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Feature;
|
||||||
|
|
||||||
|
|
||||||
|
public class FeatureFactory implements ConfigFactory<FeatureTemplate, Feature> {
|
||||||
|
@Override
|
||||||
|
public Feature build(FeatureTemplate config, Platform platform) throws LoadException {
|
||||||
|
return new ConfiguredFeature(config.getStructures(), config.getStructureNoise(), config.getDistributor(), config.getLocator());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.annotations.Final;
|
||||||
|
import com.dfsek.tectonic.annotations.Value;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||||
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||||
|
|
||||||
|
|
||||||
|
public class FeatureTemplate implements AbstractableTemplate {
|
||||||
|
@Value("id")
|
||||||
|
@Final
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Value("distributor")
|
||||||
|
private @Meta Distributor distributor;
|
||||||
|
|
||||||
|
@Value("locator")
|
||||||
|
private @Meta Locator locator;
|
||||||
|
|
||||||
|
@Value("structures.distribution")
|
||||||
|
private @Meta NoiseSampler structureNoise;
|
||||||
|
|
||||||
|
@Value("structures.structures")
|
||||||
|
private @Meta ProbabilityCollection<Structure> structures;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Distributor getDistributor() {
|
||||||
|
return distributor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Locator getLocator() {
|
||||||
|
return locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NoiseSampler getStructureNoise() {
|
||||||
|
return structureNoise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProbabilityCollection<Structure> getStructures() {
|
||||||
|
return structures;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
schema-version: 1
|
||||||
|
contributors:
|
||||||
|
- Terra contributors
|
||||||
|
id: config-feature
|
||||||
|
version: 0.1.0
|
||||||
|
entrypoints:
|
||||||
|
- "com.dfsek.terra.addons.feature.FeatureAddon"
|
||||||
|
website:
|
||||||
|
issues: https://github.com/PolyhedralDev/Terra-config-feature/issues
|
||||||
|
source: https://github.com/PolyhedralDev/Terra-config-feature
|
||||||
|
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||||
|
license: GNU LGPL v3.0
|
||||||
|
depends:
|
||||||
|
generation-stage-feature: "0.1.+"
|
Loading…
x
Reference in New Issue
Block a user