Skip to content
Open

7.3 #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# TerrainAPI

# About

TerrainAPI is a complete rewrite of the Chunk Decorator Classes in BTA, it allows for mods to easily add and modify world features and structures in BTA. TerrainAPI is also setup to allow lots of configurability to the user, allowing them to modify the world generation themselves.

Some user configurable things being:
- Tree densities
- Ore densities
- Ore spawn heights
- Lake densities
- Plant densities

## How to include TerrainAPI in a project
Add this in your `build.gradle`:
```groovy
repositories {
mavenCentral()
maven { url = "https://jitpack.io" }
}

dependencies {
modImplementation 'com.github.UselessSolutions:TerrainAPI:v${project.terrain_api_version}'
}
```

Documentation Eventually! :)
100 changes: 60 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
plugins {
id 'babric-loom' version '1.1.+'
id 'fabric-loom' version '1.7.bta'
id 'java'
}

import org.gradle.internal.os.OperatingSystem

project.ext.lwjglVersion = "3.3.4"

switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
project.ext.lwjglNatives = "natives-linux"
break
case OperatingSystem.WINDOWS:
project.ext.lwjglNatives = "natives-windows"
break
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = "natives-macos"
}

group = project.mod_group
archivesBaseName = project.mod_name
version = project.mod_version

loom {
gluedMinecraftJar()
noIntermediateMappings()
customMinecraftManifest.set("https://github.com/Turnip-Labs/bta-manifest-repo/releases/download/v${project.bta_version}/${project.bta_version}.json")
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${project.bta_channel}/v${project.bta_version}/manifest.json")
}

