split tree addon

This commit is contained in:
dfsek 2021-07-17 13:41:25 -07:00
parent 78735ec769
commit 1e5a0bb93f
7 changed files with 21 additions and 24 deletions

View File

@ -1,19 +1,14 @@
package com.dfsek.terra.addons.tree;
import com.dfsek.terra.addons.tree.tree.TreeLayer;
import com.dfsek.terra.addons.tree.tree.TreeLayerTemplate;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.addon.annotations.Addon;
import com.dfsek.terra.api.addon.annotations.Author;
import com.dfsek.terra.api.addon.annotations.Version;
import com.dfsek.terra.api.event.EventListener;
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
import com.dfsek.terra.api.util.seeded.BiomeBuilder;
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
@Addon("config-tree")
@Author("Terra")
@ -29,13 +24,5 @@ public class TreeAddon extends TerraAddon implements EventListener {
public void onPackLoad(ConfigPackPreLoadEvent event) throws DuplicateEntryException {
event.getPack().registerConfigType(new TreeConfigType(event.getPack()), "TREE", 2);
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("TREE", pack -> new TreePopulator(main));
event.getPack().applyLoader(TreeLayer.class, TreeLayerTemplate::new);
}
public void onBiomeLoad(ConfigurationLoadEvent event) {
if(BiomeBuilder.class.isAssignableFrom(event.getType().getTypeClass())) {
event.getLoadedObject(BiomeBuilder.class).getContext().put(event.load(new BiomeTreeTemplate()).get());
}
}
}

View File

@ -1,10 +1,8 @@
package com.dfsek.terra.addons.tree;
package com.dfsek.terra.addons.generation.tree;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.config.ConfigTemplate;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.addons.tree.tree.TreeLayer;
import java.util.Collections;
import java.util.List;

View File

@ -1,6 +1,5 @@
package com.dfsek.terra.addons.tree;
package com.dfsek.terra.addons.generation.tree;
import com.dfsek.terra.addons.tree.tree.TreeLayer;
import com.dfsek.terra.api.properties.Properties;
import java.util.List;

View File

@ -6,7 +6,12 @@ import com.dfsek.terra.api.addon.annotations.Addon;
import com.dfsek.terra.api.addon.annotations.Author;
import com.dfsek.terra.api.addon.annotations.Version;
import com.dfsek.terra.api.event.EventListener;
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
import com.dfsek.terra.api.util.seeded.BiomeBuilder;
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
@Addon("generation-stage-tree")
@Version("1.0.0")
@ -19,4 +24,15 @@ public class TreeGenerationAddon extends TerraAddon implements EventListener {
public void initialize() {
main.getEventManager().registerListener(this, this);
}
public void onPackLoad(ConfigPackPreLoadEvent event) throws DuplicateEntryException {
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("TREE", pack -> new TreePopulator(main));
event.getPack().applyLoader(TreeLayer.class, TreeLayerTemplate::new);
}
public void onBiomeLoad(ConfigurationLoadEvent event) {
if(BiomeBuilder.class.isAssignableFrom(event.getType().getTypeClass())) {
event.getLoadedObject(BiomeBuilder.class).getContext().put(event.load(new BiomeTreeTemplate()).get());
}
}
}

View File

@ -1,4 +1,4 @@
package com.dfsek.terra.addons.tree.tree;
package com.dfsek.terra.addons.generation.tree;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.noise.NoiseSampler;

View File

@ -1,12 +1,10 @@
package com.dfsek.terra.addons.tree.tree;
package com.dfsek.terra.addons.generation.tree;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.world.Flora;
import com.dfsek.terra.api.world.Tree;
public class TreeLayerTemplate implements ObjectTemplate<TreeLayer> {

View File

@ -1,6 +1,5 @@
package com.dfsek.terra.addons.tree;
package com.dfsek.terra.addons.generation.tree;
import com.dfsek.terra.addons.tree.tree.TreeLayer;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.profiler.ProfileFrame;
import com.dfsek.terra.api.util.PopulationUtil;