update n2d package

This commit is contained in:
dags- 2020-06-12 00:53:59 +01:00
parent 0ca12bd0d1
commit 38dc1c9261
37 changed files with 165 additions and 66 deletions

2
Engine

@ -1 +1 @@
Subproject commit 82bcd434921697fb51fd272d65ed6f10ec79ab22
Subproject commit 86578fa35c0c296487d1aac675b55d4eb994cde7

@ -1 +1 @@
Subproject commit 5411388286fbf68e37213f467cfea38c937051c6
Subproject commit 96704f55881abe69c1a20462cccb83004bd15a9a

View File

@ -28,8 +28,8 @@ package com.terraforged.api.biome.modifier;
import com.terraforged.core.Seed;
import com.terraforged.core.cell.Cell;
import com.terraforged.world.climate.Climate;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.world.biome.Biome;
public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier {

View File

@ -26,8 +26,8 @@
package com.terraforged.api.chunk.column;
import com.terraforged.api.chunk.surface.ChunkSurfaceBuffer;
import me.dags.noise.Source;
import me.dags.noise.source.FastSource;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.source.FastSource;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.IChunk;

View File

@ -25,7 +25,7 @@
package com.terraforged.api.material.geology;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
public class StrataConfig {

View File

@ -25,7 +25,7 @@
package com.terraforged.api.material.layer;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

View File

@ -11,7 +11,7 @@ import com.terraforged.core.cell.Cell;
import com.terraforged.world.biome.BiomeType;
import com.terraforged.world.heightmap.Levels;
import com.terraforged.world.terrain.TerrainType;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.world.biome.Biome;
import java.util.Arrays;

View File

@ -5,7 +5,7 @@ import com.terraforged.biome.map.defaults.DefaultBiome;
import com.terraforged.biome.provider.BiomeHelper;
import com.terraforged.core.cell.Cell;
import com.terraforged.util.ListUtils;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.world.biome.Biome;
import java.util.Collections;

View File

@ -28,8 +28,8 @@ package com.terraforged.biome.modifier;
import com.terraforged.core.Seed;
import com.terraforged.core.cell.Cell;
import com.terraforged.world.climate.Climate;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.world.biome.Biome;
public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier {

View File

@ -6,8 +6,8 @@ import com.terraforged.core.cell.Cell;
import com.terraforged.world.GeneratorContext;
import com.terraforged.world.biome.BiomeType;
import com.terraforged.world.terrain.Terrains;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;

View File

@ -31,7 +31,7 @@ import com.terraforged.biome.map.BiomeMapBuilder;
import com.terraforged.biome.map.BiomePredicate;
import com.terraforged.world.biome.BiomeData;
import com.terraforged.world.biome.BiomeType;
import me.dags.noise.util.Vec2f;
import com.terraforged.n2d.util.Vec2f;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;

View File

@ -5,9 +5,9 @@ import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.core.Seed;
import com.terraforged.core.util.Variance;
import com.terraforged.world.geology.Strata;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

View File

@ -34,10 +34,10 @@ import com.terraforged.chunk.TerraContext;
import com.terraforged.core.cell.Cell;
import com.terraforged.world.heightmap.Levels;
import com.terraforged.world.terrain.Terrains;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.func.CellFunc;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.func.CellFunc;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;

View File

@ -4,8 +4,8 @@ import com.terraforged.api.chunk.surface.Surface;
import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.api.material.state.States;
import com.terraforged.world.GeneratorContext;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.world.gen.Heightmap;

View File

@ -31,9 +31,9 @@ import com.terraforged.api.material.state.States;
import com.terraforged.chunk.TerraContext;
import com.terraforged.core.cell.Cell;
import com.terraforged.world.heightmap.Levels;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;

View File

@ -3,9 +3,9 @@ package com.terraforged.biome.surface;
import com.terraforged.api.chunk.surface.Surface;
import com.terraforged.api.chunk.surface.SurfaceContext;
import com.terraforged.api.material.state.States;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.func.CellFunc;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.func.CellFunc;
import net.minecraft.block.BlockState;
public class SteppeSurface implements Surface {

View File

@ -31,6 +31,7 @@ import com.terraforged.api.material.layer.LayerManager;
import com.terraforged.biome.provider.BiomeProvider;
import com.terraforged.chunk.generator.BiomeGenerator;
import com.terraforged.chunk.generator.FeatureGenerator;
import com.terraforged.chunk.generator.Generator;
import com.terraforged.chunk.generator.MobGenerator;
import com.terraforged.chunk.generator.StructureGenerator;
import com.terraforged.chunk.generator.SurfaceGenerator;
@ -69,13 +70,13 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
private final TerraContext context;
private final BiomeProvider biomeProvider;
private final MobGenerator mobGenerator;
private final BiomeGenerator biomeGenerator;
private final TerrainCarver terrainCarver;
private final TerrainGenerator terrainGenerator;
private final SurfaceGenerator surfaceGenerator;
private final FeatureGenerator featureGenerator;
private final StructureGenerator structureGenerator;
private final Generator.Mobs mobGenerator;
private final Generator.Biomes biomeGenerator;
private final Generator.Carvers terrainCarver;
private final Generator.Terrain terrainGenerator;
private final Generator.Surfaces surfaceGenerator;
private final Generator.Features featureGenerator;
private final Generator.Structures structureGenerator;
private final GeoManager geologyManager;
private final FeatureManager featureManager;
@ -159,12 +160,12 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
@Override
public final void spawnMobs(ServerWorld worldIn, boolean hostile, boolean peaceful) {
mobGenerator.spawnMobs(worldIn, hostile, peaceful);
mobGenerator.tickSpawners(worldIn, hostile, peaceful);
}
@Override
public final List<Biome.SpawnListEntry> getPossibleCreatures(EntityClassification type, BlockPos pos) {
return mobGenerator.getPossibleCreatures(world, type, pos);
return mobGenerator.getSpawns(world, type, pos);
}
@Override

View File

@ -29,7 +29,7 @@ import com.terraforged.api.chunk.column.ColumnDecorator;
import com.terraforged.api.chunk.column.DecoratorContext;
import com.terraforged.chunk.TerraContext;
import com.terraforged.chunk.column.ErosionDecorator;
import me.dags.noise.source.Rand;
import com.terraforged.n2d.source.Rand;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.GrassBlock;

View File

@ -9,7 +9,7 @@ import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk;
public class BiomeGenerator {
public class BiomeGenerator implements Generator.Biomes {
private final TerraChunkGenerator generator;
private final BiomeProvider biomeProvider;
@ -19,6 +19,7 @@ public class BiomeGenerator {
this.biomeProvider = generator.getBiomeProvider();
}
@Override
public void generateBiomes(IChunk chunk) {
ChunkPos pos = chunk.getPos();
try (ChunkReader reader = generator.getChunkReader(pos.x, pos.z)) {

View File

@ -17,7 +17,7 @@ import net.minecraft.world.gen.WorldGenRegion;
import java.util.List;
public class FeatureGenerator {
public class FeatureGenerator implements Generator.Features {
private final TerraChunkGenerator generator;
@ -25,6 +25,7 @@ public class FeatureGenerator {
this.generator = generator;
}
@Override
public final void generateFeatures(WorldGenRegion region) {
int chunkX = region.getMainChunkX();
int chunkZ = region.getMainChunkZ();

View File

@ -0,0 +1,89 @@
package com.terraforged.chunk.generator;
import net.minecraft.entity.EntityClassification;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeManager;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.WorldGenRegion;
import net.minecraft.world.gen.feature.template.TemplateManager;
import net.minecraft.world.server.ServerWorld;
import java.util.List;
public interface Generator {
interface Biomes {
/**
* Generates the biomes for this chunk
*/
void generateBiomes(IChunk chunk);
}
interface Terrain {
/**
* Generates the basic heightmap and populates with stone/water/bedrock accordinly
*/
void generateTerrain(IWorld world, IChunk chunk);
}
interface Features {
/**
* Places biome specific features into the center-chunk of the world gen region
* The region consists of the center chunk (the chunk being generated) and it's 8 neighbouring chunks (citation needed)
*/
void generateFeatures(WorldGenRegion region);
}
interface Structures {
/**
* Determines where structures will be placed during chunk gen
*/
void generateStructureStarts(BiomeManager biomes, IChunk chunk, TemplateManager templates);
/**
* Determines where individual structure pieces will be placed based on the start positions
*/
void generateStructureReferences(IWorld world, IChunk chunk);
}
interface Surfaces {
/**
* Applies biome specific surface generation during chunk gen
*/
void generateSurface(WorldGenRegion world, IChunk chunk);
}
interface Carvers {
/**
* Cuts caves/ravines during chunk gen according to the carving stage
*/
void carveTerrain(BiomeManager biomes, IChunk chunk, GenerationStage.Carving type);
}
interface Mobs {
/**
* Spawns mobs during chunk gen
*/
void generateMobs(WorldGenRegion region);
/**
* Ticks the worlds mob spawners post chunk gen
*/
void tickSpawners(ServerWorld world, boolean hostile, boolean peaceful);
/**
* Gets a list of possible spawns at the given position
*/
List<Biome.SpawnListEntry> getSpawns(IWorld world, EntityClassification type, BlockPos pos);
}
}

View File

@ -21,7 +21,7 @@ import net.minecraftforge.fml.common.Mod;
import java.util.List;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
public class MobGenerator {
public class MobGenerator implements Generator.Mobs {
// may be accessed cross-thread
private static volatile boolean mobSpawning = true;
@ -35,6 +35,7 @@ public class MobGenerator {
this.generator = generator;
}
@Override
public final void generateMobs(WorldGenRegion region) {
// vanilla does NOT check the mobSpawning gamerule before calling this
if (MobGenerator.mobSpawning) {
@ -47,13 +48,15 @@ public class MobGenerator {
}
}
public final void spawnMobs(ServerWorld world, boolean hostile, boolean peaceful) {
@Override
public final void tickSpawners(ServerWorld world, boolean hostile, boolean peaceful) {
phantomSpawner.tick(world, hostile, peaceful);
patrolSpawner.tick(world, hostile, peaceful);
catSpawner.tick(world, hostile, peaceful);
}
public final List<Biome.SpawnListEntry> getPossibleCreatures(IWorld world, EntityClassification type, BlockPos pos) {
@Override
public final List<Biome.SpawnListEntry> getSpawns(IWorld world, EntityClassification type, BlockPos pos) {
if (Feature.SWAMP_HUT.func_202383_b(world, pos)) {
if (type == EntityClassification.MONSTER) {
return Feature.SWAMP_HUT.getSpawnList();

View File

@ -18,7 +18,7 @@ import net.minecraft.world.gen.feature.template.TemplateManager;
import java.util.Map;
public class StructureGenerator {
public class StructureGenerator implements Generator.Structures {
private final TerraChunkGenerator generator;
@ -26,6 +26,7 @@ public class StructureGenerator {
this.generator = generator;
}
@Override
public void generateStructureStarts(BiomeManager biomes, IChunk chunk, TemplateManager templates) {
ChunkPos chunkpos = chunk.getPos();
generator.queueChunk(chunkpos.x, chunkpos.z);

View File

@ -14,7 +14,7 @@ import net.minecraft.world.gen.INoiseGenerator;
import net.minecraft.world.gen.PerlinNoiseGenerator;
import net.minecraft.world.gen.WorldGenRegion;
public class SurfaceGenerator {
public class SurfaceGenerator implements Generator.Surfaces {
private final TerraChunkGenerator generator;
private final INoiseGenerator surfaceNoise;
@ -24,6 +24,7 @@ public class SurfaceGenerator {
this.surfaceNoise = new PerlinNoiseGenerator(new SharedSeedRandom(generator.getSeed()), 3, 0);
}
@Override
public final void generateSurface(WorldGenRegion world, IChunk chunk) {
try (ChunkReader reader = generator.getChunkReader(chunk.getPos().x, chunk.getPos().z)) {
TerraContainer container = TerraContainer.getOrCreate(chunk, reader, generator.getBiomeProvider());

View File

@ -14,7 +14,7 @@ import net.minecraft.world.gen.carver.ConfiguredCarver;
import java.util.BitSet;
import java.util.ListIterator;
public class TerrainCarver {
public class TerrainCarver implements Generator.Carvers {
private final TerraChunkGenerator generator;
@ -22,6 +22,7 @@ public class TerrainCarver {
this.generator = generator;
}
@Override
public void carveTerrain(BiomeManager biomes, IChunk chunk, GenerationStage.Carving type) {
if (StructureUtils.hasOvergroundStructure(chunk)) {
return;

View File

@ -13,7 +13,7 @@ import com.terraforged.world.terrain.Terrains;
import net.minecraft.world.IWorld;
import net.minecraft.world.chunk.IChunk;
public class TerrainGenerator {
public class TerrainGenerator implements Generator.Terrain {
private final Levels levels;
private final Climate climate;
@ -29,6 +29,7 @@ public class TerrainGenerator {
this.terrainHelper = new TerrainHelper(0.75F);
}
@Override
public final void generateTerrain(IWorld world, IChunk chunk) {
try (ChunkReader reader = generator.getChunkReader(chunk.getPos().x, chunk.getPos().z)) {
TerraContainer container = TerraContainer.getOrCreate(chunk, reader, generator.getBiomeProvider());

View File

@ -305,7 +305,7 @@ public class TerraCommand {
return TextComponentUtils.wrapInSquareBrackets(new TranslationTextComponent(
"chat.coordinates", pos.getX(), "~", pos.getZ()
)).applyTextStyle((style) -> style.setColor(TextFormatting.GREEN)
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + pos.getX() + " ~ " + pos.getZ()))
.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + pos.getX() + " " + pos.getY() + " " + pos.getZ()))
.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent("chat.coordinates.tooltip")))
);
}

View File

@ -30,7 +30,7 @@ import it.unimi.dsi.fastutil.longs.LongIterator;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectList;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;

View File

@ -3,9 +3,9 @@ package com.terraforged.feature.decorator.poisson;
import com.terraforged.chunk.TerraChunkGenerator;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.region.chunk.ChunkReader;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.ChunkGenerator;

View File

@ -4,8 +4,8 @@ import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
import com.terraforged.core.util.poisson.PoissonContext;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.placement.IPlacementConfig;

View File

@ -1,7 +1,7 @@
package com.terraforged.feature.feature;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.block.BlockState;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.math.BlockPos;

View File

@ -39,7 +39,7 @@ import com.terraforged.world.GeneratorContext;
import com.terraforged.world.continent.MutableVeci;
import com.terraforged.world.heightmap.Levels;
import com.terraforged.world.terrain.Terrains;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.FontRenderer;

View File

@ -27,7 +27,7 @@ package com.terraforged.gui.preview;
import com.terraforged.core.cell.Cell;
import com.terraforged.world.heightmap.Levels;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import java.awt.*;

View File

@ -29,7 +29,7 @@ import com.terraforged.api.material.geology.StrataConfig;
import com.terraforged.api.material.geology.StrataGenerator;
import com.terraforged.material.Materials;
import com.terraforged.world.geology.Strata;
import me.dags.noise.Source;
import com.terraforged.n2d.Source;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;

View File

@ -32,8 +32,8 @@ import com.terraforged.core.Seed;
import com.terraforged.material.Materials;
import com.terraforged.world.geology.Geology;
import com.terraforged.world.geology.Strata;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.n2d.Module;
import com.terraforged.n2d.Source;
import net.minecraft.block.BlockState;
import net.minecraft.world.biome.Biome;

View File

@ -25,7 +25,7 @@
package com.terraforged.util;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.n2d.util.NoiseUtil;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -29,8 +29,8 @@ import com.terraforged.Log;
import com.terraforged.api.event.SetupEvent;
import com.terraforged.core.Seed;
import com.terraforged.world.geology.Strata;
import me.dags.noise.Source;
import me.dags.noise.source.Builder;
import com.terraforged.n2d.Source;
import com.terraforged.n2d.source.Builder;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.world.biome.Biomes;