commit
24d7201e14
@ -25,11 +25,15 @@
|
|||||||
|
|
||||||
package com.terraforged.api.material;
|
package com.terraforged.api.material;
|
||||||
|
|
||||||
|
import com.terraforged.api.material.state.StateTagPredicate;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.Tag;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class WGTags {
|
public class WGTags {
|
||||||
|
|
||||||
public static final Tag<Block> STONE = tag("wg_stone");
|
public static final Tag<Block> STONE = tag("wg_stone");
|
||||||
@ -45,4 +49,8 @@ public class WGTags {
|
|||||||
private static Tag<Block> tag(String name) {
|
private static Tag<Block> tag(String name) {
|
||||||
return new BlockTags.Wrapper(new ResourceLocation("forge", name));
|
return new BlockTags.Wrapper(new ResourceLocation("forge", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Predicate<BlockState> stone() {
|
||||||
|
return new StateTagPredicate(STONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.terraforged.api.material.state;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class StateTagPredicate implements Predicate<BlockState> {
|
||||||
|
|
||||||
|
private final Tag<Block> tag;
|
||||||
|
|
||||||
|
public StateTagPredicate(Tag<Block> tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(BlockState state) {
|
||||||
|
return tag.contains(state.getBlock());
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,7 @@ import com.terraforged.mod.util.DataPackFinder;
|
|||||||
import com.terraforged.mod.util.Environment;
|
import com.terraforged.mod.util.Environment;
|
||||||
import net.minecraft.world.biome.Biomes;
|
import net.minecraft.world.biome.Biomes;
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||||
import net.minecraft.world.gen.placement.Placement;
|
import net.minecraft.world.gen.placement.Placement;
|
||||||
import net.minecraftforge.common.BiomeDictionary;
|
import net.minecraftforge.common.BiomeDictionary;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
@ -62,11 +63,14 @@ public class TerraForgedMod {
|
|||||||
TerraWorld.init();
|
TerraWorld.init();
|
||||||
SaplingManager.init();
|
SaplingManager.init();
|
||||||
TerraCommand.init();
|
TerraCommand.init();
|
||||||
SettingsHelper.moveSettings();
|
SettingsHelper.initSettings();
|
||||||
|
|
||||||
// temp fix
|
// temp fix
|
||||||
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE, BiomeDictionary.Type.OVERWORLD);
|
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE, BiomeDictionary.Type.OVERWORLD);
|
||||||
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE_HILLS, BiomeDictionary.Type.OVERWORLD);
|
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE_HILLS, BiomeDictionary.Type.OVERWORLD);
|
||||||
|
|
||||||
|
// allows ores to replace any world-gen stone type
|
||||||
|
OreFeatureConfig.FillerBlockType.create("WG_STONE", "wg_stone", WGTags.stone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -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;
|
||||||
|
@ -35,6 +35,7 @@ import com.terraforged.core.util.concurrent.ThreadPool;
|
|||||||
import com.terraforged.core.util.concurrent.cache.CacheEntry;
|
import com.terraforged.core.util.concurrent.cache.CacheEntry;
|
||||||
import com.terraforged.core.world.GeneratorContext;
|
import com.terraforged.core.world.GeneratorContext;
|
||||||
import com.terraforged.core.world.WorldGeneratorFactory;
|
import com.terraforged.core.world.WorldGeneratorFactory;
|
||||||
|
import com.terraforged.core.world.heightmap.Levels;
|
||||||
import com.terraforged.core.world.terrain.Terrain;
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
import com.terraforged.core.world.terrain.Terrains;
|
import com.terraforged.core.world.terrain.Terrains;
|
||||||
import com.terraforged.mod.util.nbt.NBTHelper;
|
import com.terraforged.mod.util.nbt.NBTHelper;
|
||||||
@ -53,9 +54,9 @@ import java.util.Random;
|
|||||||
public class Preview extends Button {
|
public class Preview extends Button {
|
||||||
|
|
||||||
private static final int FACTOR = 4;
|
private static final int FACTOR = 4;
|
||||||
public static final int WIDTH = 256;//Size.chunkToBlock(1 << FACTOR);
|
public static final int WIDTH = 256;
|
||||||
private static final int SLICE_HEIGHT = 64;
|
private static final int SLICE_HEIGHT = 64;
|
||||||
public static final int HEIGHT = WIDTH + SLICE_HEIGHT;//Size.chunkToBlock(1 << FACTOR);
|
public static final int HEIGHT = WIDTH + SLICE_HEIGHT;
|
||||||
private static final float[] LEGEND_SCALES = {1, 0.9F, 0.75F, 0.6F};
|
private static final float[] LEGEND_SCALES = {1, 0.9F, 0.75F, 0.6F};
|
||||||
|
|
||||||
private final int offsetX;
|
private final int offsetX;
|
||||||
@ -64,15 +65,15 @@ public class Preview extends Button {
|
|||||||
private final PreviewSettings previewSettings = new PreviewSettings();
|
private final PreviewSettings previewSettings = new PreviewSettings();
|
||||||
private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true));
|
private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true));
|
||||||
|
|
||||||
|
private final String[] values = {"", "", ""};
|
||||||
|
private final String[] labels = {"Area: ", "Terrain: ", "Biome: "};
|
||||||
|
|
||||||
private int seed;
|
private int seed;
|
||||||
private long lastUpdate = 0L;
|
private long lastUpdate = 0L;
|
||||||
private Settings settings = new Settings();
|
private Settings settings = new Settings();
|
||||||
private CacheEntry<Region> task = null;
|
private CacheEntry<Region> task = null;
|
||||||
private Region region = null;
|
private Region region = null;
|
||||||
|
|
||||||
private String[] labels = {"Area: ", "Terrain: ", "Biome: "};
|
|
||||||
private String[] values = {"", "", ""};
|
|
||||||
|
|
||||||
public Preview(int seed) {
|
public Preview(int seed) {
|
||||||
super(0, 0, 0, 0, "", b -> {});
|
super(0, 0, 0, 0, "", b -> {});
|
||||||
this.seed = seed == -1 ? random.nextInt() : seed;
|
this.seed = seed == -1 ? random.nextInt() : seed;
|
||||||
@ -109,6 +110,7 @@ public class Preview extends Button {
|
|||||||
RenderSystem.disableRescaleNormal();
|
RenderSystem.disableRescaleNormal();
|
||||||
|
|
||||||
updateLegend(mx, my);
|
updateLegend(mx, my);
|
||||||
|
|
||||||
renderLegend(labels, values, x, y + width, 10, 0xFFFFFF);
|
renderLegend(labels, values, x, y + width, 10, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +132,8 @@ public class Preview extends Button {
|
|||||||
try {
|
try {
|
||||||
region = task.get();
|
region = task.get();
|
||||||
render(region);
|
render(region);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
task = null;
|
task = null;
|
||||||
}
|
}
|
||||||
@ -143,8 +147,7 @@ public class Preview extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderMode renderer = previewSettings.mode;
|
RenderMode renderer = previewSettings.mode;
|
||||||
Terrains terrains = Terrains.create(settings);
|
Levels levels = new Levels(settings.generator);
|
||||||
GeneratorContext context = new GeneratorContext(terrains, settings);
|
|
||||||
|
|
||||||
int stroke = 2;
|
int stroke = 2;
|
||||||
int width = region.getBlockSize().size;
|
int width = region.getBlockSize().size;
|
||||||
@ -164,8 +167,7 @@ public class Preview extends Button {
|
|||||||
if (x < stroke || z < stroke || x >= width - stroke || z >= width - stroke) {
|
if (x < stroke || z < stroke || x >= width - stroke || z >= width - stroke) {
|
||||||
image.setPixelRGBA(x, z, Color.BLACK.getRGB());
|
image.setPixelRGBA(x, z, Color.BLACK.getRGB());
|
||||||
} else {
|
} else {
|
||||||
Color color = renderer.color(cell, context);
|
image.setPixelRGBA(x, z, renderer.getColor(cell, levels));
|
||||||
image.setPixelRGBA(x, z, RenderMode.rgba(color));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (z == half) {
|
if (z == half) {
|
||||||
@ -203,19 +205,21 @@ public class Preview extends Button {
|
|||||||
.size(FACTOR, 0)
|
.size(FACTOR, 0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return renderer.queue(offsetX, offsetZ, 101 - previewSettings.zoom, true);
|
return renderer.queue(offsetX, offsetZ, 101 - previewSettings.zoom, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLegend(int mx ,int my) {
|
private void updateLegend(int mx ,int my) {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
|
int left = this.x;
|
||||||
|
int top = this.y;
|
||||||
|
float size = this.width;
|
||||||
int zoom = (101 - previewSettings.zoom);
|
int zoom = (101 - previewSettings.zoom);
|
||||||
int width = Math.max(1, region.getBlockSize().size * zoom);
|
int width = Math.max(1, region.getBlockSize().size * zoom);
|
||||||
int height = Math.max(1, region.getBlockSize().size * zoom);
|
int height = Math.max(1, region.getBlockSize().size * zoom);
|
||||||
values[0] = width + "x" + height;
|
values[0] = width + "x" + height;
|
||||||
|
if (mx >= left && mx <= left + size && my >= top && my <= top + size) {
|
||||||
if (mx >= this.x && mx <= this.x + this.width && my >= this.y && my <= this.y + this.height) {
|
float fx = (mx - left) / size;
|
||||||
float fx = (mx - this.x) / (float) this.width;
|
float fz = (my - top) / size;
|
||||||
float fz = (my - this.y) / (float) this.height;
|
|
||||||
int ix = NoiseUtil.round(fx * region.getBlockSize().size);
|
int ix = NoiseUtil.round(fx * region.getBlockSize().size);
|
||||||
int iz = NoiseUtil.round(fz * region.getBlockSize().size);
|
int iz = NoiseUtil.round(fz * region.getBlockSize().size);
|
||||||
Cell<Terrain> cell = region.getCell(ix, iz);
|
Cell<Terrain> cell = region.getCell(ix, iz);
|
||||||
|
@ -92,7 +92,7 @@ public class PreviewPage extends BasePage {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void update() {
|
public void update() {
|
||||||
preview.update(settings, previewerSettings);
|
preview.update(settings, previewerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package com.terraforged.mod.gui.preview;
|
package com.terraforged.mod.gui.preview;
|
||||||
|
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.world.GeneratorContext;
|
|
||||||
import com.terraforged.core.world.heightmap.Levels;
|
import com.terraforged.core.world.heightmap.Levels;
|
||||||
import com.terraforged.core.world.terrain.Terrain;
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
import me.dags.noise.util.NoiseUtil;
|
import me.dags.noise.util.NoiseUtil;
|
||||||
@ -34,50 +33,77 @@ import me.dags.noise.util.NoiseUtil;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public enum RenderMode {
|
public enum RenderMode {
|
||||||
BIOME_TYPE,
|
BIOME_TYPE {
|
||||||
TEMPERATURE,
|
@Override
|
||||||
MOISTURE,
|
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||||
BIOME_SHAPE,
|
Color color = cell.biomeType.getColor();
|
||||||
|
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
||||||
|
return rgba(hsb[0], hsb[1], (hsb[2] * scale) + bias);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TEMPERATURE {
|
||||||
|
@Override
|
||||||
|
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||||
|
float saturation = 0.7F;
|
||||||
|
float brightness = 0.8F;
|
||||||
|
return rgba(step(1 - cell.temperature, 8) * 0.65F, saturation, brightness);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
MOISTURE {
|
||||||
|
@Override
|
||||||
|
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||||
|
float saturation = 0.7F;
|
||||||
|
float brightness = 0.8F;
|
||||||
|
return rgba(step(cell.moisture, 8) * 0.65F, saturation, brightness);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BIOME_SHAPE {
|
||||||
|
@Override
|
||||||
|
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||||
|
float saturation = 0.7F;
|
||||||
|
float brightness = 0.8F;
|
||||||
|
return rgba(cell.biome, saturation, brightness);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TERRAIN_TYPE {
|
||||||
|
@Override
|
||||||
|
public int getColor(Cell<Terrain> cell, float scale, float bias) {
|
||||||
|
float saturation = 0.7F;
|
||||||
|
float brightness = 0.8F;
|
||||||
|
return rgba(cell.region, saturation, brightness);
|
||||||
|
}
|
||||||
|
},
|
||||||
;
|
;
|
||||||
|
|
||||||
public Color color(Cell<Terrain> cell, GeneratorContext context) {
|
public int getColor(Cell<Terrain> cell, Levels levels) {
|
||||||
float baseHeight = Levels.getSeaLevel(context.settings.generator);
|
float baseHeight = levels.water;
|
||||||
if (cell.value < baseHeight) {
|
if (cell.value < baseHeight) {
|
||||||
return new Color(40, 140, 200);
|
return rgba(40, 140, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
float bands = 10F;
|
float bands = 10F;
|
||||||
float alpha = 0.2F;
|
float alpha = 0.2F;
|
||||||
float elevation = (cell.value - baseHeight) / (1F - baseHeight);
|
float elevation = (cell.value - baseHeight) / (1F - baseHeight);
|
||||||
|
|
||||||
int band = NoiseUtil.round(elevation * bands);
|
int band = NoiseUtil.round(elevation * bands);
|
||||||
float scale = 1F - alpha;
|
float scale = 1F - alpha;
|
||||||
float bias = alpha * (band / bands);
|
float bias = alpha * (band / bands);
|
||||||
|
return getColor(cell, scale, bias);
|
||||||
float saturation = 0.7F;
|
|
||||||
float brightness = 0.8F;
|
|
||||||
|
|
||||||
switch (this) {
|
|
||||||
case BIOME_SHAPE:
|
|
||||||
return Color.getHSBColor(cell.biome, saturation, brightness);
|
|
||||||
case BIOME_TYPE:
|
|
||||||
Color color = cell.biomeType.getColor();
|
|
||||||
float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]);
|
|
||||||
return Color.getHSBColor(hsb[0], hsb[1], (hsb[2] * scale) + bias);
|
|
||||||
case MOISTURE:
|
|
||||||
return Color.getHSBColor(step(cell.moisture, 8) * 0.65F, saturation, brightness);
|
|
||||||
case TEMPERATURE:
|
|
||||||
return Color.getHSBColor(step(1 - cell.temperature, 8) * 0.65F, saturation, brightness);
|
|
||||||
default:
|
|
||||||
return Color.black;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract int getColor(Cell<Terrain> cell, float scale, float bias);
|
||||||
|
|
||||||
private static float step(float value, int steps) {
|
private static float step(float value, int steps) {
|
||||||
return ((float) NoiseUtil.round(value * steps)) / steps;
|
return ((float) NoiseUtil.round(value * steps)) / steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rgba(Color color) {
|
public static int rgba(float h, float s, float b) {
|
||||||
return color.getRed() + (color.getGreen() << 8) + (color.getBlue() << 16) + (255 << 24);
|
int argb = Color.HSBtoRGB(h, s, b);
|
||||||
|
int red = (argb >> 16) & 0xFF;
|
||||||
|
int green = (argb >> 8) & 0xFF;
|
||||||
|
int blue = argb & 0xFF;
|
||||||
|
return rgba(red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int rgba(int r, int g, int b) {
|
||||||
|
return r + (g << 8) + (b << 16) + (255 << 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,8 +8,9 @@ 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.storage.WorldInfo;
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -72,9 +73,9 @@ public class SettingsHelper {
|
|||||||
NBTHelper.deserialize(options, dest);
|
NBTHelper.deserialize(options, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraSettings getSettings(IWorld world) {
|
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 +88,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;
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ public class SettingsHelper {
|
|||||||
info.setGeneratorOptions(options);
|
info.setGeneratorOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void moveSettings() {
|
public static void initSettings() {
|
||||||
if (SETTINGS_FILE.exists()) {
|
if (SETTINGS_FILE.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,6 +117,12 @@ public class SettingsHelper {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initServerSettings() {
|
||||||
|
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,13 +1,13 @@
|
|||||||
#TerraForged BiomeType Hex Colors (do not include hash/pound character)
|
#BiomeType Hex Colors (do not include hash/pound character)
|
||||||
#Fri Jan 10 23:15:10 GMT 2020
|
#Fri Jan 10 23:15:10 GMT 2020
|
||||||
ALPINE=4b7835
|
ALPINE=eff2ed
|
||||||
TAIGA=4b7835
|
TAIGA=4d733b
|
||||||
TEMPERATE_RAINFOREST=3c602b
|
TEMPERATE_RAINFOREST=528c35
|
||||||
TUNDRA=f7fafc
|
TUNDRA=d7dbc8
|
||||||
TROPICAL_RAINFOREST=4aa73a
|
TROPICAL_RAINFOREST=347d3f
|
||||||
SAVANNA=389a38
|
SAVANNA=88ad3e
|
||||||
GRASSLAND=429545
|
GRASSLAND=4bb34f
|
||||||
TEMPERATE_FOREST=456938
|
TEMPERATE_FOREST=5d9948
|
||||||
STEPPE=c3aa61
|
STEPPE=e0cb89
|
||||||
DESERT=e5d98f
|
DESERT=e6db9c
|
||||||
COLD_STEPPE=a7a374
|
COLD_STEPPE=c2bb84
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 16,
|
"size": 16,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:coal_ore"
|
"Name": "minecraft:coal_ore"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 8,
|
"size": 8,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:diamond_ore"
|
"Name": "minecraft:diamond_ore"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 9,
|
"size": 9,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:gold_ore"
|
"Name": "minecraft:gold_ore"
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 9,
|
"size": 9,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:gold_ore"
|
"Name": "minecraft:gold_ore"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 9,
|
"size": 9,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:iron_ore"
|
"Name": "minecraft:iron_ore"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 7,
|
"size": 7,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:lapis_ore"
|
"Name": "minecraft:lapis_ore"
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"name": "minecraft:ore",
|
"name": "minecraft:ore",
|
||||||
"config": {
|
"config": {
|
||||||
"size": 8,
|
"size": 8,
|
||||||
"target": "natural_stone",
|
"target": "wg_stone",
|
||||||
"state": {
|
"state": {
|
||||||
"Name": "minecraft:redstone_ore",
|
"Name": "minecraft:redstone_ore",
|
||||||
"Properties": {
|
"Properties": {
|
||||||
|
@ -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