feat: mod overhaul
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Ley 2023-02-14 17:53:52 +01:00
parent 5c38b79d9c
commit be1080dc52
15 changed files with 208 additions and 43 deletions

View file

@ -66,7 +66,8 @@ jar {
manifest {
attributes([
"FMLCorePlugin" : "dev.tilera.cwg.core.CWGCorePlugin",
"FMLCorePluginContainsFMLMod": "true"
"FMLCorePluginContainsFMLMod": "true",
"FMLAT": "cwg_at.cfg"
])
}
}

View file

@ -0,0 +1,131 @@
package dev.tilera.cwg;
import dev.tilera.cwg.caves.MapGenCavesSwiss;
import net.minecraft.block.BlockFalling;
import net.minecraft.init.Blocks;
import net.minecraft.world.SpawnerAnimals;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderGenerate;
import net.minecraft.world.gen.feature.WorldGenDungeons;
import net.minecraft.world.gen.feature.WorldGenLakes;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
public class ChunkProviderClassic extends ChunkProviderGenerate {
public ChunkProviderClassic(World world, long seed, boolean features) {
super(world, seed, features);
if (!(this.caveGenerator instanceof MapGenCavesSwiss)) {
this.caveGenerator = new MapGenCavesSwiss();
}
}
@Override
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) {
BlockFalling.fallInstantly = true;
int k = p_73153_2_ * 16;
int l = p_73153_3_ * 16;
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16);
this.rand.setSeed(this.worldObj.getSeed());
long i1 = this.rand.nextLong() / 2L * 2L + 1L;
long j1 = this.rand.nextLong() / 2L * 2L + 1L;
this.rand.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed());
boolean flag = false;
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
if (this.mapFeaturesEnabled)
{
this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, p_73153_2_, p_73153_3_);
flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, p_73153_2_, p_73153_3_);
this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, p_73153_2_, p_73153_3_);
this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, p_73153_2_, p_73153_3_);
}
int k1;
int l1;
int i2;
boolean canGenerteLake = (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills) || this.hasDesertLakes();
if (canGenerteLake && !flag && this.rand.nextInt(4) == 0
&& TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.LAKE))
{
k1 = k + this.rand.nextInt(16) + 8;
l1 = this.rand.nextInt(256);
i2 = l + this.rand.nextInt(16) + 8;
(new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2);
}
if (TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.LAVA) && !flag && this.rand.nextInt(8) == 0)
{
k1 = k + this.rand.nextInt(16) + 8;
l1 = this.rand.nextInt(this.rand.nextInt(248) + 8);
i2 = l + this.rand.nextInt(16) + 8;
if (l1 < 63 || this.rand.nextInt(10) == 0)
{
(new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2);
}
}
boolean doGen = TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.DUNGEON);
for (k1 = 0; doGen && k1 < 8; ++k1)
{
l1 = k + this.rand.nextInt(16) + 8;
i2 = this.rand.nextInt(256);
int j2 = l + this.rand.nextInt(16) + 8;
(new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2);
}
biomegenbase.decorate(this.worldObj, this.rand, k, l);
if (TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.ANIMALS))
{
SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand);
}
k += 8;
l += 8;
doGen = TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.ICE);
for (k1 = 0; doGen && k1 < 16; ++k1)
{
for (l1 = 0; l1 < 16; ++l1)
{
i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1);
if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l))
{
this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2);
}
if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true))
{
this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2);
}
}
}
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
BlockFalling.fallInstantly = false;
}
public boolean hasDesertLakes() {
return Config.enableDesertLakes;
}
public boolean hasNewVanillaBiomes() {
return Config.addNewVanillaBiomes;
}
public boolean hasJungles() {
return !Config.disableJungle;
}
public boolean hasModdedBiomes() {
return !Config.disableModdedBiomes;
}
}

View file

@ -8,12 +8,18 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import dev.tilera.cwg.caves.MapGenCavesSwiss;
import dev.tilera.cwg.command.CommandChangeWorld;
import dev.tilera.cwg.noisegen.NoiseGeneratorOctavesFarlands;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.NoiseGenerator;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.InitMapGenEvent;
import net.minecraftforge.event.terraingen.InitNoiseGensEvent;
@Mod(modid = Constants.ID, name = Constants.NAME, version = Constants.VERSION)
@Mod(modid = Constants.ID, name = Constants.NAME, version = Constants.VERSION, acceptableRemoteVersions = "*")
public class ClassicWorldgen {
public static final WorldType CLASSIC = new WorldTypeClassic("onesix");
@ -41,10 +47,38 @@ public class ClassicWorldgen {
}
}
@SubscribeEvent
public void onInitNoiseGen(InitNoiseGensEvent event) {
if (Config.enableFarlands) {
NoiseGenerator[] noiseGens = new NoiseGenerator[event.originalNoiseGens.length];
for (int i = 0; i < noiseGens.length; i++) {
if (event.originalNoiseGens[i] instanceof NoiseGeneratorOctaves) {
int octaves = ((NoiseGeneratorOctaves)event.originalNoiseGens[i]).octaves;
noiseGens[i] = new NoiseGeneratorOctavesFarlands(event.rand, octaves);
} else {
noiseGens[i] = event.originalNoiseGens[i];
}
}
event.newNoiseGens = noiseGens;
}
}
@EventHandler
public void onServerLoad(FMLServerStartingEvent event) {
if (Config.changeWorldTypeCommand)
event.registerServerCommand(new CommandChangeWorld());
}
public static boolean isClassicWorld() {
World[] worlds = MinecraftServer.getServer().worldServers;
if (worlds.length == 0) return true;
World world = worlds[0];
if (world == null) return true;
return isClassicWorld(world);
}
public static boolean isClassicWorld(World world) {
return world.getWorldChunkManager() instanceof WorldChunkManagerClassic;
}
}

