Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use direct types instead of getters #135

Merged
merged 4 commits into from
Aug 19, 2024
Merged
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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ subprojects {
maven("https://repo.codemc.io/repository/nms/")
// maven("https://libraries.minecraft.net/minecraft-server")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://jitpack.io")
}
// Handle this inside each implementation as different minecraft versions support a different max jvm version
// java {
Expand Down
1 change: 1 addition & 0 deletions buildProj/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
implementation(project(":implementation:v1_20_R3"))
implementation(project(":implementation:v1_20_R4"))
implementation(project(":implementation:v1_21_R1"))
implementation("com.github.AvarionMC:yaml:1.1.1")
}

tasks.shadowJar {
Expand Down
1 change: 1 addition & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies {
compileOnly(group = "org.spigotmc", name = "spigot", version = "1.18-R0.1-SNAPSHOT")
// compileOnly(group = "org.spigotmc", name = "spigot", version = "1.16.4-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:20.1.0")
compileOnly("com.github.AvarionMC:yaml:1.1.1")
}

// Set this to the lowest compat in implementation
Expand Down
152 changes: 76 additions & 76 deletions common/src/main/java/org/terraform/biome/BiomeBank.java

Large diffs are not rendered by default.

49 changes: 29 additions & 20 deletions common/src/main/java/org/terraform/biome/BiomeClimate.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,58 @@
package org.terraform.biome;

import org.jetbrains.annotations.NotNull;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.utils.Range;

public enum BiomeClimate {

// Tree-Dense areas
HUMID_VEGETATION(Range.between(TConfigOption.CLIMATE_HUMIDVEGETATION_MINTEMP.getDouble(),
TConfigOption.CLIMATE_HUMIDVEGETATION_MAXTEMP.getDouble()
), Range.between(TConfigOption.CLIMATE_HUMIDVEGETATION_MINMOIST.getDouble(),
TConfigOption.CLIMATE_HUMIDVEGETATION_MAXMOIST.getDouble()
HUMID_VEGETATION(Range.between(
TConfig.c.CLIMATE_HUMIDVEGETATION_MINTEMP,
TConfig.c.CLIMATE_HUMIDVEGETATION_MAXTEMP
), Range.between(
TConfig.c.CLIMATE_HUMIDVEGETATION_MINMOIST,
TConfig.c.CLIMATE_HUMIDVEGETATION_MAXMOIST
), 2),

// Savannas
DRY_VEGETATION(Range.between(TConfigOption.CLIMATE_DRYVEGETATION_MINTEMP.getDouble(),
TConfigOption.CLIMATE_DRYVEGETATION_MAXTEMP.getDouble()
), Range.between(TConfigOption.CLIMATE_DRYVEGETATION_MINMOIST.getDouble(),
TConfigOption.CLIMATE_DRYVEGETATION_MAXMOIST.getDouble()
DRY_VEGETATION(Range.between(
TConfig.c.CLIMATE_DRYVEGETATION_MINTEMP,
TConfig.c.CLIMATE_DRYVEGETATION_MAXTEMP
), Range.between(
TConfig.c.CLIMATE_DRYVEGETATION_MINMOIST,
TConfig.c.CLIMATE_DRYVEGETATION_MAXMOIST
), 1),

// Deserts
HOT_BARREN(Range.between(TConfigOption.CLIMATE_HOTBARREN_MINTEMP.getDouble(),
TConfigOption.CLIMATE_HOTBARREN_MAXTEMP.getDouble()
HOT_BARREN(Range.between(
TConfig.c.CLIMATE_HOTBARREN_MINTEMP,
TConfig.c.CLIMATE_HOTBARREN_MAXTEMP
),
Range.between(TConfigOption.CLIMATE_HOTBARREN_MINMOIST.getDouble(),
TConfigOption.CLIMATE_HOTBARREN_MAXMOIST.getDouble()
Range.between(
TConfig.c.CLIMATE_HOTBARREN_MINMOIST,
TConfig.c.CLIMATE_HOTBARREN_MAXMOIST
),
2
),

// Cold biomes - taigas, maybe eroded plains
COLD(Range.between(TConfigOption.CLIMATE_COLD_MINTEMP.getDouble(), TConfigOption.CLIMATE_COLD_MAXTEMP.getDouble()),
Range.between(TConfigOption.CLIMATE_COLD_MINMOIST.getDouble(),
TConfigOption.CLIMATE_COLD_MAXMOIST.getDouble()
COLD(Range.between(TConfig.c.CLIMATE_COLD_MINTEMP, TConfig.c.CLIMATE_COLD_MAXTEMP),
Range.between(
TConfig.c.CLIMATE_COLD_MINMOIST,
TConfig.c.CLIMATE_COLD_MAXMOIST
),
1
),

// Any snowy biomes.
SNOWY(Range.between(TConfigOption.CLIMATE_SNOWY_MINTEMP.getDouble(),
TConfigOption.CLIMATE_SNOWY_MAXTEMP.getDouble()
SNOWY(Range.between(
TConfig.c.CLIMATE_SNOWY_MINTEMP,
TConfig.c.CLIMATE_SNOWY_MAXTEMP
),
Range.between(TConfigOption.CLIMATE_SNOWY_MINMOIST.getDouble(),
TConfigOption.CLIMATE_SNOWY_MAXMOIST.getDouble()
Range.between(
TConfig.c.CLIMATE_SNOWY_MINMOIST,
TConfig.c.CLIMATE_SNOWY_MAXMOIST
),
2
),
Expand Down
10 changes: 5 additions & 5 deletions common/src/main/java/org/terraform/biome/BiomeSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.terraform.data.SimpleLocation;
import org.terraform.data.TerraformWorld;
import org.terraform.main.TerraformGeneratorPlugin;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.utils.GenUtils;
import org.terraform.utils.noise.FastNoise;
import org.terraform.utils.noise.FastNoise.NoiseType;
Expand All @@ -17,7 +17,7 @@

public class BiomeSection {
// A BiomeSection is 128 blocks wide (Default of bitshift 7).
public static final int bitshifts = TConfigOption.BIOME_SECTION_BITSHIFTS.getInt();
public static final int bitshifts = TConfig.c.BIOME_SECTION_BITSHIFTS;
public static final int sectionWidth = (int) (1 << bitshifts);
public static final int minSize = sectionWidth;
public static final int dominanceThreshold = (int) (0.35 * sectionWidth);
Expand Down Expand Up @@ -119,7 +119,7 @@ protected BiomeSection(TerraformWorld tw, int x, int z, boolean useSectionCoords

public static @NotNull BiomeSection getMostDominantSection(@NotNull TerraformWorld tw, int x, int z) {

double dither = TConfigOption.BIOME_DITHER.getDouble();
double dither = TConfig.c.BIOME_DITHER;
Random locationBasedRandom = new Random(Objects.hash(tw.getSeed(), x, z));
SimpleLocation target = new SimpleLocation(x, 0, z);
BiomeSection homeSection = BiomeBank.getBiomeSectionFromBlockCoords(tw, x, z);
Expand Down Expand Up @@ -169,8 +169,8 @@ protected void doCalculations() {
}

private @Nullable BiomeBank parseBiomeBank() {
temperature = 3.0f * 2.5f * tw.getTemperatureOctave().GetNoise(this.x, this.z);
moisture = 3.0f * 2.5f * tw.getMoistureOctave().GetNoise(this.x, this.z);
temperature = 3f * 2.5f * tw.getTemperatureOctave().GetNoise(this.x, this.z);
moisture = 3f * 2.5f * tw.getMoistureOctave().GetNoise(this.x, this.z);

return BiomeBank.selectBiome(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.terraform.data.SimpleBlock;
import org.terraform.data.SimpleLocation;
import org.terraform.data.TerraformWorld;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.tree.FractalTypes;
import org.terraform.tree.MushroomBuilder;
Expand Down Expand Up @@ -79,7 +79,7 @@ public void populateLargeItems(@NotNull TerraformWorld tw,
data.getChunkX(),
data.getChunkZ(),
15,
0.30f
0.3f
);

// Giant mushrooms
Expand All @@ -98,7 +98,7 @@ public void populateLargeItems(@NotNull TerraformWorld tw,
};

if (HeightMap.getTrueHeightGradient(data, sLoc.getX(), sLoc.getZ(), 3)
<= TConfigOption.MISC_TREES_GRADIENT_LIMIT.getDouble())
<= TConfig.c.MISC_TREES_GRADIENT_LIMIT)
{
new MushroomBuilder(type).build(tw, data, sLoc.getX(), sLoc.getY(), sLoc.getZ());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.terraform.coregen.bukkit.TerraformGenerator;
import org.terraform.coregen.populatordata.PopulatorDataAbstract;
import org.terraform.data.TerraformWorld;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.tree.TreeDB;
import org.terraform.utils.GenUtils;
Expand All @@ -20,8 +20,8 @@
* This class contains functions for oases, it's not a biome handler.
*/
public class OasisBeach {
public static final double oasisThreshold = (2 - TConfigOption.BIOME_OASIS_COMMONNESS.getDouble()) * 0.31;
private static final float oasisFrequency = TConfigOption.BIOME_OASIS_FREQUENCY.getFloat();
public static final double oasisThreshold = (2 - TConfig.c.BIOME_OASIS_COMMONNESS) * 0.31;
private static final float oasisFrequency = TConfig.c.BIOME_OASIS_FREQUENCY;

public static float getOasisNoise(TerraformWorld world, int x, int z) {
FastNoise lushRiversNoise = NoiseCacheHandler.getNoise(world,
Expand Down Expand Up @@ -127,7 +127,7 @@ public static void createBush(@NotNull Random random,
Material stem,
double density)
{
if (!TConfigOption.arePlantsEnabled()) {
if (!TConfig.arePlantsEnabled()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.terraform.biome.cavepopulators;

import org.jetbrains.annotations.NotNull;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.utils.GenUtils;

import java.util.Random;

public enum CaveClusterRegistry {
LUSH(9527213,
TConfigOption.BIOME_CAVE_LUSHCLUSTER_SEPARATION.getInt(),
TConfigOption.BIOME_CAVE_LUSHCLUSTER_MAXPERTUB.getFloat()
TConfig.c.BIOME_CAVE_LUSHCLUSTER_SEPARATION,
(float)TConfig.c.BIOME_CAVE_LUSHCLUSTER_MAXPERTUB
), DRIPSTONE(5902907,
TConfigOption.BIOME_CAVE_DRIPSTONECLUSTER_SEPARATION.getInt(),
TConfigOption.BIOME_CAVE_DRIPSTONECLUSTER_MAXPERTUB.getFloat()
TConfig.c.BIOME_CAVE_DRIPSTONECLUSTER_SEPARATION,
(float)TConfig.c.BIOME_CAVE_DRIPSTONECLUSTER_MAXPERTUB
), CRYSTALLINE(4427781,
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_SEPARATION.getInt(),
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_MAXPERTUB.getFloat()
TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_SEPARATION,
(float)TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_MAXPERTUB
), FLUID(79183628, 40, 0.2f),
;

Expand All @@ -32,20 +32,20 @@ public enum CaveClusterRegistry {
public @NotNull AbstractCaveClusterPopulator getPopulator(@NotNull Random random) {
return switch (this) {
case LUSH -> new LushClusterCavePopulator(GenUtils.randInt(random,
TConfigOption.BIOME_CAVE_LUSHCLUSTER_MINSIZE.getInt(),
TConfigOption.BIOME_CAVE_LUSHCLUSTER_MAXSIZE.getInt()
TConfig.c.BIOME_CAVE_LUSHCLUSTER_MINSIZE,
TConfig.c.BIOME_CAVE_LUSHCLUSTER_MAXSIZE
), false);
case DRIPSTONE -> new DripstoneClusterCavePopulator(GenUtils.randInt(random,
TConfigOption.BIOME_CAVE_DRIPSTONECLUSTER_MINSIZE.getInt(),
TConfigOption.BIOME_CAVE_DRIPSTONECLUSTER_MAXSIZE.getInt()
TConfig.c.BIOME_CAVE_DRIPSTONECLUSTER_MINSIZE,
TConfig.c.BIOME_CAVE_DRIPSTONECLUSTER_MAXSIZE
));
case CRYSTALLINE -> new CrystallineClusterCavePopulator(GenUtils.randInt(random,
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_MINSIZE.getInt(),
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_MAXSIZE.getInt()
TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_MINSIZE,
TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_MAXSIZE
));
case FLUID -> new CaveFluidClusterPopulator(GenUtils.randInt(random,
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_MINSIZE.getInt(),
TConfigOption.BIOME_CAVE_CRYSTALLINECLUSTER_MAXSIZE.getInt()
TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_MINSIZE,
TConfig.c.BIOME_CAVE_CRYSTALLINECLUSTER_MAXSIZE
));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.terraform.data.SimpleBlock;
import org.terraform.data.TerraformWorld;
import org.terraform.main.TerraformGeneratorPlugin;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.tree.TreeDB;
import org.terraform.utils.BlockUtils;
Expand Down Expand Up @@ -128,7 +128,7 @@ public void oneUnit(@NotNull TerraformWorld tw,
}
}
else if (Version.isAtLeast(17) && GenUtils.chance(random, 1, 7)) { // Dripleaves
if (TConfigOption.arePlantsEnabled()) {
if (TConfig.arePlantsEnabled()) {
if (random.nextBoolean()) {
new DirectionalBuilder(Material.BIG_DRIPLEAF).setFacing(BlockUtils.getDirectBlockFace(random))
.apply(floor.getUp());
Expand Down Expand Up @@ -178,7 +178,7 @@ else if (GenUtils.chance(random, 1, 7))

if (BlockUtils.isStoneLike(rel.getType())) {
rel.setType(Material.MOSS_BLOCK);
if (TConfigOption.arePlantsEnabled() && BlockUtils.isAir(target.getType()) && GenUtils.chance(
if (TConfig.arePlantsEnabled() && BlockUtils.isAir(target.getType()) && GenUtils.chance(
random,
1,
5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.terraform.data.SimpleBlock;
import org.terraform.data.SimpleLocation;
import org.terraform.data.TerraformWorld;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.tree.FractalTreeBuilder;
import org.terraform.tree.FractalTypes;
Expand Down Expand Up @@ -119,7 +119,7 @@ public void populateSmallItems(TerraformWorld world,
// If an underside was valid, you can check the upper area for
// decorating overhangs
for (BlockFace face : BlockUtils.directBlockFaces) {
if (TConfigOption.arePlantsEnabled() && target.getRelative(face).getType() == Material.AIR) {
if (TConfig.arePlantsEnabled() && target.getRelative(face).getType() == Material.AIR) {
if (GenUtils.chance(random, 1, 5))
// TODO:PlantBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.terraform.coregen.bukkit.TerraformGenerator;
import org.terraform.coregen.populatordata.PopulatorDataAbstract;
import org.terraform.data.TerraformWorld;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.utils.BlockUtils;
import org.terraform.utils.GenUtils;
Expand All @@ -27,11 +27,11 @@
import java.util.Random;

public class BadlandsHandler extends BiomeHandler {
static final int sandRadius = TConfigOption.BIOME_BADLANDS_PLATEAU_SAND_RADIUS.getInt();
static final int plateauHeight = TConfigOption.BIOME_BADLANDS_PLATEAU_HEIGHT.getInt();
static final float plateauFrequency = TConfigOption.BIOME_BADLANDS_PLATEAU_FREQUENCY.getFloat();
static final double plateauThreshold = TConfigOption.BIOME_BADLANDS_PLATEAU_THRESHOLD.getDouble();
static final double plateauCommonness = TConfigOption.BIOME_BADLANDS_PLATEAU_COMMONNESS.getDouble();
static final int sandRadius = TConfig.c.BIOME_BADLANDS_PLATEAU_SAND_RADIUS;
static final int plateauHeight = TConfig.c.BIOME_BADLANDS_PLATEAU_HEIGHT;
static final float plateauFrequency = TConfig.c.BIOME_BADLANDS_PLATEAU_FREQUENCY;
static final double plateauThreshold = TConfig.c.BIOME_BADLANDS_PLATEAU_THRESHOLD;
static final double plateauCommonness = TConfig.c.BIOME_BADLANDS_PLATEAU_COMMONNESS;
static private BiomeBlender riversBlender;
static private BiomeBlender plateauBlender;

Expand Down Expand Up @@ -324,7 +324,7 @@ else if ((int) graduated * plateauHeight == y + 2) {
}

void spawnDeadTree(@NotNull PopulatorDataAbstract data, int x, int y, int z) {
if (!TConfigOption.areTreesEnabled()) {
if (!TConfig.areTreesEnabled()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.terraform.coregen.populatordata.PopulatorDataAbstract;
import org.terraform.data.SimpleBlock;
import org.terraform.data.TerraformWorld;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.utils.BlockUtils;
import org.terraform.utils.GenUtils;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void populateLargeItems(TerraformWorld tw, @NotNull Random random, @NotNu
if (data.getType(x, y, z) == Material.GRASS_BLOCK || data.getType(x, y, z) == Material.PODZOL) {

// Small grass poffs
if (TConfigOption.arePlantsEnabled() && GenUtils.chance(random, 1, 50)) {
if (TConfig.arePlantsEnabled() && GenUtils.chance(random, 1, 50)) {
BlockUtils.replaceSphere(random.nextInt(424444),
2,
3,
Expand All @@ -117,7 +117,7 @@ public void populateLargeItems(TerraformWorld tw, @NotNull Random random, @NotNu
}

// Bamboo
if (TConfigOption.arePlantsEnabled()
if (TConfig.arePlantsEnabled()
&& GenUtils.chance(random, 1, 3)
&& BlockUtils.isDirtLike(data.getType(x, y, z)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.terraform.data.SimpleLocation;
import org.terraform.data.TerraformWorld;
import org.terraform.data.Wall;
import org.terraform.main.config.TConfigOption;
import org.terraform.main.config.TConfig;
import org.terraform.small_items.PlantBuilder;
import org.terraform.tree.FractalTreeBuilder;
import org.terraform.tree.FractalTypes;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void populateSmallItems(TerraformWorld world,
if (GenUtils.chance(random, 2, 10)) { // Grass
if (GenUtils.chance(random, 8, 10)) {
// Pink petals. No longer generate tall grass.
if (Version.isAtLeast(20) && TConfigOption.arePlantsEnabled() && GenUtils.chance(random, 6, 10)) {
if (Version.isAtLeast(20) && TConfig.arePlantsEnabled() && GenUtils.chance(random, 6, 10)) {
data.setBlockData(
rawX,
surfaceY + 1,
Expand Down
Loading