separate api source from mod source
This commit is contained in:
parent
16f1aa190f
commit
8d2e2f2f6e
@ -1 +1 @@
|
|||||||
Subproject commit c8448a4425de149fc5e0ac189cea757fe2ba0772
|
Subproject commit a53367b857a43107877096869c40d53fa16fd216
|
33
TerraForgedAPI/build.gradle
Normal file
33
TerraForgedAPI/build.gradle
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url "https://files.minecraftforge.net/maven" }
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: "net.minecraftforge.gradle"
|
||||||
|
apply plugin: "eclipse"
|
||||||
|
apply plugin: "maven"
|
||||||
|
|
||||||
|
version = "${version}-mc${mc_version}"
|
||||||
|
archivesBaseName = "TerraForgedAPI"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||||
|
compile project(":Noise2D")
|
||||||
|
compile project(":FeatureManager")
|
||||||
|
compile project(":TerraForgedCore")
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
mappings channel: mcp_channel, version: mcp_version
|
||||||
|
}
|
7
TerraForgedAPI/gradle.properties
Normal file
7
TerraForgedAPI/gradle.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
mod_version=0.0.1-ALPHA
|
||||||
|
mc_version=1.15.2
|
||||||
|
forge_version=31.0.1
|
||||||
|
mcp_channel=snapshot
|
||||||
|
mcp_version=20200124-1.15.1
|
||||||
|
org.gradle.jvmargs=-Xmx8G
|
||||||
|
org.gradle.daemon=false
|
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.biome;
|
||||||
|
|
||||||
|
import com.terraforged.core.world.biome.BiomeType;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
|
import net.minecraft.tags.TagCollection;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class BiomeTags {
|
||||||
|
|
||||||
|
private static int generation;
|
||||||
|
private static TagCollection<Biome> collection = new TagCollection<>(
|
||||||
|
path -> Optional.empty(),
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final Map<BiomeType, BiomeWrapper> tags = new EnumMap<>(BiomeType.class);
|
||||||
|
|
||||||
|
public static final Tag<Biome> ALPINE = tag(BiomeType.ALPINE);
|
||||||
|
public static final Tag<Biome> COLD_STEPPE = tag(BiomeType.COLD_STEPPE);
|
||||||
|
public static final Tag<Biome> DESERT = tag(BiomeType.DESERT);
|
||||||
|
public static final Tag<Biome> GRASSLAND = tag(BiomeType.GRASSLAND);
|
||||||
|
public static final Tag<Biome> SAVANNA = tag(BiomeType.SAVANNA);
|
||||||
|
public static final Tag<Biome> STEPPE = tag(BiomeType.STEPPE);
|
||||||
|
public static final Tag<Biome> TAIGA = tag(BiomeType.TAIGA);
|
||||||
|
public static final Tag<Biome> TEMPERATE_FOREST = tag(BiomeType.TEMPERATE_FOREST);
|
||||||
|
public static final Tag<Biome> TEMPERATE_RAINFOREST = tag(BiomeType.TEMPERATE_RAINFOREST);
|
||||||
|
public static final Tag<Biome> TROPICAL_RAINFOREST = tag(BiomeType.TROPICAL_RAINFOREST);
|
||||||
|
public static final Tag<Biome> TUNDRA = tag(BiomeType.TUNDRA);
|
||||||
|
|
||||||
|
public static Tag<Biome> getTag(BiomeType type) {
|
||||||
|
return tags.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCollection(TagCollection<Biome> collection) {
|
||||||
|
BiomeTags.collection = collection;
|
||||||
|
BiomeTags.generation++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BiomeWrapper tag(BiomeType type) {
|
||||||
|
BiomeWrapper wrapper = tag(type.name().toLowerCase());
|
||||||
|
tags.put(type, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BiomeWrapper tag(String name) {
|
||||||
|
return new BiomeWrapper(new ResourceLocation("terraforged", name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BiomeWrapper extends Tag<Biome> {
|
||||||
|
|
||||||
|
private Tag<Biome> cachedTag = null;
|
||||||
|
private int lastKnownGeneration = -1;
|
||||||
|
|
||||||
|
public BiomeWrapper(ResourceLocation name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Biome biome) {
|
||||||
|
if (this.lastKnownGeneration != BiomeTags.generation) {
|
||||||
|
this.cachedTag = BiomeTags.collection.getOrCreate(this.getId());
|
||||||
|
this.lastKnownGeneration = BiomeTags.generation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.cachedTag.contains(biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Biome> getAllElements() {
|
||||||
|
if (this.lastKnownGeneration != BiomeTags.generation) {
|
||||||
|
this.cachedTag = BiomeTags.collection.getOrCreate(this.getId());
|
||||||
|
this.lastKnownGeneration = BiomeTags.generation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.cachedTag.getAllElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Tag.ITagEntry<Biome>> getEntries() {
|
||||||
|
if (this.lastKnownGeneration != BiomeTags.generation) {
|
||||||
|
this.cachedTag = BiomeTags.collection.getOrCreate(this.getId());
|
||||||
|
this.lastKnownGeneration = BiomeTags.generation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.cachedTag.getEntries();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.biome.modifier;
|
||||||
|
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.core.util.Seed;
|
||||||
|
import com.terraforged.core.world.climate.Climate;
|
||||||
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
|
import me.dags.noise.Module;
|
||||||
|
import me.dags.noise.Source;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public abstract class AbstractMaxHeightModifier extends AbstractOffsetModifier {
|
||||||
|
|
||||||
|
private final float minHeight;
|
||||||
|
private final float maxHeight;
|
||||||
|
private final float range;
|
||||||
|
private final Module variance;
|
||||||
|
|
||||||
|
public AbstractMaxHeightModifier(Seed seed, Climate climate, int scale, int octaves, float variance, float minHeight, float maxHeight) {
|
||||||
|
super(climate);
|
||||||
|
this.minHeight = minHeight;
|
||||||
|
this.maxHeight = maxHeight;
|
||||||
|
this.range = maxHeight - minHeight;
|
||||||
|
this.variance = Source.perlin(seed.next(), scale, octaves).scale(variance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final Biome modify(Biome in, Cell<Terrain> cell, int x, int z, float ox, float oz) {
|
||||||
|
float var = variance.getValue(x, z);
|
||||||
|
float value = cell.value + var;
|
||||||
|
if (value < minHeight) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
if (value > maxHeight) {
|
||||||
|
return getModifiedBiome(in, cell, x, z, ox, oz);
|
||||||
|
}
|
||||||
|
float alpha = (value - minHeight) / range;
|
||||||
|
cell.biomeEdge *= alpha;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Biome getModifiedBiome(Biome in, Cell<Terrain> cell, int x, int z, float ox, float oz);
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.biome.modifier;
|
||||||
|
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.core.world.climate.Climate;
|
||||||
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public abstract class AbstractOffsetModifier implements BiomeModifier {
|
||||||
|
|
||||||
|
private final Climate climate;
|
||||||
|
|
||||||
|
public AbstractOffsetModifier(Climate climate) {
|
||||||
|
this.climate = climate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome modify(Biome in, Cell<Terrain> cell, int x, int z) {
|
||||||
|
float dx = climate.getOffsetX(x, z, 50);
|
||||||
|
float dz = climate.getOffsetX(x, z, 50);
|
||||||
|
return modify(in, cell, x, z, x + dx, z + dz);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Biome modify(Biome in, Cell<Terrain> cell, int x, int z, float ox, float oz);
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.biome.modifier;
|
||||||
|
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public interface BiomeModifier extends Comparable<BiomeModifier> {
|
||||||
|
|
||||||
|
int priority();
|
||||||
|
|
||||||
|
boolean test(Biome biome);
|
||||||
|
|
||||||
|
Biome modify(Biome in, Cell<Terrain> cell, int x, int z);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default int compareTo(BiomeModifier other) {
|
||||||
|
// reverse order
|
||||||
|
return Integer.compare(other.priority(), priority());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.biome.modifier;
|
||||||
|
|
||||||
|
public interface BiomeModifierRegistrar {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk;
|
||||||
|
|
||||||
|
import net.minecraft.util.SharedSeedRandom;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
|
public class ChunkContext {
|
||||||
|
|
||||||
|
public final int chunkX;
|
||||||
|
public final int chunkZ;
|
||||||
|
public final int blockX;
|
||||||
|
public final int blockZ;
|
||||||
|
public final IChunk chunk;
|
||||||
|
public final SharedSeedRandom random = new SharedSeedRandom();
|
||||||
|
|
||||||
|
public ChunkContext(IChunk chunk) {
|
||||||
|
this.chunk = chunk;
|
||||||
|
this.chunkX = chunk.getPos().x;
|
||||||
|
this.chunkZ = chunk.getPos().z;
|
||||||
|
this.blockX = chunkX << 4;
|
||||||
|
this.blockZ = chunkZ << 4;
|
||||||
|
this.random.setBaseChunkSeed(chunkX, chunkZ);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,347 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
|
import it.unimi.dsi.fastutil.shorts.ShortList;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.fluid.IFluidState;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.ChunkPos;
|
||||||
|
import net.minecraft.util.math.RayTraceContext;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.util.palette.UpgradeData;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraft.world.ITickList;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
|
import net.minecraft.world.biome.BiomeContainer;
|
||||||
|
import net.minecraft.world.chunk.ChunkSection;
|
||||||
|
import net.minecraft.world.chunk.ChunkStatus;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
import net.minecraft.world.gen.GenerationStage;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
import net.minecraft.world.gen.feature.structure.StructureStart;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class ChunkDelegate implements IChunk {
|
||||||
|
|
||||||
|
private final IChunk chunk;
|
||||||
|
|
||||||
|
public ChunkDelegate(IChunk chunk) {
|
||||||
|
this.chunk = chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IChunk getChunk() {
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving) {
|
||||||
|
return chunk.setBlockState(pos, state, isMoving);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTileEntity(BlockPos pos, TileEntity tileEntityIn) {
|
||||||
|
chunk.addTileEntity(pos, tileEntityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addEntity(Entity entityIn) {
|
||||||
|
chunk.addEntity(entityIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ChunkSection getLastExtendedBlockStorage() {
|
||||||
|
return chunk.getLastExtendedBlockStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTopFilledSegment() {
|
||||||
|
return chunk.getTopFilledSegment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<BlockPos> getTileEntitiesPos() {
|
||||||
|
return chunk.getTileEntitiesPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkSection[] getSections() {
|
||||||
|
return chunk.getSections();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Map.Entry<Heightmap.Type, Heightmap>> getHeightmaps() {
|
||||||
|
return chunk.getHeightmaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightmap(Heightmap.Type type, long[] data) {
|
||||||
|
chunk.setHeightmap(type, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Heightmap getHeightmap(Heightmap.Type type) {
|
||||||
|
return chunk.getHeightmap(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTopBlockY(Heightmap.Type heightmapType, int x, int z) {
|
||||||
|
return chunk.getTopBlockY(heightmapType, x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkPos getPos() {
|
||||||
|
return chunk.getPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLastSaveTime(long saveTime) {
|
||||||
|
chunk.setLastSaveTime(saveTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, StructureStart> getStructureStarts() {
|
||||||
|
return chunk.getStructureStarts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStructureStarts(Map<String, StructureStart> structureStartsIn) {
|
||||||
|
chunk.setStructureStarts(structureStartsIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmptyBetween(int startY, int endY) {
|
||||||
|
return chunk.isEmptyBetween(startY, endY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public BiomeContainer getBiomes() {
|
||||||
|
return chunk.getBiomes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setModified(boolean modified) {
|
||||||
|
chunk.setModified(modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModified() {
|
||||||
|
return chunk.isModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkStatus getStatus() {
|
||||||
|
return chunk.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeTileEntity(BlockPos pos) {
|
||||||
|
chunk.removeTileEntity(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markBlockForPostprocessing(BlockPos pos) {
|
||||||
|
chunk.markBlockForPostprocessing(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShortList[] getPackedPositions() {
|
||||||
|
return chunk.getPackedPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void func_201636_b(short packedPosition, int index) {
|
||||||
|
chunk.func_201636_b(packedPosition, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addTileEntity(CompoundNBT nbt) {
|
||||||
|
chunk.addTileEntity(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public CompoundNBT getDeferredTileEntity(BlockPos pos) {
|
||||||
|
return chunk.getDeferredTileEntity(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public CompoundNBT getTileEntityNBT(BlockPos pos) {
|
||||||
|
return chunk.getTileEntityNBT(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<BlockPos> getLightSources() {
|
||||||
|
return chunk.getLightSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITickList<Block> getBlocksToBeTicked() {
|
||||||
|
return chunk.getBlocksToBeTicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITickList<Fluid> getFluidsToBeTicked() {
|
||||||
|
return chunk.getFluidsToBeTicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BitSet getCarvingMask(GenerationStage.Carving type) {
|
||||||
|
return chunk.getCarvingMask(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpgradeData getUpgradeData() {
|
||||||
|
return chunk.getUpgradeData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInhabitedTime(long newInhabitedTime) {
|
||||||
|
chunk.setInhabitedTime(newInhabitedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getInhabitedTime() {
|
||||||
|
return chunk.getInhabitedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShortList getList(ShortList[] p_217308_0_, int p_217308_1_) {
|
||||||
|
return IChunk.getList(p_217308_0_, p_217308_1_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasLight() {
|
||||||
|
return chunk.hasLight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLight(boolean p_217305_1_) {
|
||||||
|
chunk.setLight(p_217305_1_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public IWorld getWorldForge() {
|
||||||
|
return chunk.getWorldForge();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public TileEntity getTileEntity(BlockPos pos) {
|
||||||
|
return chunk.getTileEntity(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockState(BlockPos pos) {
|
||||||
|
return chunk.getBlockState(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidState getFluidState(BlockPos pos) {
|
||||||
|
return chunk.getFluidState(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightValue(BlockPos pos) {
|
||||||
|
return chunk.getLightValue(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLightLevel() {
|
||||||
|
return chunk.getMaxLightLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return chunk.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockRayTraceResult rayTraceBlocks(RayTraceContext context) {
|
||||||
|
return chunk.rayTraceBlocks(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public BlockRayTraceResult rayTraceBlocks(Vec3d p_217296_1_, Vec3d p_217296_2_, BlockPos p_217296_3_, VoxelShape p_217296_4_, BlockState p_217296_5_) {
|
||||||
|
return chunk.rayTraceBlocks(p_217296_1_, p_217296_2_, p_217296_3_, p_217296_4_, p_217296_5_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T func_217300_a(RayTraceContext p_217300_0_, BiFunction<RayTraceContext, BlockPos, T> p_217300_1_, Function<RayTraceContext, T> p_217300_2_) {
|
||||||
|
return IBlockReader.func_217300_a(p_217300_0_, p_217300_1_, p_217300_2_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public StructureStart getStructureStart(String stucture) {
|
||||||
|
return chunk.getStructureStart(stucture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putStructureStart(String structureIn, StructureStart structureStartIn) {
|
||||||
|
chunk.putStructureStart(structureIn, structureStartIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LongSet getStructureReferences(String structureIn) {
|
||||||
|
return chunk.getStructureReferences(structureIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addStructureReference(String strucutre, long reference) {
|
||||||
|
chunk.addStructureReference(strucutre, reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, LongSet> getStructureReferences() {
|
||||||
|
return chunk.getStructureReferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStructureReferences(Map<String, LongSet> p_201606_1_) {
|
||||||
|
chunk.setStructureReferences(p_201606_1_);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class ChunkSurfaceBuffer extends ChunkDelegate {
|
||||||
|
|
||||||
|
private int surfaceTop;
|
||||||
|
private int surfaceBottom;
|
||||||
|
|
||||||
|
public ChunkSurfaceBuffer(IChunk chunk) {
|
||||||
|
super(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving) {
|
||||||
|
if (pos.getY() > surfaceTop) {
|
||||||
|
surfaceTop = pos.getY();
|
||||||
|
}
|
||||||
|
if (pos.getY() < surfaceBottom) {
|
||||||
|
surfaceBottom = pos.getY();
|
||||||
|
}
|
||||||
|
return super.setBlockState(pos, state, isMoving);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSurfaceTop() {
|
||||||
|
return surfaceTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSurfaceBottom() {
|
||||||
|
return surfaceBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurfaceLevel(int y) {
|
||||||
|
surfaceTop = y;
|
||||||
|
surfaceBottom = y;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.column;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.ChunkSurfaceBuffer;
|
||||||
|
import me.dags.noise.Source;
|
||||||
|
import me.dags.noise.source.FastSource;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
|
public interface ColumnDecorator {
|
||||||
|
|
||||||
|
FastSource variance = (FastSource) Source.perlin(0, 100, 1);
|
||||||
|
ThreadLocal<BlockPos.Mutable> pos = ThreadLocal.withInitial(BlockPos.Mutable::new);
|
||||||
|
ThreadLocal<BlockPos.Mutable> pos1 = ThreadLocal.withInitial(BlockPos.Mutable::new);
|
||||||
|
|
||||||
|
void decorate(IChunk chunk, ProcessorContext context, int x, int y, int z);
|
||||||
|
|
||||||
|
default void decorate(ChunkSurfaceBuffer buffer, ProcessorContext context, int x, int y, int z) {
|
||||||
|
decorate(buffer.getChunk(), context, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void fillDown(IChunk chunk, int x, int z, int from, int to, BlockState state) {
|
||||||
|
for (int dy = from; dy > to; dy--) {
|
||||||
|
chunk.setBlockState(pos.get().setPos(x, dy, z), state, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static float getNoise(float x, float z, int seed, float scale, float bias) {
|
||||||
|
return (variance.getValue(x, z, seed) * scale) + bias;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float getNoise(float x, float z, int seed, int scale, int bias) {
|
||||||
|
return getNoise(x, z, seed, scale / 255F, bias / 255F);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.column;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DecoratorManager {
|
||||||
|
|
||||||
|
private final List<ColumnDecorator> baseDecorators;
|
||||||
|
private final List<ColumnDecorator> featureDecorators;
|
||||||
|
|
||||||
|
public DecoratorManager(List<ColumnDecorator> baseDecorators, List<ColumnDecorator> featureDecorators) {
|
||||||
|
this.baseDecorators = baseDecorators;
|
||||||
|
this.featureDecorators = featureDecorators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerBaseDecorator(ColumnDecorator decorator) {
|
||||||
|
baseDecorators.add(decorator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerFeatureDecorator(ColumnDecorator decorator) {
|
||||||
|
featureDecorators.add(decorator);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.column;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.ChunkContext;
|
||||||
|
import com.terraforged.core.cell.Cell;
|
||||||
|
import com.terraforged.core.world.climate.Climate;
|
||||||
|
import com.terraforged.core.world.heightmap.Levels;
|
||||||
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
|
import com.terraforged.core.world.terrain.Terrains;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
|
public class ProcessorContext extends ChunkContext {
|
||||||
|
|
||||||
|
public final Levels levels;
|
||||||
|
public final Climate climate;
|
||||||
|
public final Terrains terrains;
|
||||||
|
|
||||||
|
public Biome biome;
|
||||||
|
public Cell<Terrain> cell;
|
||||||
|
|
||||||
|
public ProcessorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate) {
|
||||||
|
super(chunk);
|
||||||
|
this.levels = levels;
|
||||||
|
this.climate = climate;
|
||||||
|
this.terrains = terrain;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface;
|
||||||
|
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public class CachedSurface {
|
||||||
|
|
||||||
|
public Biome biome;
|
||||||
|
public Surface surface;
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface;
|
||||||
|
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.surface.builder.Combiner;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
|
public interface Surface {
|
||||||
|
|
||||||
|
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||||
|
|
||||||
|
void buildSurface(int x, int z, int height, SurfaceContext ctx);
|
||||||
|
|
||||||
|
default void fill(int x, int z, int start, int end, IChunk chunk, BlockState state) {
|
||||||
|
if (start < end) {
|
||||||
|
for (int y = start; y < end; y++) {
|
||||||
|
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||||
|
}
|
||||||
|
} else if (start > end) {
|
||||||
|
for (int y = start; y > end; y--) {
|
||||||
|
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default Surface then(Surface next) {
|
||||||
|
return new Combiner(this, next);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.column.ProcessorContext;
|
||||||
|
import com.terraforged.core.world.climate.Climate;
|
||||||
|
import com.terraforged.core.world.heightmap.Levels;
|
||||||
|
import com.terraforged.core.world.terrain.Terrains;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
import net.minecraft.world.gen.GenerationSettings;
|
||||||
|
|
||||||
|
public class SurfaceContext extends ProcessorContext {
|
||||||
|
|
||||||
|
public final BlockState solid;
|
||||||
|
public final BlockState fluid;
|
||||||
|
public final int seaLevel;
|
||||||
|
public final long seed;
|
||||||
|
public final CachedSurface cached = new CachedSurface();
|
||||||
|
|
||||||
|
public double noise;
|
||||||
|
|
||||||
|
public SurfaceContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate, GenerationSettings settings, long seed) {
|
||||||
|
super(chunk, levels, terrain, climate);
|
||||||
|
this.solid = settings.getDefaultBlock();
|
||||||
|
this.fluid = settings.getDefaultFluid();
|
||||||
|
this.seed = seed;
|
||||||
|
this.seaLevel = levels.waterLevel;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.surface.builder.Delegate;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SurfaceManager {
|
||||||
|
|
||||||
|
private final Map<Biome, Surface> surfaces = new HashMap<>();
|
||||||
|
|
||||||
|
public SurfaceManager replace(Biome biome, Surface surface) {
|
||||||
|
surfaces.put(biome, surface);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SurfaceManager extend(Biome biome, Surface surface) {
|
||||||
|
Surface result = getOrCreateSurface(biome).then(surface);
|
||||||
|
return replace(biome, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Surface getSurface(SurfaceContext context) {
|
||||||
|
if (context.biome == context.cached.biome) {
|
||||||
|
return context.cached.surface;
|
||||||
|
}
|
||||||
|
context.cached.biome = context.biome;
|
||||||
|
context.cached.surface = getOrCreateSurface(context.biome);
|
||||||
|
return context.cached.surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Surface getOrCreateSurface(Biome biome) {
|
||||||
|
return surfaces.computeIfAbsent(biome, Delegate.FUNC);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface.builder;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.surface.Surface;
|
||||||
|
import com.terraforged.api.chunk.surface.SurfaceContext;
|
||||||
|
|
||||||
|
public class Combiner implements Surface {
|
||||||
|
|
||||||
|
private final Surface first;
|
||||||
|
private final Surface second;
|
||||||
|
|
||||||
|
public Combiner(Surface first, Surface second) {
|
||||||
|
this.first = first;
|
||||||
|
this.second = second;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildSurface(int x, int z, int height, SurfaceContext ctx) {
|
||||||
|
first.buildSurface(x, z, height, ctx);
|
||||||
|
second.buildSurface(x, z, height, ctx);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.chunk.surface.builder;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.surface.Surface;
|
||||||
|
import com.terraforged.api.chunk.surface.SurfaceContext;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class Delegate implements Surface {
|
||||||
|
|
||||||
|
public static final Function<Biome, Surface> FUNC = Delegate::new;
|
||||||
|
|
||||||
|
private final ConfiguredSurfaceBuilder<?> surfaceBuilder;
|
||||||
|
|
||||||
|
private Delegate(Biome biome) {
|
||||||
|
this(biome.getSurfaceBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Delegate(ConfiguredSurfaceBuilder<?> surfaceBuilder) {
|
||||||
|
this.surfaceBuilder = surfaceBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildSurface(int x, int z, int height, SurfaceContext context) {
|
||||||
|
surfaceBuilder.setSeed(context.seed);
|
||||||
|
|
||||||
|
surfaceBuilder.buildSurface(
|
||||||
|
context.random,
|
||||||
|
context.chunk,
|
||||||
|
context.biome,
|
||||||
|
x,
|
||||||
|
z,
|
||||||
|
height,
|
||||||
|
context.noise,
|
||||||
|
context.solid,
|
||||||
|
context.fluid,
|
||||||
|
context.seaLevel,
|
||||||
|
context.seed
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.event;
|
||||||
|
|
||||||
|
import com.terraforged.api.chunk.column.DecoratorManager;
|
||||||
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
|
import com.terraforged.api.material.geology.GeologyManager;
|
||||||
|
import com.terraforged.api.material.layer.LayerManager;
|
||||||
|
import com.terraforged.core.world.terrain.provider.TerrainProvider;
|
||||||
|
import com.terraforged.feature.modifier.FeatureModifiers;
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
|
public abstract class TerraEvent<T> extends Event {
|
||||||
|
|
||||||
|
private final T manager;
|
||||||
|
|
||||||
|
public TerraEvent(T manager) {
|
||||||
|
this.manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getManager() {
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to register custom biome Surface decorators
|
||||||
|
*/
|
||||||
|
public static class Surface extends TerraEvent<SurfaceManager> {
|
||||||
|
|
||||||
|
public Surface(SurfaceManager manager) {
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register additional layer blocks (such as Snow Layers)
|
||||||
|
*/
|
||||||
|
public static class Layers extends TerraEvent<LayerManager> {
|
||||||
|
|
||||||
|
public Layers(LayerManager manager) {
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom Strata and Geologies
|
||||||
|
*/
|
||||||
|
public static class Geology extends TerraEvent<GeologyManager> {
|
||||||
|
|
||||||
|
public Geology(GeologyManager manager) {
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom FeatureModifiers
|
||||||
|
*/
|
||||||
|
public static class Features extends TerraEvent<FeatureModifiers> {
|
||||||
|
|
||||||
|
public Features(FeatureModifiers manager) {
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom Terrain Populators
|
||||||
|
*/
|
||||||
|
public static class Terrain extends TerraEvent<TerrainProvider> {
|
||||||
|
|
||||||
|
public Terrain(TerrainProvider provider) {
|
||||||
|
super(provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom ColumnDecorators
|
||||||
|
* - base decorators process chunk columns early in the generation process (before biome surfaces etc)
|
||||||
|
* - feature decorators process chunk columns late in the generation process (after all features have been placed)
|
||||||
|
*/
|
||||||
|
public static class Decorators extends TerraEvent<DecoratorManager> {
|
||||||
|
|
||||||
|
public Decorators(DecoratorManager manager) {
|
||||||
|
super(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class MaterialTags {
|
||||||
|
|
||||||
|
public static final Tag<Block> WG_ROCK = tag("rock");
|
||||||
|
public static final Tag<Block> WG_EARTH = tag("earth");
|
||||||
|
public static final Tag<Block> WG_CLAY = tag("clay");
|
||||||
|
public static final Tag<Block> WG_SEDIMENT = tag("sediment");
|
||||||
|
public static final Tag<Block> WG_ORE = tag("ore");
|
||||||
|
public static final Tag<Block> WG_ERODIBLE = tag("erodible");
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Tag<Block> tag(String name) {
|
||||||
|
return new BlockTags.Wrapper(new ResourceLocation("terraforged", name));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.geology;
|
||||||
|
|
||||||
|
import com.terraforged.core.world.geology.Geology;
|
||||||
|
import com.terraforged.core.world.geology.Strata;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public interface GeologyManager {
|
||||||
|
|
||||||
|
StrataGenerator getStrataGenerator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a global strata group (applies to any biome that does not have specific geology defined.
|
||||||
|
*/
|
||||||
|
void register(Strata<BlockState> strata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a biome specific strata group.
|
||||||
|
*/
|
||||||
|
default void register(Biome biome, Strata<BlockState> strata) {
|
||||||
|
register(biome, strata, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a biome specific strata group.
|
||||||
|
*/
|
||||||
|
void register(Biome biome, Strata<BlockState> strata, boolean inheritGlobal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register/replace a biome-specific geology group
|
||||||
|
*/
|
||||||
|
void register(Biome biome, Geology<BlockState> geology);
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.geology;
|
||||||
|
|
||||||
|
import me.dags.noise.util.NoiseUtil;
|
||||||
|
|
||||||
|
public class StrataConfig {
|
||||||
|
|
||||||
|
public Config soil = new Config(0, 1, 0.1F, 0.25F);
|
||||||
|
public Config sediment = new Config(0, 2, 0.05F, 0.15F);
|
||||||
|
public Config clay = new Config(0, 2, 0.05F, 0.1F);
|
||||||
|
public Config rock = new Config(10, 30, 0.1F, 1.5F);
|
||||||
|
|
||||||
|
public static class Config {
|
||||||
|
|
||||||
|
public int minLayers;
|
||||||
|
public int maxLayers;
|
||||||
|
public float minDepth;
|
||||||
|
public float maxDepth;
|
||||||
|
|
||||||
|
public Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Config(int minLayers, int maxLayers, float minDepth, float maxDepth) {
|
||||||
|
this.minLayers = minLayers;
|
||||||
|
this.maxLayers = maxLayers;
|
||||||
|
this.minDepth = minDepth;
|
||||||
|
this.maxDepth = maxDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLayers(float value) {
|
||||||
|
int range = maxLayers - minLayers;
|
||||||
|
return minLayers + NoiseUtil.round(value * range);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDepth(float value) {
|
||||||
|
float range = maxDepth - minDepth;
|
||||||
|
return minDepth + value * range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.geology;
|
||||||
|
|
||||||
|
import com.terraforged.core.world.geology.Strata;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
|
public interface StrataGenerator {
|
||||||
|
|
||||||
|
Strata<BlockState> generate(int seed, int scale, StrataConfig config);
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.layer;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LayerManager {
|
||||||
|
|
||||||
|
private final Map<Block, LayerMaterial> layers = new HashMap<>();
|
||||||
|
|
||||||
|
public LayerManager() {
|
||||||
|
register(LayerMaterial.of(Blocks.SNOW_BLOCK, Blocks.SNOW));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(LayerMaterial material) {
|
||||||
|
register(material.getLayerType(), material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Block block, LayerMaterial material) {
|
||||||
|
layers.put(block, material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayerMaterial getMaterial(Block block) {
|
||||||
|
return layers.get(block);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.layer;
|
||||||
|
|
||||||
|
import me.dags.noise.util.NoiseUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.state.IProperty;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
|
||||||
|
public class LayerMaterial {
|
||||||
|
|
||||||
|
private static final BlockState AIR = Blocks.AIR.getDefaultState();
|
||||||
|
|
||||||
|
private final int min;
|
||||||
|
private final int max;
|
||||||
|
private final BlockState fullState;
|
||||||
|
private final BlockState layerState;
|
||||||
|
private final IProperty<Integer> layerProperty;
|
||||||
|
|
||||||
|
private LayerMaterial(BlockState fullState, BlockState layerState, IProperty<Integer> layerProperty) {
|
||||||
|
this.layerProperty = layerProperty;
|
||||||
|
this.min = min(layerProperty);
|
||||||
|
this.max = max(layerProperty);
|
||||||
|
this.layerState = layerState;
|
||||||
|
this.fullState = fullState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getLayerType() {
|
||||||
|
return layerState.getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getFull() {
|
||||||
|
return fullState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getState(float value) {
|
||||||
|
return getState(getLevel(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getState(int level) {
|
||||||
|
if (level < min) {
|
||||||
|
return LayerMaterial.AIR;
|
||||||
|
}
|
||||||
|
if (level >= max) {
|
||||||
|
return fullState;
|
||||||
|
}
|
||||||
|
return layerState.with(layerProperty, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel(float depth) {
|
||||||
|
if (depth > 1) {
|
||||||
|
depth = getDepth(depth);
|
||||||
|
} else if (depth < 0) {
|
||||||
|
depth = 0;
|
||||||
|
}
|
||||||
|
return NoiseUtil.round(depth * max);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDepth(float height) {
|
||||||
|
return height - (int) height;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int min(IProperty<Integer> property) {
|
||||||
|
return property.getAllowedValues().stream().min(Integer::compareTo).orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int max(IProperty<Integer> property) {
|
||||||
|
return property.getAllowedValues().stream().max(Integer::compareTo).orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(Block block) {
|
||||||
|
return of(block, BlockStateProperties.LAYERS_1_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(Block block, IProperty<Integer> property) {
|
||||||
|
return of(block.getDefaultState(), block.getDefaultState(), property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(Block full, Block layer) {
|
||||||
|
return of(full.getDefaultState(), layer.getDefaultState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(Block full, Block layer, IProperty<Integer> property) {
|
||||||
|
return of(full.getDefaultState(), layer.getDefaultState(), property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(BlockState layer) {
|
||||||
|
return of(layer, BlockStateProperties.LAYERS_1_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(BlockState layer, IProperty<Integer> property) {
|
||||||
|
return of(layer.with(property, max(property)), layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(BlockState full, BlockState layer) {
|
||||||
|
return of(full, layer, BlockStateProperties.LAYERS_1_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LayerMaterial of(BlockState full, BlockState layer, IProperty<Integer> property) {
|
||||||
|
return new LayerMaterial(full, layer, property);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.state;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class CachedState extends StateSupplier {
|
||||||
|
|
||||||
|
private static final List<CachedState> all = new ArrayList<>();
|
||||||
|
|
||||||
|
private final Supplier<BlockState> supplier;
|
||||||
|
|
||||||
|
private volatile BlockState reference = null;
|
||||||
|
|
||||||
|
public CachedState(Supplier<BlockState> supplier) {
|
||||||
|
this.supplier = supplier;
|
||||||
|
all.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState get() {
|
||||||
|
BlockState state = reference;
|
||||||
|
if (state == null) {
|
||||||
|
state = supplier.get();
|
||||||
|
reference = state;
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CachedState clear() {
|
||||||
|
reference = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearAll() {
|
||||||
|
all.forEach(CachedState::clear);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.state;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
public class DefaultState extends StateSupplier {
|
||||||
|
|
||||||
|
private final ResourceLocation name;
|
||||||
|
|
||||||
|
private DefaultState(ResourceLocation name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CachedState cache() {
|
||||||
|
return new CachedState(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState get() {
|
||||||
|
Block block = ForgeRegistries.BLOCKS.getValue(name);
|
||||||
|
if (block == null) {
|
||||||
|
block = Blocks.AIR;
|
||||||
|
}
|
||||||
|
return block.getDefaultState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultState of(String name) {
|
||||||
|
return of(new ResourceLocation(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultState of(ResourceLocation name) {
|
||||||
|
return new DefaultState(name);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.state;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public abstract class StateSupplier implements Supplier<BlockState> {
|
||||||
|
|
||||||
|
public Block getBlock() {
|
||||||
|
return get().getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getDefaultState() {
|
||||||
|
return getBlock().getDefaultState();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 TerraForged
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.terraforged.api.material.state;
|
||||||
|
|
||||||
|
public class States {
|
||||||
|
|
||||||
|
public static final StateSupplier BEDROCK = DefaultState.of("minecraft:bedrock").cache();
|
||||||
|
public static final StateSupplier COARSE_DIRT = DefaultState.of("minecraft:coarse_dirt").cache();
|
||||||
|
public static final StateSupplier DIRT = DefaultState.of("minecraft:dirt").cache();
|
||||||
|
public static final StateSupplier GRASS_BLOCK = DefaultState.of("minecraft:grass_block").cache();
|
||||||
|
public static final StateSupplier CLAY = DefaultState.of("minecraft:clay").cache();
|
||||||
|
public static final StateSupplier GRAVEL = DefaultState.of("minecraft:gravel").cache();
|
||||||
|
public static final StateSupplier LAVA = DefaultState.of("minecraft:lava").cache();
|
||||||
|
public static final StateSupplier PACKED_ICE = DefaultState.of("minecraft:packed_ice").cache();
|
||||||
|
public static final StateSupplier RED_SANDSTONE = DefaultState.of("minecraft:red_sandstone").cache();
|
||||||
|
public static final StateSupplier SAND = DefaultState.of("minecraft:sand").cache();
|
||||||
|
public static final StateSupplier SANDSTONE = DefaultState.of("minecraft:sandstone").cache();
|
||||||
|
public static final StateSupplier SNOW_BLOCK = DefaultState.of("minecraft:snow_block").cache();
|
||||||
|
public static final StateSupplier STONE = DefaultState.of("minecraft:stone").cache();
|
||||||
|
public static final StateSupplier WATER = DefaultState.of("minecraft:water").cache();
|
||||||
|
}
|
@ -68,6 +68,9 @@ public abstract class Renderer {
|
|||||||
return height * el;
|
return height * el;
|
||||||
} else if (applet.controller.getColorMode() == Applet.BIOME_TYPE) {
|
} else if (applet.controller.getColorMode() == Applet.BIOME_TYPE) {
|
||||||
Color c = cell.biomeType.getColor();
|
Color c = cell.biomeType.getColor();
|
||||||
|
if (cell.riverMask < 0.2) {
|
||||||
|
c = Color.white;
|
||||||
|
}
|
||||||
float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
|
float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
|
||||||
float bri = 90 + cell.biomeTypeMask * 10;
|
float bri = 90 + cell.biomeTypeMask * 10;
|
||||||
applet.fill(hsb[0] * 100, hsb[1] * 100, hsb[2] * bri);
|
applet.fill(hsb[0] * 100, hsb[1] * 100, hsb[2] * bri);
|
||||||
|
@ -39,17 +39,17 @@ public class FilterSettings {
|
|||||||
@Serializable
|
@Serializable
|
||||||
public static class Erosion {
|
public static class Erosion {
|
||||||
|
|
||||||
@Range(min = 1000, max = 30000)
|
@Range(min = 1000, max = 50000)
|
||||||
@Comment("Controls the number of erosion iterations")
|
@Comment("Controls the number of erosion iterations")
|
||||||
public int iterations = 15000;
|
public int iterations = 12000;
|
||||||
|
|
||||||
@Range(min = 0F, max = 1F)
|
@Range(min = 0F, max = 1F)
|
||||||
@Comment("Controls how quickly material dissolves (during erosion)")
|
@Comment("Controls how quickly material dissolves (during erosion)")
|
||||||
public float erosionRate = 0.35F;
|
public float erosionRate = 0.4F;
|
||||||
|
|
||||||
@Range(min = 0F, max = 1F)
|
@Range(min = 0F, max = 1F)
|
||||||
@Comment("Controls how quickly material is deposited (during erosion)")
|
@Comment("Controls how quickly material is deposited (during erosion)")
|
||||||
public float depositeRate = 0.5F;
|
public float depositeRate = 0.4F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 51b518ee0b8d5bb53357ce9e8259aab41934d331
|
Subproject commit 7b36c6610c90356a6c047e789245fd5357fe7d23
|
@ -2,5 +2,6 @@ rootProject.name = "TerraForged"
|
|||||||
include ":Noise2D"
|
include ":Noise2D"
|
||||||
include ":FeatureManager"
|
include ":FeatureManager"
|
||||||
include ":TerraForgedCore"
|
include ":TerraForgedCore"
|
||||||
include ":TerraForgedApp"
|
include ":TerraForgedAPI"
|
||||||
include ":TerraForgedMod"
|
include ":TerraForgedMod"
|
||||||
|
include ":TerraForgedApp"
|
Loading…
Reference in New Issue
Block a user