mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
pull versions out to Versions config
This commit is contained in:
@@ -46,6 +46,8 @@ afterEvaluate {
|
||||
forSubProjects(":common:addons") {
|
||||
dependencies {
|
||||
"compileOnly"(project(":common:api"))
|
||||
"shadedImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"(project(":common:api"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
object Versions {
|
||||
object Libraries {
|
||||
const val tectonic = "3.1.0"
|
||||
const val paralithic = "0.6.0"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.6.1"
|
||||
|
||||
const val slf4j = "1.7.32"
|
||||
const val log4j_slf4j_impl = "2.14.1"
|
||||
|
||||
object Internal {
|
||||
const val apacheText = "1.9"
|
||||
const val jafama = "2.3.2"
|
||||
const val apacheIO = "2.6"
|
||||
const val asm = "9.2"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
@@ -18,4 +27,10 @@ object Versions {
|
||||
const val paper = "1.18-R0.1-SNAPSHOT"
|
||||
const val paperLib = "1.0.5"
|
||||
}
|
||||
|
||||
object Sponge {
|
||||
const val sponge = "9.0.0-SNAPSHOT"
|
||||
const val mixin = "0.8.2"
|
||||
const val minecraft = "1.17.1"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
dependencies {
|
||||
shadedApi(project(":common:api:util"))
|
||||
shadedApi("ca.solo-studios:strata:1.1.1")
|
||||
shadedApi("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ dependencies {
|
||||
shadedApi(project(":common:api:registry"))
|
||||
shadedApi(project(":common:api:addons"))
|
||||
|
||||
shadedApi("net.jafama:jafama:2.3.2")
|
||||
|
||||
shadedApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
shadedApi("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
|
||||
|
||||
shadedApi("cloud.commandframework", "cloud-core", "1.6.1")
|
||||
|
||||
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
dependencies {
|
||||
shadedApi(project(":common:api:util"))
|
||||
|
||||
shadedApi("net.jafama:jafama:2.3.2")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
dependencies {
|
||||
shadedApi(project(":common:api:util"))
|
||||
|
||||
shadedApi("com.dfsek:paralithic:0.6.0")
|
||||
shadedApi("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
|
||||
shadedApi("net.jafama:jafama:2.3.2")
|
||||
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
dependencies {
|
||||
shadedApi("com.dfsek.tectonic:common:${Versions.Libraries.tectonic}")
|
||||
shadedApi("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
|
||||
shadedApi("net.jafama:jafama:2.3.2")
|
||||
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ dependencies {
|
||||
shadedApi(project(":common:api"))
|
||||
shadedApi(project(":common:implementation:bootstrap-addon-loader"))
|
||||
|
||||
shadedApi("org.apache.commons:commons-rng-core:1.3")
|
||||
shadedApi("commons-io:commons-io:2.6")
|
||||
shadedImplementation("org.apache.commons:commons-text:1.9")
|
||||
shadedImplementation("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
|
||||
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
shadedImplementation("org.apache.commons", "commons-text", Versions.Libraries.Internal.apacheText)
|
||||
shadedImplementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
|
||||
|
||||
shadedImplementation("org.yaml:snakeyaml:1.27")
|
||||
shadedImplementation("org.ow2.asm:asm:9.2")
|
||||
shadedImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
shadedImplementation("org.ow2.asm", "asm", Versions.Libraries.Internal.asm)
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.config.loaders.config;
|
||||
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.structure.StructureSpawn;
|
||||
import com.dfsek.terra.math.GridSpawn;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class GridSpawnLoader implements TypeLoader<StructureSpawn> {
|
||||
@Override
|
||||
public StructureSpawn load(AnnotatedType type, Object o, ConfigLoader configLoader) {
|
||||
Map<String, Integer> map = (Map<String, Integer>) o;
|
||||
return new GridSpawn(map.get("width"), map.get("padding"), map.getOrDefault("salt", 0));
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.math;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.util.PopulationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.util.FastRandom;
|
||||
|
||||
|
||||
/**
|
||||
* Class to procedurally determine the spawn point of an object based on a grid with padding between cells.
|
||||
*/
|
||||
public class GridSpawn implements com.dfsek.terra.api.structure.StructureSpawn {
|
||||
private final int separation;
|
||||
private final int width;
|
||||
private final int salt;
|
||||
|
||||
public GridSpawn(int width, int separation, int salt) {
|
||||
this.separation = separation;
|
||||
this.width = width;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 getNearestSpawn(int x, int z, long seed) {
|
||||
int structureChunkX = x / (width + 2 * separation);
|
||||
int structureChunkZ = z / (width + 2 * separation);
|
||||
List<Vector3> zones = new ArrayList<>(9);
|
||||
for(int xi = structureChunkX - 1; xi <= structureChunkX + 1; xi++) {
|
||||
for(int zi = structureChunkZ - 1; zi <= structureChunkZ + 1; zi++) {
|
||||
zones.add(getChunkSpawn(xi, zi, seed));
|
||||
}
|
||||
}
|
||||
Vector3 shortest = zones.get(0);
|
||||
Vector3 compare = new Vector3(x, 0, z);
|
||||
for(Vector3 v : zones) {
|
||||
if(compare.distanceSquared(shortest) > compare.distanceSquared(v)) shortest = v.clone();
|
||||
}
|
||||
return shortest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X/Z coordinates of the spawn point in the nearest Chunk (not Minecraft chunk)
|
||||
*
|
||||
* @param structureChunkX Chunk X coordinate
|
||||
* @param structureChunkZ Chunk Z coordinate
|
||||
* @param seed Seed for RNG
|
||||
*
|
||||
* @return Vector representing spawnpoint
|
||||
*/
|
||||
public Vector3 getChunkSpawn(int structureChunkX, int structureChunkZ, long seed) {
|
||||
Random r = new FastRandom(PopulationUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed + salt));
|
||||
int offsetX = r.nextInt(width);
|
||||
int offsetZ = r.nextInt(width);
|
||||
int sx = structureChunkX * (width + 2 * separation) + offsetX;
|
||||
int sz = structureChunkZ * (width + 2 * separation) + offsetZ;
|
||||
return new Vector3(sx, 0, sz);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getSeparation() {
|
||||
return separation;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.util;
|
||||
|
||||
|
||||
import org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Random;
|
||||
import java.util.SplittableRandom;
|
||||
|
||||
|
||||
public class FastRandom extends Random {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 4571946470190183260L;
|
||||
private XoRoShiRo128PlusPlus random;
|
||||
|
||||
public FastRandom() {
|
||||
super();
|
||||
SplittableRandom randomseed = new SplittableRandom();
|
||||
this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
}
|
||||
|
||||
public FastRandom(long seed) {
|
||||
super(seed);
|
||||
SplittableRandom randomseed = new SplittableRandom(seed);
|
||||
this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setSeed(long seed) {
|
||||
SplittableRandom randomseed = new SplittableRandom(seed);
|
||||
this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextBytes(byte[] bytes) {
|
||||
random.nextBytes(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int bound) {
|
||||
return random.nextInt(bound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return (float) random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ dependencies {
|
||||
shadedApi("org.slf4j:slf4j-api:1.8.0-beta4") {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
}
|
||||
shadedImplementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.14.1") {
|
||||
shadedImplementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ dependencies {
|
||||
shadedApi("org.slf4j:slf4j-api:1.8.0-beta4") {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
}
|
||||
shadedImplementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.14.1") {
|
||||
shadedImplementation("org.apache.logging.log4j", "log4j-slf4j18-impl", Versions.Libraries.log4j_slf4j_impl) {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
}
|
||||
|
||||
annotationProcessor("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||
implementation("org.spongepowered:spongeapi:9.0.0-SNAPSHOT")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8.2:processor")
|
||||
annotationProcessor("org.spongepowered", "spongeapi", Versions.Sponge.sponge)
|
||||
implementation("org.spongepowered", "spongeapi", Versions.Sponge.sponge)
|
||||
annotationProcessor("org.spongepowered:mixin:${Versions.Sponge.mixin}:processor")
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version("1.17.1")
|
||||
version(Versions.Sponge.minecraft)
|
||||
runs {
|
||||
server()
|
||||
client()
|
||||
|
||||
Reference in New Issue
Block a user