Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
layout.json
29 changes: 24 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1704650211
//version: 1705357285
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -122,6 +122,7 @@ propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("versionPattern", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
// Deprecated properties (kept for backwards compat)
Expand Down Expand Up @@ -370,6 +371,7 @@ catch (Exception ignored) {
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
boolean checkVersion = false
try {
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
if (versionOverride == null) {
Expand All @@ -388,6 +390,8 @@ try {
}
} else if (isDirty) {
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
} else {
checkVersion = true
}
} else {
identifiedVersion = versionOverride
Expand All @@ -409,6 +413,8 @@ ext {

if (identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
} else if (checkVersion && versionPattern && !(identifiedVersion ==~ versionPattern)) {
throw new GradleException("Invalid version: '$identifiedVersion' does not match version pattern '$versionPattern'")
}

group = "com.github.GTNewHorizons"
Expand All @@ -428,18 +434,31 @@ minecraft {
for (f in replaceGradleTokenInFile.split(',')) {
tagReplacementFiles.add f
}
out.style(Style.Info).text('replaceGradleTokenInFile is deprecated! Consider using generateGradleTokenClass.').println()
}
if (gradleTokenModId) {
injectedTags.put gradleTokenModId, modId
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenModId, modId
} else {
out.style(Style.Failure).text('gradleTokenModId is deprecated! The field will no longer be generated.').println()
}
}
if (gradleTokenModName) {
injectedTags.put gradleTokenModName, modName
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenModName, modName
} else {
out.style(Style.Failure).text('gradleTokenModName is deprecated! The field will no longer be generated.').println()
}
}
if (gradleTokenVersion) {
injectedTags.put gradleTokenVersion, modVersion
}
if (gradleTokenGroupName) {
injectedTags.put gradleTokenGroupName, modGroup
if (replaceGradleTokenInFile) {
injectedTags.put gradleTokenGroupName, modGroup
} else {
out.style(Style.Failure).text('gradleTokenGroupName is deprecated! The field will no longer be generated.').println()
}
}
if (enableGenericInjection.toBoolean()) {
injectMissingGenerics.set(true)
Expand Down Expand Up @@ -786,7 +805,7 @@ dependencies {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.4')
}

java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

dependencies {
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false}

compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.53:dev")
// For Thaumcraft runtime
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.1.16:dev")
}
16 changes: 13 additions & 3 deletions src/main/java/twilightforest/TFFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ public static TFFeature generateFeatureForOldMapGen(int chunkX, int chunkZ, Worl
}

public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World world) {
Copy link

@YannickMG YannickMG Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears this function isn't only used when generating a feature (as its name would suggest) but also when looking up which feature should exist in a given region.

Changing the configurated change post-worldgen affects functionality that check against existing features such as the magic map.

Is this intended? If so you might want to document the caveat that this config isn't meant to be modified on an existing world.
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, definitely need a warning, I was worried that this would happen


// get random value
Random hillRNG = new Random(world.getSeed() + chunkX * 25117L + chunkZ * 151121L);

// Balance major features chance
if (!getRandom(hillRNG, TwilightForestMod.majorFeatureGenChance)) {
return nothing;
}

if (TwilightForestMod.oldMapGen) {
return generateFeatureForOldMapGen(chunkX, chunkZ, world);
}
Expand All @@ -389,8 +398,6 @@ public static TFFeature generateFeatureFor1Point7(int chunkX, int chunkZ, World
// what biome is at the center of the chunk?
BiomeGenBase biomeAt = world.getBiomeGenForCoords((chunkX << 4) + 8, (chunkZ << 4) + 8);

// get random value
Random hillRNG = new Random(world.getSeed() + chunkX * 25117L + chunkZ * 151121L);
int randnum = hillRNG.nextInt(16);

// glaciers have ice towers
Expand Down Expand Up @@ -547,7 +554,6 @@ public static TFFeature getFeatureForRegion(int chunkX, int chunkZ, World world)
*
* @param cx
* @param cz
* @param seed
* @return
*/
public static int[] getNearestCenter(int cx, int cz, World world) {
Expand Down Expand Up @@ -895,4 +901,8 @@ public ItemStack createHintBook() {
return book;
}

public static boolean getRandom(Random r, double chanceMul) {
return ((r.nextDouble() * 100d) < chanceMul);

}
}
76 changes: 76 additions & 0 deletions src/main/java/twilightforest/TwilightForestMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import twilightforest.biomes.TFBiomeBase;
import twilightforest.block.TFBlocks;
import twilightforest.entity.TFCreatures;
import twilightforest.gt_integration.GT_Integration_Utils;
import twilightforest.item.BehaviorTFMobEggDispense;
import twilightforest.item.ItemTFMagicMap;
import twilightforest.item.ItemTFMazeMap;
Expand All @@ -53,6 +54,7 @@
import twilightforest.tileentity.TileEntityTFTowerBossSpawner;
import twilightforest.tileentity.TileEntityTFTowerBuilder;
import twilightforest.tileentity.TileEntityTFTrophy;
import twilightforest.world.TFGenCaveStalactite;
import twilightforest.world.WorldProviderTwilightForest;

@Mod(modid = TwilightForestMod.ID, name = "The Twilight Forest", version = TwilightForestMod.VERSION)
Expand Down Expand Up @@ -89,6 +91,34 @@ public class TwilightForestMod {
public static float canopyCoverage;
public static int twilightOakChance;

// Ore Balance

public static double stalactiteOrePopulationDensity = 75;
public static boolean gregifyStalactiteOres;

public static boolean diamondOreStal;
public static boolean lapisOreStal;
public static boolean emeraldOreStal;
public static boolean goldOreStal;
public static boolean redstoneOreStal;
public static boolean ironOreStal;
public static boolean coalOreStal;
public static boolean glowstoneStal;

public static boolean GT_useSmallOres;

public static int GT_diamondOreMeta;
public static int GT_lapisOreMeta;
public static int GT_emeraldOreMeta;
public static int GT_goldOreMeta;
public static int GT_redstoneOreMeta;
public static int GT_ironOreMeta;
public static int GT_coalOreMeta;

// Major feature spawn chance
public static double majorFeatureGenChance = 100;
public static double minorFeatureGenChance = 100;

public static int idMobWildBoar;
public static int idMobBighornSheep;
public static int idMobWildDeer;
Expand Down Expand Up @@ -320,6 +350,16 @@ public void postInit(FMLPostInitializationEvent evt) {
FMLLog.info("[TwilightForest] Did not find Thaumcraft, did not load ThaumcraftApi integration.");
}

// GT Ore
if (Loader.isModLoaded("gregtech") && gregifyStalactiteOres) {
// Doing
GT_Integration_Utils.init();
} else {
FMLLog.warning("[TwilightForest] Did not load Gregtech integration.");
// Disable
gregifyStalactiteOres = false;
}

// final check for biome ID conflicts
TwilightForestMod.hasBiomeIdConflicts = TFBiomeBase.areThereBiomeIdConflicts();
}
Expand Down Expand Up @@ -926,6 +966,42 @@ private void loadConfiguration(Configuration configFile) {
"TwilightOakChance",
48).comment = "Chance that a chunk in the Twilight Forest will contain a twilight oak tree. Higher numbers reduce the number of trees, increasing performance.";

// Ore in Stalactites
// Toggle gen

diamondOreStal = configFile.get("Stalactites", "Diamond Ore Stalactites", true).getBoolean(true);
lapisOreStal = configFile.get("Stalactites", "Lapis Ore Stalactites", true).getBoolean(true);
emeraldOreStal = configFile.get("Stalactites", "Emerald Ore Stalactites", true).getBoolean(true);
goldOreStal = configFile.get("Stalactites", "Gold Ore Stalactites", true).getBoolean(true);
redstoneOreStal = configFile.get("Stalactites", "Redstone Ore Stalactites", true).getBoolean(true);
ironOreStal = configFile.get("Stalactites", "Iron Ore Stalactites", true).getBoolean(true);
coalOreStal = configFile.get("Stalactites", "Coal Ore Stalactites", true).getBoolean(true);
glowstoneStal = configFile.get("Stalactites", "Glowstone Stalactites", true).getBoolean(true);

// Toggle ore
TFGenCaveStalactite.configStalactites();

gregifyStalactiteOres = configFile.get("Stalactites", "Use Gregified ores", false).getBoolean(false);

if (gregifyStalactiteOres) {
// GT Ore Mapping
// Show More config
GT_useSmallOres = configFile.get("GT_OreMapping", "GT_UseSmallOres", false).getBoolean(false);
GT_coalOreMeta = configFile.get("GT_OreMapping", "GT_coalOreMeta", 535).getInt();
GT_lapisOreMeta = configFile.get("GT_OreMapping", "GT_lapisOreMeta", 526).getInt();
GT_redstoneOreMeta = configFile.get("GT_OreMapping", "GT_redstoneOreMeta", 810).getInt();
GT_emeraldOreMeta = configFile.get("GT_OreMapping", "GT_emeraldOreMeta", 501).getInt();
GT_diamondOreMeta = configFile.get("GT_OreMapping", "GT_diamondOreMeta", 500).getInt();
GT_ironOreMeta = configFile.get("GT_OreMapping", "GT_ironOreMeta", 32).getInt();
GT_goldOreMeta = configFile.get("GT_OreMapping", "GT_goldOreMeta", 86).getInt();

}

// Gen chance
majorFeatureGenChance = configFile.get("WorldGen", "Major Feature Generation Chance", 100).getDouble(100);
minorFeatureGenChance = configFile.get("WorldGen", "Minor Feature Generation Chance", 100).getDouble(100);
stalactiteOrePopulationDensity = configFile.get("WorldGen", "Ore density in stalactites", 100).getDouble(100);

// fixed values, don't even read the config
idMobWildBoar = 177;
idMobBighornSheep = 178;
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/twilightforest/biomes/TFBiomeDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ protected void genDecorations(BiomeGenBase biome) {
}

// random features!
if (randomGenerator.nextInt(6) == 0) {
int rx = chunk_X + randomGenerator.nextInt(16) + 8;
int rz = chunk_Z + randomGenerator.nextInt(16) + 8;
int ry = currentWorld.getHeightValue(rx, rz);
if (ry < 75) {
TFGenerator rf = randomFeature(randomGenerator);
rf.generate(currentWorld, randomGenerator, rx, ry, rz);
// now with chance

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "now" part of "now with chance" isn't going to be very helpful to future readers of the code, for which that comment will always have been there.

If the intent of the comment is to indicate that there's a chance of the feature not happening then you might want to encode that knowledge about the code's intent into a well named function instead.

if (TFFeature.getRandom(randomGenerator, TwilightForestMod.minorFeatureGenChance)) {
if (randomGenerator.nextInt(6) == 0) {
int rx = chunk_X + randomGenerator.nextInt(16) + 8;
int rz = chunk_Z + randomGenerator.nextInt(16) + 8;
int ry = currentWorld.getHeightValue(rx, rz);
if (ry < 75) {
TFGenerator rf = randomFeature(randomGenerator);
rf.generate(currentWorld, randomGenerator, rx, ry, rz);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new minorFeatureGenChance config option now compounds with an existing 1 in 7 chance of generating a minor feature. This makes the config option a bit misleading and limits our ability to do things such as making minor features more common.

Would it be possible to combine these random chances, such as by using 1/7 (~14.25%) as the default value of the config option?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think it’s logical to combine and leave the default 14% in the config

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package twilightforest.gt_integration;

import net.minecraft.block.Block;
import net.minecraft.world.World;

public class GT_Integration_Utils {

static GT_OrePlacer orePlacer;

public static void init() {
// Create worker obj
orePlacer = new GT_OrePlacer();

}

public static boolean isInit() {
return orePlacer != null;
}

public static boolean doPlaceGTOre(World aWorld, int aX, int aY, int aZ, Block mcOreBlock) {
if (!isInit()) {
return false;
}
return orePlacer.placeGTOre(aWorld, aX, aY, aZ, mcOreBlock);
}

public static GT_OrePlacer getOrePlacer() {
return orePlacer;
}

}
Comment on lines 1 to 27

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should reduce the visibility of this class's members.

orePlacer and isInit can be private, getOrePlacer is not used and should be removed (or used).

54 changes: 54 additions & 0 deletions src/main/java/twilightforest/gt_integration/GT_OrePlacer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package twilightforest.gt_integration;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;

import gregtech.common.blocks.GT_TileEntity_Ores;
import twilightforest.TwilightForestMod;

public class GT_OrePlacer {

public int getMappedGTMetaForOre(Block mOre) {
Comment on lines +1 to +12

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getMappedGTMetaForOre should be private, and if you remove GT_Integration_Utils::getOrePlacer then all of GT_OrePlacer can be package private instead of public to hide your implementation details.


if (mOre == Blocks.coal_ore) {
return TwilightForestMod.GT_coalOreMeta;
}

if (mOre == Blocks.iron_ore) {
return TwilightForestMod.GT_ironOreMeta;

}
if (mOre == Blocks.gold_ore) {
return TwilightForestMod.GT_goldOreMeta;
}

if (mOre == Blocks.redstone_ore) {
return TwilightForestMod.GT_redstoneOreMeta;
}

if (mOre == Blocks.lapis_ore) {
return TwilightForestMod.GT_lapisOreMeta;
}

if (mOre == Blocks.emerald_ore) {
return TwilightForestMod.GT_emeraldOreMeta;
}
if (mOre == Blocks.diamond_ore) {
return TwilightForestMod.GT_diamondOreMeta;
}

return -1;
}

public boolean placeGTOre(World aWorld, int aX, int aY, int aZ, Block mcOreBlock) {

int mappedMeta = getMappedGTMetaForOre(mcOreBlock);
if (mappedMeta <= 0) {
return false;
}
return GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, mappedMeta, TwilightForestMod.GT_useSmallOres, true);

}

}
Loading