feat: option to enable farlands

This commit is contained in:
Timo Ley 2023-01-17 09:25:09 +01:00
parent b873e2129e
commit 190f8e3c62
4 changed files with 69 additions and 2 deletions

View file

@ -24,7 +24,7 @@ apply from: './gradle/scripts/mixins.gradle'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.4.0"
version = "1.5.0"
group= "dev.tilera.modding"
archivesBaseName = "cwg"

View file

@ -15,6 +15,7 @@ public class Config {
public static boolean disableNewFlowers = false;
public static boolean classicExtremeHills = false;
public static boolean disableHeightTemperature = false;
public static boolean enableFarlands = false;
public static void initConfig() {
conf = new Configuration(new File(Loader.instance().getConfigDir(), "ClassicWorldgen.cfg"));
@ -26,6 +27,7 @@ public class Config {
classicExtremeHills = conf.getBoolean("classicExtremeHills", "tweaks", classicExtremeHills, "generate 1.6 extreme hills instead of 1.7");
disableHeightTemperature = conf.getBoolean("disableHeightTemperature", "tweaks", disableHeightTemperature, "disable snow on mountains");
changeWorldTypeCommand = conf.getBoolean("changeTypeCommand", "commands", changeWorldTypeCommand, "enable command to change the WorldType");
enableFarlands = conf.getBoolean("enableFarlands", "tweaks", enableFarlands, "reenable the Farlands!");
conf.save();
}

View file

@ -0,0 +1,63 @@
package dev.tilera.cwg.mixins;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import dev.tilera.cwg.Config;
import net.minecraft.util.MathHelper;
import net.minecraft.world.gen.NoiseGenerator;
import net.minecraft.world.gen.NoiseGeneratorImproved;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
@Mixin(NoiseGeneratorOctaves.class)
public abstract class MixinNoiseGeneratorOctaves extends NoiseGenerator {
@Shadow
private NoiseGeneratorImproved[] generatorCollection;
@Shadow
private int octaves;
/**
* @author tilera
* @reason farlands
*/
@Overwrite
public double[] generateNoiseOctaves(double[] p_76304_1_, int p_76304_2_, int p_76304_3_, int p_76304_4_, int p_76304_5_, int p_76304_6_, int p_76304_7_, double p_76304_8_, double p_76304_10_, double p_76304_12_) {
if (p_76304_1_ == null)
{
p_76304_1_ = new double[p_76304_5_ * p_76304_6_ * p_76304_7_];
}
else
{
for (int k1 = 0; k1 < p_76304_1_.length; ++k1)
{
p_76304_1_[k1] = 0.0D;
}
}
double d6 = 1.0D;
for (int l1 = 0; l1 < this.octaves; ++l1)
{
double d3 = (double)p_76304_2_ * d6 * p_76304_8_;
double d4 = (double)p_76304_3_ * d6 * p_76304_10_;
double d5 = (double)p_76304_4_ * d6 * p_76304_12_;
long i2 = MathHelper.floor_double_long(d3);
long j2 = MathHelper.floor_double_long(d5);
d3 -= (double)i2;
d5 -= (double)j2;
if (!Config.enableFarlands) {
i2 %= 16777216L;
j2 %= 16777216L;
}
d3 += (double)i2;
d5 += (double)j2;
this.generatorCollection[l1].populateNoiseArray(p_76304_1_, d3, d4, d5, p_76304_5_, p_76304_6_, p_76304_7_, p_76304_8_ * d6, p_76304_10_ * d6, p_76304_12_ * d6, d6);
d6 /= 2.0D;
}
return p_76304_1_;
}
}

View file

@ -9,7 +9,9 @@
"MixinBiomeGenHills",
"MixinBiomeGenPlains",
"MixinBiomeGenSwamp",
"MixinGenDoublePlant"],
"MixinGenDoublePlant",
"MixinNoiseGeneratorOctaves"
],
"injectors": {
"defaultRequire": 1
}