mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
delete tree config addon
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
# config-tree
|
||||
|
||||
Registers the default configuration for Terra Trees, `TREE`.
|
||||
@@ -1,45 +0,0 @@
|
||||
import com.dfsek.terra.configureCompilation
|
||||
import com.dfsek.terra.configureDependencies
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
idea
|
||||
}
|
||||
|
||||
configureCompilation()
|
||||
configureDependencies()
|
||||
|
||||
group = "com.dfsek.terra.common"
|
||||
|
||||
dependencies {
|
||||
"shadedApi"(project(":common:api"))
|
||||
"compileOnly"("com.google.guava:guava:30.0-jre")
|
||||
|
||||
"testImplementation"("com.google.guava:guava:30.0-jre")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks["sourcesJar"])
|
||||
artifact(tasks["jar"])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
|
||||
val mavenSnapshotUrl = "https://repo.codemc.io/repository/maven-snapshots/"
|
||||
|
||||
maven(mavenUrl) {
|
||||
val mavenUsername: String? by project
|
||||
val mavenPassword: String? by project
|
||||
if (mavenUsername != null && mavenPassword != null) {
|
||||
credentials {
|
||||
username = mavenUsername
|
||||
password = mavenPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
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.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
@Addon("config-tree")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class TreeAddon extends TerraAddon implements EventListener {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager().registerListener(this, this);
|
||||
}
|
||||
|
||||
public void onPackLoad(ConfigPackPreLoadEvent event) throws DuplicateEntryException {
|
||||
event.getPack().registerConfigType(new TreeConfigType(), "TREE", 2);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
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.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TreeConfigType implements ConfigType<TreeTemplate, Tree> {
|
||||
private final TreeFactory factory = new TreeFactory();
|
||||
|
||||
public static final TypeKey<Tree> TREE_TYPE_TOKEN = new TypeKey<>(){};
|
||||
|
||||
@Override
|
||||
public TreeTemplate getTemplate(ConfigPack pack, TerraPlugin main) {
|
||||
return new TreeTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigFactory<TreeTemplate, Tree> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeKey<Tree> getTypeClass() {
|
||||
return TREE_TYPE_TOKEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<OpenRegistry<Tree>> registrySupplier(ConfigPack pack) {
|
||||
return pack.getRegistryFactory()::create;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.terra.addons.tree.tree.TerraTree;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
|
||||
public class TreeFactory implements ConfigFactory<TreeTemplate, Tree> {
|
||||
@Override
|
||||
public Tree build(TreeTemplate config, TerraPlugin main) {
|
||||
return new TerraTree(config.getSpawnable(), config.getyOffset(), config.getStructures());
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class TreeTemplate implements AbstractableTemplate {
|
||||
@Value("scripts")
|
||||
private ProbabilityCollection<Structure> structure;
|
||||
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("y-offset")
|
||||
@Default
|
||||
private int yOffset = 0;
|
||||
|
||||
@Value("spawnable")
|
||||
private MaterialSet spawnable;
|
||||
|
||||
public ProbabilityCollection<Structure> getStructures() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getyOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
public MaterialSet getSpawnable() {
|
||||
return spawnable;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.dfsek.terra.addons.tree.tree;
|
||||
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TerraTree implements Tree {
|
||||
private final MaterialSet spawnable;
|
||||
private final int yOffset;
|
||||
private final ProbabilityCollection<Structure> structure;
|
||||
|
||||
public TerraTree(MaterialSet spawnable, int yOffset, ProbabilityCollection<Structure> structure) {
|
||||
this.spawnable = spawnable;
|
||||
this.yOffset = yOffset;
|
||||
this.structure = structure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean plant(Vector3 location, World world, Random random) {
|
||||
return structure.get(random).generateDirect(location.clone().add(0, yOffset, 0), world, random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialSet getSpawnable() {
|
||||
return spawnable;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user