View file

@ -9,29 +9,25 @@ public class Config {
static Configuration conf;
public static boolean enableSwissCheeseCaves = false;
public static boolean blockNewVanillaBiomes = true;
public static boolean addNewVanillaBiomes = false;
public static boolean changeWorldTypeCommand = false;
public static boolean disableNewFlowers = false;
public static boolean classicExtremeHills = false;
public static boolean disableHeightTemperature = false;
public static boolean enableFarlands = false;
public static boolean disableJungle = false;
public static boolean disableModdedBiomes = false;
public static boolean enableDesertLakes = true;
public static void initConfig() {
conf = new Configuration(new File(Loader.instance().getConfigDir(), "ClassicWorldgen.cfg"));
conf.load();
enableSwissCheeseCaves = conf.getBoolean("enableSwissCheeseCaves", "caves", enableSwissCheeseCaves, "enable classic (1.6) cavegen");
blockNewVanillaBiomes = conf.getBoolean("blockNewVanillaBiomes", "worldgen", blockNewVanillaBiomes, "prevent new 1.7 vanilla biomes from generating with classic/1.6 WorldType");
addNewVanillaBiomes = conf.getBoolean("addNewVanillaBiomes", "worldgen", addNewVanillaBiomes, "generate new 1.7 vanilla biomes with classic/1.6 WorldType");
disableNewFlowers = conf.getBoolean("disableNewFlowers", "tweaks", disableNewFlowers, "prevent new 1.7 flowers from generating in swamps and plains");
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!");
disableJungle = conf.getBoolean("disableJungle", "worldgen", disableJungle, "prevent jungle biomes from generating in classic worldgen");
disableModdedBiomes = conf.getBoolean("disableModdedBiomes", "worldgen", disableModdedBiomes, "prevent modded biomes from generating in classic worldgen");
enableDesertLakes = conf.getBoolean("enableDesertLakes", "worldgen", enableDesertLakes, "enable lakes in desert in classic worldgen");
conf.save();
}

View file

@ -3,6 +3,7 @@ package dev.tilera.cwg;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.chunk.IChunkProvider;
public class WorldTypeClassic extends WorldType {
@ -15,4 +16,9 @@ public class WorldTypeClassic extends WorldType {
return new WorldChunkManagerClassic(world);
}
@Override
public IChunkProvider getChunkGenerator(World world, String generatorOptions) {
return new ChunkProviderClassic(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled());
}
}

View file

@ -52,13 +52,15 @@ public class GenLayerBiomeClassic extends GenLayer {
addedBiomes.add(BiomeGenBase.savannaPlateau);
biomeEntries.add(new BiomeEntry(BiomeGenBase.megaTaiga, 10));
addedBiomes.add(BiomeGenBase.megaTaiga);
biomeEntries.add(new BiomeEntry(BiomeGenBase.icePlains, 10));
addedBiomes.add(BiomeGenBase.icePlains);
}
if (!Config.disableModdedBiomes) {
for (BiomeType t : BiomeType.values()) {
ImmutableList<BiomeEntry> biomesToAdd = BiomeManager.getBiomes(t);
for (BiomeEntry biome : biomesToAdd) {
if ((biome.biome.biomeID < 40 && Config.blockNewVanillaBiomes) || addedBiomes.contains(biome.biome)) continue;
if (biome.biome.biomeID < 40 || addedBiomes.contains(biome.biome)) continue;
addedBiomes.add(biome.biome);
biomeEntries.add(biome);
if (biome.itemWeight != 10) hasBiomeWeights = true;

View file

@ -42,7 +42,7 @@ public abstract class MixinBiomeGenBase {
*/
@Overwrite
public final float getFloatTemperature(int p_150564_1_, int p_150564_2_, int p_150564_3_) {
if (p_150564_2_ > 64 && !Config.disableHeightTemperature) {
if (p_150564_2_ > 64 && !(ClassicWorldgen.isClassicWorld() || Config.classicExtremeHills)) {
float f = (float)temperatureNoise.func_151601_a((double)p_150564_1_ * 1.0D / 8.0D, (double)p_150564_3_ * 1.0D / 8.0D) * 4.0F;
return this.temperature - (f + (float)p_150564_2_ - 64.0F) * 0.05F / 30.0F;
} else {

View file

@ -50,7 +50,7 @@ public abstract class MixinBiomeGenHills extends BiomeGenBase {
*/
@Overwrite(remap = false)
public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) {
if (p_150573_1_.getWorldInfo().getTerrainType() == ClassicWorldgen.CLASSIC || Config.classicExtremeHills) {
if (ClassicWorldgen.isClassicWorld(p_150573_1_) || Config.classicExtremeHills) {
super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_);
} else {
this.topBlock = Blocks.grass;

View file

@ -34,7 +34,7 @@ public abstract class MixinBiomeGenJungle extends BiomeGenBase {
}
int i1 = p_76728_2_.nextInt(height);
if (p_76728_1_.getWorldInfo().getTerrainType() != ClassicWorldgen.CLASSIC)
if (!ClassicWorldgen.isClassicWorld(p_76728_1_))
(new WorldGenMelon()).generate(p_76728_1_, p_76728_2_, k, i1, l);
WorldGenVines worldgenvines = new WorldGenVines();

View file

@ -5,7 +5,7 @@ import java.util.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import dev.tilera.cwg.Config;
import dev.tilera.cwg.ClassicWorldgen;
import net.minecraft.block.BlockFlower;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenPlains;
@ -23,7 +23,7 @@ public abstract class MixinBiomeGenPlains extends BiomeGenBase {
*/
@Overwrite(remap = false)
public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) {
if (!Config.disableNewFlowers) {
if (!ClassicWorldgen.isClassicWorld()) {
double d0 = plantNoise.func_151601_a((double)p_150572_2_ / 200.0D, (double)p_150572_4_ / 200.0D);
int l;
if (d0 < -0.8D) {

View file

@ -5,7 +5,7 @@ import java.util.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import dev.tilera.cwg.Config;
import dev.tilera.cwg.ClassicWorldgen;
import net.minecraft.block.BlockFlower;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenSwamp;
@ -23,7 +23,7 @@ public abstract class MixinBiomeGenSwamp extends BiomeGenBase {
*/
@Overwrite(remap = false)
public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) {
if (!Config.disableNewFlowers) {
if (!ClassicWorldgen.isClassicWorld()) {
return BlockFlower.field_149859_a[1];
}
return super.func_150572_a(p_150572_1_, p_150572_2_, p_150572_3_, p_150572_4_);

View file

@ -26,7 +26,7 @@ public abstract class MixinGenDoublePlant extends WorldGenerator{
public boolean generate(World p_generate_1_, Random p_generate_2_, int p_generate_3_, int p_generate_4_, int p_generate_5_) {
boolean var6 = false;
if (p_generate_1_.getWorldInfo().getTerrainType() != ClassicWorldgen.CLASSIC) {
if (!ClassicWorldgen.isClassicWorld(p_generate_1_)) {
for(int var7 = 0; var7 < 64; ++var7) {
int var8 = p_generate_3_ + p_generate_2_.nextInt(8) - p_generate_2_.nextInt(8);
int var9 = p_generate_4_ + p_generate_2_.nextInt(4) - p_generate_2_.nextInt(4);

View file

@ -1,28 +1,17 @@
package dev.tilera.cwg.mixins;
package dev.tilera.cwg.noisegen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Random;
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;
public class NoiseGeneratorOctavesFarlands extends NoiseGeneratorOctaves {
/**
* @author tilera
* @reason farlands
*/
@Overwrite
public NoiseGeneratorOctavesFarlands(Random rand, int octaves) {
super(rand, octaves);
}
@Override
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)
{
@ -47,10 +36,6 @@ public abstract class MixinNoiseGeneratorOctaves extends NoiseGenerator {
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);
@ -59,5 +44,5 @@ public abstract class MixinNoiseGeneratorOctaves extends NoiseGenerator {
return p_76304_1_;
}
}

View file

@ -0,0 +1,11 @@
public net.minecraft.world.gen.ChunkProviderGenerate field_73230_p # worldObj
public net.minecraft.world.gen.ChunkProviderGenerate field_73220_k # rand
public net.minecraft.world.gen.ChunkProviderGenerate field_73229_q # mapFeaturesEnabled
public net.minecraft.world.gen.ChunkProviderGenerate field_73223_w # mineshaftGenerator
public net.minecraft.world.gen.ChunkProviderGenerate field_73224_v # villageGenerator
public net.minecraft.world.gen.ChunkProviderGenerate field_73223_w # mineshaftGenerator
public net.minecraft.world.gen.ChunkProviderGenerate field_73225_u # strongholdGenerator
public net.minecraft.world.gen.ChunkProviderGenerate field_73233_x # scatteredFeatureGenerator
public net.minecraft.world.gen.ChunkProviderGenerate field_73226_t # caveGenerator
public net.minecraft.world.gen.NoiseGeneratorOctaves field_76306_b # octaves
public net.minecraft.world.gen.NoiseGeneratorOctaves field_76307_a # generatorCollection

View file

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