- only apply custom redwood trees to minecraft biomes
- added options to use other mods' generators for nether/end - added options to change bedrock material, depth, and variance
This commit is contained in:
parent
151fc67284
commit
6f0f8efeba
@ -33,6 +33,7 @@ import com.terraforged.mod.chunk.TerraContext;
|
|||||||
import com.terraforged.mod.chunk.TerraGenSettings;
|
import com.terraforged.mod.chunk.TerraGenSettings;
|
||||||
import com.terraforged.mod.chunk.test.TestChunkGenerator;
|
import com.terraforged.mod.chunk.test.TestChunkGenerator;
|
||||||
import com.terraforged.mod.gui.SettingsScreen;
|
import com.terraforged.mod.gui.SettingsScreen;
|
||||||
|
import com.terraforged.mod.settings.DimesionSettings;
|
||||||
import com.terraforged.mod.settings.SettingsHelper;
|
import com.terraforged.mod.settings.SettingsHelper;
|
||||||
import com.terraforged.mod.settings.TerraSettings;
|
import com.terraforged.mod.settings.TerraSettings;
|
||||||
import com.terraforged.mod.util.Environment;
|
import com.terraforged.mod.util.Environment;
|
||||||
@ -46,6 +47,7 @@ import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings;
|
|||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.gen.ChunkGenerator;
|
import net.minecraft.world.gen.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.OverworldGenSettings;
|
import net.minecraft.world.gen.OverworldGenSettings;
|
||||||
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@ -66,27 +68,14 @@ public class TerraWorld extends WorldType {
|
|||||||
TerraWorld.types.add(this);
|
TerraWorld.types.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getHorizon(World world) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getCloudHeight() {
|
|
||||||
return 260.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkGenerator<?> createChunkGenerator(World world) {
|
public ChunkGenerator<?> createChunkGenerator(World world) {
|
||||||
if (world.getDimension().getType() != DimensionType.OVERWORLD) {
|
if (world.getDimension().getType() == DimensionType.OVERWORLD) {
|
||||||
return world.getDimension().createChunkGenerator();
|
WorldInfo info = world.getWorldInfo();
|
||||||
}
|
int version = SettingsHelper.getVersion(info);
|
||||||
|
TerraSettings settings = SettingsHelper.getSettings(info);
|
||||||
Log.debug("Creating {} generator", world.getDimension().getType());
|
|
||||||
|
|
||||||
int version = SettingsHelper.getVersion(world.getWorldInfo());
|
|
||||||
TerraSettings settings = SettingsHelper.getSettings(world);
|
|
||||||
SettingsHelper.syncSettings(world.getWorldInfo(), settings, version);
|
SettingsHelper.syncSettings(world.getWorldInfo(), settings, version);
|
||||||
|
settings.dimensions.dimensionGenerators.apply(world.getWorldInfo());
|
||||||
|
|
||||||
Terrains terrains = Terrains.create(settings);
|
Terrains terrains = Terrains.create(settings);
|
||||||
|
|
||||||
@ -98,7 +87,33 @@ public class TerraWorld extends WorldType {
|
|||||||
TerraContext context = new TerraContext(world, terrains, settings);
|
TerraContext context = new TerraContext(world, terrains, settings);
|
||||||
BiomeProvider biomeProvider = new BiomeProvider(context);
|
BiomeProvider biomeProvider = new BiomeProvider(context);
|
||||||
|
|
||||||
return getGeneratorFactory().create(context, biomeProvider, genSettings);
|
Log.debug("Creating Terra {} generator", world.getDimension().getType().getRegistryName());
|
||||||
|
return factory.create(context, biomeProvider, genSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world.getDimension().getType() == DimensionType.THE_NETHER) {
|
||||||
|
WorldType type = DimesionSettings.getWorldType(world.getWorldInfo(), DimensionType.THE_NETHER);
|
||||||
|
Log.debug("Creating {} {} generator", type.getName(), world.getDimension().getType().getRegistryName());
|
||||||
|
return type.createChunkGenerator(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world.getDimension().getType() == DimensionType.THE_END) {
|
||||||
|
WorldType type = DimesionSettings.getWorldType(world.getWorldInfo(), DimensionType.THE_END);
|
||||||
|
Log.debug("Creating {} {} generator", type.getName(), world.getDimension().getType().getRegistryName());
|
||||||
|
return type.createChunkGenerator(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.createChunkGenerator(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getHorizon(World world) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getCloudHeight() {
|
||||||
|
return 260.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -107,10 +122,6 @@ public class TerraWorld extends WorldType {
|
|||||||
mc.displayGuiScreen(new SettingsScreen(gui));
|
mc.displayGuiScreen(new SettingsScreen(gui));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkGeneratorFactory<?> getGeneratorFactory() {
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
Log.info("Registered world type");
|
Log.info("Registered world type");
|
||||||
new TerraWorld("terraforged", TerraChunkGenerator::new);
|
new TerraWorld("terraforged", TerraChunkGenerator::new);
|
||||||
@ -120,9 +131,13 @@ public class TerraWorld extends WorldType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isTerraType(WorldType type) {
|
||||||
|
return types.contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isTerraWorld(IWorld world) {
|
public static boolean isTerraWorld(IWorld world) {
|
||||||
if (world instanceof World) {
|
if (world instanceof World) {
|
||||||
return types.contains(((World) world).getWorldType());
|
return isTerraType(((World) world).getWorldType());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,21 +25,24 @@
|
|||||||
|
|
||||||
package com.terraforged.mod.biome.provider;
|
package com.terraforged.mod.biome.provider;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.Biomes;
|
import net.minecraftforge.common.BiomeDictionary;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.provider.BiomeProvider {
|
public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.provider.BiomeProvider {
|
||||||
|
|
||||||
protected static final Set<Biome> defaultBiomes = ImmutableSet.of(Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.MOUNTAIN_EDGE, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU, Biomes.WARM_OCEAN, Biomes.LUKEWARM_OCEAN, Biomes.COLD_OCEAN, Biomes.DEEP_WARM_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_FROZEN_OCEAN, Biomes.SUNFLOWER_PLAINS, Biomes.DESERT_LAKES, Biomes.GRAVELLY_MOUNTAINS, Biomes.FLOWER_FOREST, Biomes.TAIGA_MOUNTAINS, Biomes.SWAMP_HILLS, Biomes.ICE_SPIKES, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.DARK_FOREST_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MODIFIED_BADLANDS_PLATEAU);
|
|
||||||
|
|
||||||
public AbstractBiomeProvider() {
|
public AbstractBiomeProvider() {
|
||||||
super(defaultBiomes);
|
super(getOverworldBiomes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Biome> getAvailableBiomes() {
|
||||||
|
return super.field_226837_c_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,4 +58,11 @@ public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.pr
|
|||||||
public abstract Set<Biome> getBiomesInSquare(int x, int y, int z, int size);
|
public abstract Set<Biome> getBiomesInSquare(int x, int y, int z, int size);
|
||||||
|
|
||||||
public abstract BlockPos findBiomePosition(int centerX, int centerY, int centerZ, int range, List<Biome> biomes, Random random);
|
public abstract BlockPos findBiomePosition(int centerX, int centerY, int centerZ, int range, List<Biome> biomes, Random random);
|
||||||
|
|
||||||
|
private static Set<Biome> getOverworldBiomes() {
|
||||||
|
return ForgeRegistries.BIOMES.getValues().stream()
|
||||||
|
.map(biome -> biome.delegate.get())
|
||||||
|
.filter(biome -> BiomeDictionary.getTypes(biome).contains(BiomeDictionary.Type.OVERWORLD))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,10 +139,10 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasStructure(Structure<?> structureIn) {
|
public boolean hasStructure(Structure<?> structure) {
|
||||||
return this.hasStructureCache.computeIfAbsent(structureIn, (p_205006_1_) -> {
|
return this.hasStructureCache.computeIfAbsent(structure, (name) -> {
|
||||||
for (Biome biome : defaultBiomes) {
|
for (Biome biome : getAvailableBiomes()) {
|
||||||
if (biome.hasStructure(p_205006_1_)) {
|
if (biome.hasStructure(name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
@Override
|
@Override
|
||||||
public Set<BlockState> getSurfaceBlocks() {
|
public Set<BlockState> getSurfaceBlocks() {
|
||||||
if (this.topBlocksCache.isEmpty()) {
|
if (this.topBlocksCache.isEmpty()) {
|
||||||
for (Biome biome : defaultBiomes) {
|
for (Biome biome : getAvailableBiomes()) {
|
||||||
this.topBlocksCache.add(biome.getSurfaceBuilderConfig().getTop());
|
this.topBlocksCache.add(biome.getSurfaceBuilderConfig().getTop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,12 +368,13 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
Log.info(" - Geology decorator enabled");
|
Log.info(" - Geology decorator enabled");
|
||||||
processors.add(new GeologyDecorator(geologyManager));
|
processors.add(new GeologyDecorator(geologyManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.terraSettings.features.erosionDecorator) {
|
if (context.terraSettings.features.erosionDecorator) {
|
||||||
Log.info(" - Erosion decorator enabled");
|
Log.info(" - Erosion decorator enabled");
|
||||||
processors.add(new ErosionDecorator(context));
|
processors.add(new ErosionDecorator(context));
|
||||||
}
|
}
|
||||||
processors.add(new CoastDecorator(context));
|
processors.add(new CoastDecorator(context));
|
||||||
processors.add(new BedrockDecorator());
|
processors.add(new BedrockDecorator(context));
|
||||||
return processors;
|
return processors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,16 +28,44 @@ package com.terraforged.mod.decorator.base;
|
|||||||
import com.terraforged.api.chunk.column.ColumnDecorator;
|
import com.terraforged.api.chunk.column.ColumnDecorator;
|
||||||
import com.terraforged.api.chunk.column.DecoratorContext;
|
import com.terraforged.api.chunk.column.DecoratorContext;
|
||||||
import com.terraforged.api.material.state.States;
|
import com.terraforged.api.material.state.States;
|
||||||
|
import com.terraforged.mod.chunk.TerraContext;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class BedrockDecorator implements ColumnDecorator {
|
public class BedrockDecorator implements ColumnDecorator {
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final int minDepth;
|
||||||
|
private final int variance;
|
||||||
|
private final BlockState material;
|
||||||
|
|
||||||
|
public BedrockDecorator(TerraContext context) {
|
||||||
|
minDepth = context.terraSettings.dimensions.baseLayer.minDepth;
|
||||||
|
variance = context.terraSettings.dimensions.baseLayer.variance;
|
||||||
|
material = getState(context.terraSettings.dimensions.baseLayer.material);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
public void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z) {
|
||||||
fillDown(context, chunk, x, z, 1 + random.nextInt(4), -1, States.BEDROCK.get());
|
if (variance <= 0) {
|
||||||
|
fillDown(context, chunk, x, z, minDepth - 1, -1, material);
|
||||||
|
} else {
|
||||||
|
fillDown(context, chunk, x, z, minDepth + ThreadLocalRandom.current().nextInt(variance), -1, material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockState getState(String name) {
|
||||||
|
ResourceLocation location = ResourceLocation.tryCreate(name);
|
||||||
|
if (location != null && ForgeRegistries.BLOCKS.containsKey(location)) {
|
||||||
|
Block block = ForgeRegistries.BLOCKS.getValue(location);
|
||||||
|
if (block != null) {
|
||||||
|
return block.getDefaultState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return States.BEDROCK.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,16 @@ public class ScrollPane extends AbstractOptionList<ScrollPane.Entry> implements
|
|||||||
return option.mouseReleased(x, y, button);
|
return option.mouseReleased(x, y, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyPressed(int i, int j, int k) {
|
||||||
|
return option.keyPressed(i, j, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean charTyped(char c, int code) {
|
||||||
|
return option.charTyped(c, code);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean wut, float partialTicks) {
|
public void render(int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean wut, float partialTicks) {
|
||||||
int optionWidth = Math.min(396, width);
|
int optionWidth = Math.min(396, width);
|
||||||
|
@ -28,6 +28,7 @@ package com.terraforged.mod.gui;
|
|||||||
import com.terraforged.mod.gui.element.TerraButton;
|
import com.terraforged.mod.gui.element.TerraButton;
|
||||||
import com.terraforged.mod.gui.element.TerraLabel;
|
import com.terraforged.mod.gui.element.TerraLabel;
|
||||||
import com.terraforged.mod.gui.page.ClimatePage;
|
import com.terraforged.mod.gui.page.ClimatePage;
|
||||||
|
import com.terraforged.mod.gui.page.DimensionsPage;
|
||||||
import com.terraforged.mod.gui.page.FeaturePage;
|
import com.terraforged.mod.gui.page.FeaturePage;
|
||||||
import com.terraforged.mod.gui.page.FilterPage;
|
import com.terraforged.mod.gui.page.FilterPage;
|
||||||
import com.terraforged.mod.gui.page.GeneratorPage;
|
import com.terraforged.mod.gui.page.GeneratorPage;
|
||||||
@ -70,7 +71,8 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
new RiverPage(settings, preview),
|
new RiverPage(settings, preview),
|
||||||
new FilterPage(settings, preview),
|
new FilterPage(settings, preview),
|
||||||
new FeaturePage(settings),
|
new FeaturePage(settings),
|
||||||
new StructurePage(settings)
|
new StructurePage(settings),
|
||||||
|
new DimensionsPage(settings),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +251,13 @@ public class SettingsScreen extends OverlayScreen {
|
|||||||
return a || b || c;
|
return a || b || c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean charTyped(char c, int code) {
|
||||||
|
boolean a = pages[pageIndex].action(pane -> pane.charTyped(c, code));
|
||||||
|
boolean b = preview.action(pane -> pane.charTyped(c, code));
|
||||||
|
return a || b || super.charTyped(c, code);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose() {
|
public void onClose() {
|
||||||
for (Page page : pages) {
|
for (Page page : pages) {
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.terraforged.mod.gui.element;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.StringNBT;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class TerraTextInput extends TextFieldWidget implements Element, Consumer<String> {
|
||||||
|
|
||||||
|
private final CompoundNBT value;
|
||||||
|
private final List<String> tooltip;
|
||||||
|
private Predicate<String> validator = s -> true;
|
||||||
|
private Consumer<TerraTextInput> callback = t -> {};
|
||||||
|
|
||||||
|
public TerraTextInput(String name, CompoundNBT value) {
|
||||||
|
super(Minecraft.getInstance().fontRenderer, 0, 0, 100, 20, name);
|
||||||
|
this.value = value;
|
||||||
|
this.tooltip = Element.readTooltip(value);
|
||||||
|
setText(value.getString("value"));
|
||||||
|
setResponder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColorValidator(Predicate<String> validator) {
|
||||||
|
this.validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyPressed(int i, int j, int k) {
|
||||||
|
return super.keyPressed(i, j, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean charTyped(char c, int code) {
|
||||||
|
return super.charTyped(c, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTooltip() {
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(String text) {
|
||||||
|
value.put("value", StringNBT.valueOf(text));
|
||||||
|
callback.accept(this);
|
||||||
|
if (validator.test(text)) {
|
||||||
|
setTextColor(14737632);
|
||||||
|
} else {
|
||||||
|
setTextColor(0xffff3f30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,7 +32,7 @@ import net.minecraftforge.common.util.Constants;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Toggle extends TerraButton {
|
public class TerraToggle extends TerraButton {
|
||||||
|
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final CompoundNBT value;
|
private final CompoundNBT value;
|
||||||
@ -42,7 +42,7 @@ public class Toggle extends TerraButton {
|
|||||||
private int index;
|
private int index;
|
||||||
private Runnable callback = () -> {};
|
private Runnable callback = () -> {};
|
||||||
|
|
||||||
public Toggle(String prefix, CompoundNBT value) {
|
public TerraToggle(String prefix, CompoundNBT value) {
|
||||||
super(value.getString("value"));
|
super(value.getString("value"));
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
@ -58,7 +58,7 @@ public class Toggle extends TerraButton {
|
|||||||
setMessage(prefix + value.getString("value"));
|
setMessage(prefix + value.getString("value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Toggle callback(Runnable runnable) {
|
public TerraToggle callback(Runnable runnable) {
|
||||||
this.callback = runnable;
|
this.callback = runnable;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.terraforged.mod.gui.page;
|
||||||
|
|
||||||
|
import com.terraforged.mod.TerraWorld;
|
||||||
|
import com.terraforged.mod.gui.OverlayScreen;
|
||||||
|
import com.terraforged.mod.gui.element.TerraTextInput;
|
||||||
|
import com.terraforged.mod.settings.TerraSettings;
|
||||||
|
import com.terraforged.mod.util.nbt.NBTHelper;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.ListNBT;
|
||||||
|
import net.minecraft.nbt.StringNBT;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.WorldType;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
public class DimensionsPage extends BasePage {
|
||||||
|
|
||||||
|
private final TerraSettings settings;
|
||||||
|
private final CompoundNBT dimensionSettings;
|
||||||
|
|
||||||
|
public DimensionsPage(TerraSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
this.dimensionSettings = NBTHelper.serialize(settings.dimensions);
|
||||||
|
|
||||||
|
CompoundNBT generators = dimensionSettings.getCompound("dimensionGenerators").getCompound("value");
|
||||||
|
for (String name : generators.keySet()) {
|
||||||
|
CompoundNBT setting = generators.getCompound(name);
|
||||||
|
setting.put("#options", getWorldTypes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
return "Dimension Settings";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
NBTHelper.deserialize(dimensionSettings, settings.dimensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(OverlayScreen parent) {
|
||||||
|
Column left = getColumn(0);
|
||||||
|
addElements(left.left, left.top, left, dimensionSettings, true, left.scrollPane::addButton, this::update);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAddWidget(Widget widget) {
|
||||||
|
if (widget instanceof TerraTextInput) {
|
||||||
|
TerraTextInput input = (TerraTextInput) widget;
|
||||||
|
input.setColorValidator(string -> ForgeRegistries.BLOCKS.containsKey(new ResourceLocation(string)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ListNBT getWorldTypes() {
|
||||||
|
ListNBT options = new ListNBT();
|
||||||
|
for (WorldType type : WorldType.WORLD_TYPES) {
|
||||||
|
if (type == null || (type.getId() >= 1 && type.getId() <= 6) || type.getId() == 8) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!TerraWorld.isTerraType(type)) {
|
||||||
|
options.add(StringNBT.valueOf(type.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
}
|
@ -28,10 +28,10 @@ package com.terraforged.mod.gui.page;
|
|||||||
import com.terraforged.mod.gui.OverlayRenderer;
|
import com.terraforged.mod.gui.OverlayRenderer;
|
||||||
import com.terraforged.mod.gui.OverlayScreen;
|
import com.terraforged.mod.gui.OverlayScreen;
|
||||||
import com.terraforged.mod.gui.ScrollPane;
|
import com.terraforged.mod.gui.ScrollPane;
|
||||||
import com.terraforged.mod.gui.element.TerraButton;
|
|
||||||
import com.terraforged.mod.gui.element.TerraLabel;
|
import com.terraforged.mod.gui.element.TerraLabel;
|
||||||
import com.terraforged.mod.gui.element.TerraSlider;
|
import com.terraforged.mod.gui.element.TerraSlider;
|
||||||
import com.terraforged.mod.gui.element.Toggle;
|
import com.terraforged.mod.gui.element.TerraTextInput;
|
||||||
|
import com.terraforged.mod.gui.element.TerraToggle;
|
||||||
import com.terraforged.mod.util.nbt.NBTHelper;
|
import com.terraforged.mod.util.nbt.NBTHelper;
|
||||||
import net.minecraft.client.gui.IGuiEventListener;
|
import net.minecraft.client.gui.IGuiEventListener;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@ -144,6 +144,7 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer {
|
|||||||
button.x = x;
|
button.x = x;
|
||||||
button.y = top.getAndAdd(SLIDER_HEIGHT + SLIDER_PAD);
|
button.y = top.getAndAdd(SLIDER_HEIGHT + SLIDER_PAD);
|
||||||
consumer.accept(button);
|
consumer.accept(button);
|
||||||
|
onAddWidget(button);
|
||||||
} else if (deep) {
|
} else if (deep) {
|
||||||
INBT child = value.get("value");
|
INBT child = value.get("value");
|
||||||
if (child == null || child.getId() != Constants.NBT.TAG_COMPOUND) {
|
if (child == null || child.getId() != Constants.NBT.TAG_COMPOUND) {
|
||||||
@ -170,14 +171,18 @@ public abstract class Page implements IGuiEventListener, OverlayRenderer {
|
|||||||
} else if (type == Constants.NBT.TAG_FLOAT) {
|
} else if (type == Constants.NBT.TAG_FLOAT) {
|
||||||
return new TerraSlider.Float(name + ": ", value).callback(callback);
|
return new TerraSlider.Float(name + ": ", value).callback(callback);
|
||||||
} else if (type == Constants.NBT.TAG_STRING && value.contains("#options")) {
|
} else if (type == Constants.NBT.TAG_STRING && value.contains("#options")) {
|
||||||
return new Toggle(name + ": ", value).callback(callback);
|
return new TerraToggle(name + ": ", value).callback(callback);
|
||||||
} else if (type == Constants.NBT.TAG_STRING) {
|
} else if (type == Constants.NBT.TAG_STRING) {
|
||||||
return new TerraButton(name);
|
return new TerraTextInput(name, value);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onAddWidget(Widget widget) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class Column {
|
public static class Column {
|
||||||
|
|
||||||
public final int left;
|
public final int left;
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package com.terraforged.mod.settings;
|
||||||
|
|
||||||
|
import com.terraforged.core.util.serialization.annotation.Comment;
|
||||||
|
import com.terraforged.core.util.serialization.annotation.Range;
|
||||||
|
import com.terraforged.core.util.serialization.annotation.Serializable;
|
||||||
|
import com.terraforged.mod.TerraWorld;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.StringNBT;
|
||||||
|
import net.minecraft.world.WorldType;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
|
import org.jline.utils.Log;
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public class DimesionSettings {
|
||||||
|
|
||||||
|
public BaseDecorator baseLayer = new BaseDecorator();
|
||||||
|
|
||||||
|
public DimensionGenerators dimensionGenerators = new DimensionGenerators();
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public static class BaseDecorator {
|
||||||
|
|
||||||
|
@Comment("Controls the material that should be used in the world's base layer")
|
||||||
|
public String material = "minecraft:bedrock";
|
||||||
|
|
||||||
|
@Range(min = 0, max = 10)
|
||||||
|
@Comment("Controls the minimum height of the world's base layer")
|
||||||
|
public int minDepth = 1;
|
||||||
|
|
||||||
|
@Range(min = 0, max = 10)
|
||||||
|
@Comment("Controls the amount of height randomness of the world's base layer")
|
||||||
|
public int variance = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
public static class DimensionGenerators {
|
||||||
|
|
||||||
|
@Comment("Select the nether generator")
|
||||||
|
public String nether = "default";
|
||||||
|
|
||||||
|
@Comment("Select the end generator")
|
||||||
|
public String end = "default";
|
||||||
|
|
||||||
|
public void apply(WorldInfo info) {
|
||||||
|
set(info, DimensionType.THE_NETHER, nether);
|
||||||
|
set(info, DimensionType.THE_END, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorldType getWorldType(WorldInfo info, DimensionType type) {
|
||||||
|
String generator = info.getDimensionData(type).getString("TerraDelegateGenerator");
|
||||||
|
return getWorldType(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void set(WorldInfo info, DimensionType type, String value) {
|
||||||
|
CompoundNBT data = info.getDimensionData(type);
|
||||||
|
data.put("TerraDelegateGenerator", StringNBT.valueOf(getWorldType(value).getName()));
|
||||||
|
info.setDimensionData(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WorldType getWorldType(String name) {
|
||||||
|
WorldType type = WorldType.byName(name);
|
||||||
|
if (type == null) {
|
||||||
|
Log.warn("WorldType {} does not exist. Reverting to default", name);
|
||||||
|
return WorldType.DEFAULT;
|
||||||
|
}
|
||||||
|
if (TerraWorld.isTerraType(type)) {
|
||||||
|
Log.warn("Cannot set TerraForged as world type for {}", name);
|
||||||
|
return WorldType.DEFAULT;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import com.terraforged.mod.Log;
|
|||||||
import com.terraforged.mod.TerraWorld;
|
import com.terraforged.mod.TerraWorld;
|
||||||
import com.terraforged.mod.util.nbt.NBTHelper;
|
import com.terraforged.mod.util.nbt.NBTHelper;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.storage.WorldInfo;
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -72,9 +72,13 @@ public class SettingsHelper {
|
|||||||
NBTHelper.deserialize(options, dest);
|
NBTHelper.deserialize(options, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraSettings getSettings(IWorld world) {
|
public static TerraSettings getSettings(World world) {
|
||||||
|
return getSettings(world.getWorldInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerraSettings getSettings(WorldInfo info) {
|
||||||
TerraSettings settings = new TerraSettings();
|
TerraSettings settings = new TerraSettings();
|
||||||
if (world.getWorldInfo().getGeneratorOptions().isEmpty()) {
|
if (info.getGeneratorOptions().isEmpty()) {
|
||||||
if (SETTINGS_FILE.exists()) {
|
if (SETTINGS_FILE.exists()) {
|
||||||
try (Reader reader = new BufferedReader(new FileReader(SETTINGS_FILE))) {
|
try (Reader reader = new BufferedReader(new FileReader(SETTINGS_FILE))) {
|
||||||
Log.info("Loading generator settings from json");
|
Log.info("Loading generator settings from json");
|
||||||
@ -87,7 +91,7 @@ public class SettingsHelper {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.info("Loading generator settings from level.dat");
|
Log.info("Loading generator settings from level.dat");
|
||||||
NBTHelper.deserialize(world.getWorldInfo().getGeneratorOptions(), settings);
|
NBTHelper.deserialize(info.getGeneratorOptions(), settings);
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,6 @@ public class TerraSettings extends Settings {
|
|||||||
public FeatureSettings features = new FeatureSettings();
|
public FeatureSettings features = new FeatureSettings();
|
||||||
|
|
||||||
public StructureSettings structures = new StructureSettings();
|
public StructureSettings structures = new StructureSettings();
|
||||||
|
|
||||||
|
public DimesionSettings dimensions = new DimesionSettings();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"biomes": [
|
||||||
|
"minecraft:*"
|
||||||
|
],
|
||||||
"match": [
|
"match": [
|
||||||
[
|
[
|
||||||
"minecraft:mega_spruce_tree"
|
"minecraft:mega_spruce_tree"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
mod_version=0.0.13
|
mod_version=0.0.14
|
||||||
mc_version=1.15.2
|
mc_version=1.15.2
|
||||||
forge_version=31.1.1
|
forge_version=31.1.77
|
||||||
mcp_channel=snapshot
|
mcp_channel=snapshot
|
||||||
mcp_version=20200225-1.15.1
|
mcp_version=20200225-1.15.1
|
||||||
org.gradle.jvmargs=-Xmx4G
|
org.gradle.jvmargs=-Xmx4G
|
||||||
|
Loading…
Reference in New Issue
Block a user