feat: option system changes
All checks were successful
ci/woodpecker/tag/central-override Pipeline was successful
All checks were successful
ci/woodpecker/tag/central-override Pipeline was successful
This commit is contained in:
parent
58164c7554
commit
55c39659af
8 changed files with 35 additions and 14 deletions
|
@ -1,6 +1,8 @@
|
|||
package dev.tilera.cwg.classic;
|
||||
|
||||
import dev.tilera.cwg.api.CwgGlobals;
|
||||
import dev.tilera.cwg.api.hooks.IHookProvider;
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
|
||||
import dev.tilera.cwg.hooks.ICavegenHook;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.SpawnerAnimals;
|
||||
|
@ -17,8 +19,13 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType
|
|||
|
||||
public class ChunkProviderClassic extends ChunkProviderGenerate {
|
||||
|
||||
public ChunkProviderClassic(World world, long seed, boolean features) {
|
||||
private IGeneratorOptionProvider options;
|
||||
|
||||
public ChunkProviderClassic(World world, long seed, boolean features, IGeneratorOptionProvider options) {
|
||||
super(world, seed, features);
|
||||
this.options = options;
|
||||
ICavegenHook hook = options.getValue("cwg:cavegen_hook", IHookProvider.class).getHook(ICavegenHook.class);
|
||||
hook.setCavegen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +40,7 @@ public class ChunkProviderClassic extends ChunkProviderGenerate {
|
|||
this.rand.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed());
|
||||
boolean flag = false;
|
||||
|
||||
if (CwgGlobals.getOptionProvider(worldObj).getBoolean("cwg:generator.classic:enableModdedWorldgen")) {
|
||||
if (options.getBoolean("cwg:generator.classic:enableModdedWorldgen")) {
|
||||
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
|
||||
}
|
||||
|
||||
|
@ -70,7 +77,7 @@ public class ChunkProviderClassic extends ChunkProviderGenerate {
|
|||
}
|
||||
}
|
||||
|
||||
boolean doGen = !CwgGlobals.getOptionProvider(worldObj).getBoolean("cwg:generator.classic:enableModdedWorldgen") || TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, EventType.DUNGEON);
|
||||
boolean doGen = !options.getBoolean("cwg:generator.classic:enableModdedWorldgen") || 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;
|
||||
|
@ -106,7 +113,7 @@ public class ChunkProviderClassic extends ChunkProviderGenerate {
|
|||
}
|
||||
}
|
||||
|
||||
if (CwgGlobals.getOptionProvider(worldObj).getBoolean("cwg:generator.classic:enableModdedWorldgen")) {
|
||||
if (options.getBoolean("cwg:generator.classic:enableModdedWorldgen")) {
|
||||
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag));
|
||||
}
|
||||
|
||||
|
@ -114,7 +121,7 @@ public class ChunkProviderClassic extends ChunkProviderGenerate {
|
|||
}
|
||||
|
||||
public boolean hasDesertLakes() {
|
||||
return CwgGlobals.getOptionProvider(worldObj).getBoolean("cwg:classic_extreme_hills");
|
||||
return options.getBoolean("cwg:classic_extreme_hills");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.tilera.cwg.classic;
|
|||
|
||||
import dev.tilera.cwg.api.generator.AbstractChunkManager;
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
|
||||
import dev.tilera.cwg.api.options.IOption;
|
||||
import dev.tilera.cwg.genlayer.GenLayerAddIslandClassic;
|
||||
import dev.tilera.cwg.genlayer.GenLayerAddSnowClassic;
|
||||
import dev.tilera.cwg.genlayer.GenLayerBiomeClassic;
|
||||
|
@ -93,7 +92,7 @@ public class WorldChunkManagerClassic extends AbstractChunkManager{
|
|||
|
||||
@Override
|
||||
public IChunkProvider getGenerator(World world) {
|
||||
return new ChunkProviderClassic(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled());
|
||||
return new ChunkProviderClassic(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.tilera.cwg.hooks;
|
||||
|
||||
import dev.tilera.cwg.api.hooks.IHookProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
|
||||
public interface ICavegenHook extends IHookProvider {
|
||||
|
@ -9,4 +10,9 @@ public interface ICavegenHook extends IHookProvider {
|
|||
|
||||
MapGenBase createRavineGenerator();
|
||||
|
||||
default void setCavegen(ChunkProviderGenerate generator) {
|
||||
generator.caveGenerator = createCaveGenerator();
|
||||
generator.ravineGenerator = createRavineGenerator();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ public class SwissCavegenHook implements ICavegenHook {
|
|||
|
||||
@Override
|
||||
public MapGenBase createCaveGenerator() {
|
||||
System.out.println("ALECALECALEC");
|
||||
return new MapGenCavesSwiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,13 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
|
||||
|
||||
public class OptionProvider implements IGeneratorOptionProvider {
|
||||
|
||||
private IGeneratorOptionRegistry registry;
|
||||
private IGeneratorOptionProvider registry;
|
||||
private Map<String, Object> storage = new HashMap<>();
|
||||
|
||||
public OptionProvider(IGeneratorOptionRegistry registry) {
|
||||
public OptionProvider(IGeneratorOptionProvider registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@ package dev.tilera.cwg.vanilla;
|
|||
import dev.tilera.cwg.DelegateChunkManager;
|
||||
import dev.tilera.cwg.api.generator.AbstractChunkManager;
|
||||
import dev.tilera.cwg.api.generator.IChunkManagerFactory;
|
||||
import dev.tilera.cwg.api.hooks.IHookProvider;
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
|
||||
import dev.tilera.cwg.api.options.IOption;
|
||||
import dev.tilera.cwg.hooks.ICavegenHook;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.WorldChunkManagerHell;
|
||||
|
@ -15,9 +17,12 @@ public class SingleBiomeChunkManagerFactory implements IChunkManagerFactory {
|
|||
@Override
|
||||
public AbstractChunkManager createChunkManager(IGeneratorOptionProvider options, World world) {
|
||||
int biomeID = options.getInt("cwg:generator.singleBiome:biomeID");
|
||||
ICavegenHook hook = options.getValue("cwg:cavegen_hook", IHookProvider.class).getHook(ICavegenHook.class);
|
||||
ChunkProviderGenerate generator = new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled());
|
||||
hook.setCavegen(generator);
|
||||
return new DelegateChunkManager(
|
||||
options,
|
||||
new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()),
|
||||
generator,
|
||||
new WorldChunkManagerHell(BiomeGenBase.getBiome(biomeID), 1.0f)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package dev.tilera.cwg.vanilla;
|
|||
import dev.tilera.cwg.DelegateChunkManager;
|
||||
import dev.tilera.cwg.api.generator.AbstractChunkManager;
|
||||
import dev.tilera.cwg.api.generator.IChunkManagerFactory;
|
||||
import dev.tilera.cwg.api.hooks.IHookProvider;
|
||||
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
|
||||
import dev.tilera.cwg.api.options.IOption;
|
||||
import dev.tilera.cwg.hooks.ICavegenHook;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.WorldChunkManager;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
|
@ -13,9 +15,12 @@ public class VanillaChunkManagerFactory implements IChunkManagerFactory {
|
|||
|
||||
@Override
|
||||
public AbstractChunkManager createChunkManager(IGeneratorOptionProvider options, World world) {
|
||||
ICavegenHook hook = options.getValue("cwg:cavegen_hook", IHookProvider.class).getHook(ICavegenHook.class);
|
||||
ChunkProviderGenerate generator = new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled());
|
||||
hook.setCavegen(generator);
|
||||
return new DelegateChunkManager(
|
||||
options,
|
||||
new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled()),
|
||||
generator,
|
||||
new WorldChunkManager(world)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,5 +7,6 @@ public net.minecraft.world.gen.ChunkProviderGenerate field_73223_w # mineshaftGe
|
|||
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.ChunkProviderGenerate field_73232_y # ravineGenerator
|
||||
public net.minecraft.world.gen.NoiseGeneratorOctaves field_76306_b # octaves
|
||||
public net.minecraft.world.gen.NoiseGeneratorOctaves field_76307_a # generatorCollection
|
Loading…
Reference in a new issue