repositories {
Expand All @@ -24,6 +38,14 @@ repositories {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'SignalumMavenInfrastructure'
url = 'https://maven.thesignalumproject.net/infrastructure'
}
maven {
name = 'SignalumMavenReleases'
url = 'https://maven.thesignalumproject.net/releases'
}
ivy {
url = "https://github.com/Better-than-Adventure"
patternLayout {
Expand All @@ -33,25 +55,17 @@ repositories {
metadataSources { artifact() }
}
ivy {
url = "https://github.com/Turnip-Labs"
url = "https://downloads.betterthanadventure.net/bta-client/${project.bta_channel}/"
patternLayout {
artifact "[organisation]/releases/download/v[revision]/[module]-[revision].jar"
artifact "/v[revision]/client.jar"
m2compatible = true
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/Turnip-Labs"
url = "https://downloads.betterthanadventure.net/bta-server/${project.bta_channel}/"
patternLayout {
artifact "[organisation]/releases/download/[revision]/[module]-[revision].jar"
m2compatible = true
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/Turnip-Labs"
patternLayout {
artifact "[organisation]/releases/download/[revision]/[module]-bta-[revision].jar"
artifact "/v[revision]/server.jar"
m2compatible = true
}
metadataSources { artifact() }
Expand All @@ -64,48 +78,49 @@ repositories {
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/MartinSVK12"
patternLayout {
artifact "[organisation]/releases/download/[revision]/[module]-[revision].jar"
m2compatible = true
}
metadataSources { artifact() }
}
ivy {
url = "https://github.com/UselessBullets"
patternLayout {
artifact "[organisation]/releases/download/v[revision]/[module]-[revision].jar"
m2compatible = true
}
metadataSources { artifact() }
}

}

dependencies {
minecraft "bta-download-repo:bta:${project.bta_version}"
minecraft "::${project.bta_version}"
mappings loom.layered() {}

modRuntimeOnly "objects:client:43db9b498cb67058d2e12d394e6507722e71bb45" // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
modImplementation "fabric-loader:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Helper library
// If you do not need Halplibe you can comment this line out or delete this line
modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}"
implementation("turniplabs:halplibe:${project.halplibe_version}")

modImplementation "ModMenu:ModMenu:2.0.0"
//modImplementation "Useless-Profiler:profiler:1.0.1"
modImplementation("turniplabs:modmenu-bta:${project.mod_menu_version}")

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"

implementation 'com.google.guava:guava:30.0-jre'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'

implementation 'com.google.guava:guava:33.0.0-jre'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
var log4jVersion = "2.20.0"
implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-api:${log4jVersion}")
implementation("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")

include(implementation("org.apache.commons:commons-lang3:3.12.0"))

modImplementation("com.github.zarzelcow:legacy-lwjgl3:1.0.4")
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")

runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
implementation "org.lwjgl:lwjgl:$lwjglVersion"
implementation "org.lwjgl:lwjgl-assimp:$lwjglVersion"
implementation "org.lwjgl:lwjgl-glfw:$lwjglVersion"
implementation "org.lwjgl:lwjgl-openal:$lwjglVersion"
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion"
implementation "org.lwjgl:lwjgl-stb:$lwjglVersion"
}

java {
Expand All @@ -114,7 +129,7 @@ java {
withSourcesJar()
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.release.set 8
}

Expand All @@ -124,6 +139,11 @@ jar {
}
}

configurations.configureEach {
// Removes LWJGL2 dependencies
exclude group: "org.lwjgl.lwjgl"
}

processResources {
inputs.property "version", version

Expand Down
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
org.gradle.jvmargs=-Xmx2G

# BTA
bta_version=1.7.7.0_02
bta_version=7.3
bta_channel=release

# Loader
loader_version=0.14.19-babric.1-bta
loader_version=0.15.6-bta.7

# HalpLibe
halplibe_version=2.7.0
halplibe_version=5.1.0
mod_menu_version=3.0.0

# Mod
mod_version=1.3.1
mod_version=1.5.0-7.3
mod_group=useless
mod_name=terrainapi
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
Binary file added lib/modmenu-bta-3.0.0.jar
Binary file not shown.
36 changes: 20 additions & 16 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
}
}
repositories {
gradlePluginPortal()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Jitpack'
url = 'https://jitpack.io'
}
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
maven {
name = 'SignalumMavenInfrastructure'
url = 'https://maven.thesignalumproject.net/infrastructure'
}
}
}
13 changes: 9 additions & 4 deletions src/main/java/useless/terrainapi/TerrainMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import com.google.gson.GsonBuilder;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.ApiStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.util.GameStartEntrypoint;
import useless.terrainapi.api.TerrainAPI;
import useless.terrainapi.config.ConfigManager;
import useless.terrainapi.initialization.TerrainInitialization;


public class TerrainMain implements ModInitializer {
public class TerrainMain implements ModInitializer, GameStartEntrypoint {
public static final Gson GSON = (new GsonBuilder()).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
public static final String MOD_ID = "terrain-api";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
Expand All @@ -25,8 +25,13 @@ public class TerrainMain implements ModInitializer {
public void onInitialize() {
LOGGER.info("TerrainMain initialized.");
}
@ApiStatus.Internal
public static void loadModules(){
@Override
public void beforeGameStart() {

}

@Override
public void afterGameStart() {
LOCK_API = false;
new TerrainInitialization().onInitialize();
FabricLoader.getInstance().getEntrypoints("terrain-api", TerrainAPI.class).forEach(api -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/useless/terrainapi/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static void prepareBiomeConfigFile(String id) {
if (fileHashMap.get(id) != null) {
return;
}
Path filePath = Paths.get(FabricLoader.getInstance().getConfigDirectory() + "/" + TerrainMain.MOD_ID);
Path filePath = Paths.get(FabricLoader.getInstance().getConfigDir() + "/" + TerrainMain.MOD_ID);
try {
Files.createDirectories(filePath);
} catch (IOException e) {
Expand Down
41 changes: 33 additions & 8 deletions src/main/java/useless/terrainapi/config/OreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,60 @@ public class OreConfig extends APIConfig {
/**
* Map of Block key generation range
*/
@SerializedName(value = "Vertical Range") @Expose
public HashMap<String, Float> verticalRange = new HashMap<>();
@SerializedName(value = "Vertical Starting Range") @Expose
public HashMap<String, Float> verticalStartingRange = new HashMap<>();

/**
* Map of Block key generation range
*/
@SerializedName(value = "Vertical Ending Range") @Expose
public HashMap<String, Float> verticalEndingRange = new HashMap<>();

/**Creates an ore entry, this can be used directly by OreFeatures#addManagedOreFeature or directly by referencing the HashMaps themselves
* @param block The block to be generated, the block key is used as the key for the hashmap
* @param clusterSize Size in blocks of an ore vein
* @param chances Number of chances per chunk to generate an ore patch, this values scales with world height
* @param range Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
*/
public void setOreValues(String modID, Block block, int clusterSize, int chances, float range){
public void setOreValues(String modID, Block<?> block, int clusterSize, int chances, float range){
String key = block.getKey();
if (this.clusterSize.containsKey(key) && this.getConfigOverride()){
return;
}
if (this.clusterSize.getOrDefault(key, clusterSize) != clusterSize || this.chancesPerChunk.getOrDefault(key, chances) != chances || this.verticalRange.getOrDefault(key, range) != range){
if (this.clusterSize.getOrDefault(key, clusterSize) != clusterSize || this.chancesPerChunk.getOrDefault(key, chances) != chances || this.verticalStartingRange.getOrDefault(key, 0f) != 0 || this.verticalStartingRange.getOrDefault(key, range) != range){
TerrainMain.LOGGER.warn(modID + String.format(" has changed block %s to generate %d blocks with %d chances and a range of %f", block.getKey(), clusterSize, chances, range));
}
setOreValues(block, clusterSize, chances, range);
setOreValues(block, clusterSize, chances, 0, range);
}
/**Creates an ore entry, this can be used directly by OreFeatures#addManagedOreFeature or directly by referencing the HashMaps themselves
* @param block The block to be generated, the block key is used as the key for the hashmap
* @param clusterSize Size in blocks of an ore vein
* @param chances Number of chances per chunk to generate an ore patch, this values scales with world height
* @param range Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
* @param startingRange Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
* @param endingRange Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
*/
public void setOreValues(String modID, Block<?> block, int clusterSize, int chances, float startingRange, float endingRange){
String key = block.getKey();
if (this.clusterSize.containsKey(key) && this.getConfigOverride()){
return;
}
if (this.clusterSize.getOrDefault(key, clusterSize) != clusterSize || this.chancesPerChunk.getOrDefault(key, chances) != chances || this.verticalStartingRange.getOrDefault(key, startingRange) != startingRange || this.verticalEndingRange.getOrDefault(key, endingRange) != endingRange){
TerrainMain.LOGGER.warn(modID + String.format(" has changed block %s to generate %d blocks with %d chances and a range of [%f, %f]", block.getKey(), clusterSize, chances, startingRange, endingRange));
}
setOreValues(block, clusterSize, chances, startingRange, endingRange);
}
/**Creates an ore entry, this can be used directly by OreFeatures#addManagedOreFeature or directly by referencing the HashMaps themselves
* @param block The block to be generated, the block key is used as the key for the hashmap
* @param clusterSize Size in blocks of an ore vein
* @param chances Number of chances per chunk to generate an ore patch, this values scales with world height
* @param startingRange Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
* @param endingRange Value from [0, 1], it's the fraction from the bottom of the world to the surface that the ore can generate
*/
@ApiStatus.Internal
protected void setOreValues(Block block, int clusterSize, int chances, float range){
protected void setOreValues(Block block, int clusterSize, int chances, float startingRange, float endingRange){
this.clusterSize.put(block.getKey(), clusterSize);
this.chancesPerChunk.put(block.getKey(), chances);
this.verticalRange.put(block.getKey(), range);
this.verticalStartingRange.put(block.getKey(), startingRange);
this.verticalEndingRange.put(block.getKey(), endingRange);
}
}
Loading