fix geology decorator which broke during the threading refactor
This commit is contained in:
parent
73b5e57579
commit
421f1e637f
@ -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;
|
||||||
|
|
||||||
|
public interface BiomeRegistry {
|
||||||
|
|
||||||
|
void register(TransientBiome biome);
|
||||||
|
}
|
@ -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.biome;
|
||||||
|
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
|
||||||
|
public abstract class TransientBiome extends Biome {
|
||||||
|
|
||||||
|
protected TransientBiome(Builder biomeBuilder) {
|
||||||
|
super(biomeBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGrassColor(double x, double z) {
|
||||||
|
return getBase().getGrassColor(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFoliageColor() {
|
||||||
|
return getBase().getFoliageColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSkyColor() {
|
||||||
|
return getBase().getSkyColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Biome getBase();
|
||||||
|
}
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package com.terraforged.api.event;
|
package com.terraforged.api.event;
|
||||||
|
|
||||||
|
import com.terraforged.api.biome.BiomeRegistry;
|
||||||
import com.terraforged.api.biome.modifier.ModifierManager;
|
import com.terraforged.api.biome.modifier.ModifierManager;
|
||||||
import com.terraforged.api.chunk.column.DecoratorManager;
|
import com.terraforged.api.chunk.column.DecoratorManager;
|
||||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
@ -89,6 +90,16 @@ public abstract class SetupEvent<T> extends Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom Transient Biomes
|
||||||
|
*/
|
||||||
|
public static class Biomes extends SetupEvent<BiomeRegistry> {
|
||||||
|
|
||||||
|
public Biomes(BiomeRegistry manager, GeneratorContext context) {
|
||||||
|
super(manager, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register custom BiomeModifiers
|
* Register custom BiomeModifiers
|
||||||
*/
|
*/
|
||||||
|
@ -36,22 +36,22 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Strata<T> {
|
public class Strata<T> {
|
||||||
|
|
||||||
private final float[] depthBuffer;
|
|
||||||
private final Module heightMod;
|
private final Module heightMod;
|
||||||
private final List<Stratum<T>> strata;
|
private final List<Stratum<T>> strata;
|
||||||
|
|
||||||
private Strata(Module heightMod, List<Stratum<T>> strata) {
|
private Strata(Module heightMod, List<Stratum<T>> strata) {
|
||||||
this.strata = strata;
|
this.strata = strata;
|
||||||
this.heightMod = heightMod;
|
this.heightMod = heightMod;
|
||||||
this.depthBuffer = new float[strata.size()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean downwards(final int x, final int y, final int z, Stratum.Visitor<T> visitor) {
|
public boolean downwards(final int x, final int y, final int z, Stratum.Visitor<T> visitor) {
|
||||||
|
DepthBuffer depthBuffer = new DepthBuffer(strata, x, z);
|
||||||
|
|
||||||
int py = y;
|
int py = y;
|
||||||
T last = null;
|
T last = null;
|
||||||
float sum = getDepth(x, z);
|
float sum = depthBuffer.sum;
|
||||||
for (int i = 0; i < strata.size(); i++) {
|
for (int i = 0; i < strata.size(); i++) {
|
||||||
float depth = depthBuffer[i] / sum;
|
float depth = depthBuffer.buffer[i] / sum;
|
||||||
int height = NoiseUtil.round(depth * y);
|
int height = NoiseUtil.round(depth * y);
|
||||||
T value = strata.get(i).getValue();
|
T value = strata.get(i).getValue();
|
||||||
last = value;
|
last = value;
|
||||||
@ -77,10 +77,11 @@ public class Strata<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean upwards(int x, int y, int z, Stratum.Visitor<T> visitor) {
|
public boolean upwards(int x, int y, int z, Stratum.Visitor<T> visitor) {
|
||||||
|
DepthBuffer depthBuffer = new DepthBuffer(strata, x, z);
|
||||||
int py = 0;
|
int py = 0;
|
||||||
float sum = getDepth(x, z);
|
float sum = depthBuffer.sum;
|
||||||
for (int i = strata.size() - 1; i > 0; i--) {
|
for (int i = strata.size() - 1; i > 0; i--) {
|
||||||
float depth = depthBuffer[i] / sum;
|
float depth = depthBuffer.buffer[i] / sum;
|
||||||
int height = NoiseUtil.round(depth * y);
|
int height = NoiseUtil.round(depth * y);
|
||||||
T value = strata.get(i).getValue();
|
T value = strata.get(i).getValue();
|
||||||
for (int dy = 0; dy < height; dy++) {
|
for (int dy = 0; dy < height; dy++) {
|
||||||
@ -100,14 +101,21 @@ public class Strata<T> {
|
|||||||
return (int) (64 * heightMod.getValue(x, z));
|
return (int) (64 * heightMod.getValue(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getDepth(int x, int z) {
|
private static class DepthBuffer {
|
||||||
float sum = 0F;
|
|
||||||
for (int i = 0; i < strata.size(); i++) {
|
private final float sum;
|
||||||
float depth = strata.get(i).getDepth(x, z);
|
private final float[] buffer;
|
||||||
sum += depth;
|
|
||||||
depthBuffer[i] = depth;
|
private <T> DepthBuffer(List<Stratum<T>> strata, int x, int z) {
|
||||||
|
buffer = new float[strata.size()];
|
||||||
|
float sum = 0F;
|
||||||
|
for (int i = 0; i < strata.size(); i++) {
|
||||||
|
float depth = strata.get(i).getDepth(x, z);
|
||||||
|
sum += depth;
|
||||||
|
buffer[i] = depth;
|
||||||
|
}
|
||||||
|
this.sum = sum;
|
||||||
}
|
}
|
||||||
return sum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Builder<T> builder(int seed, me.dags.noise.source.Builder noise) {
|
public static <T> Builder<T> builder(int seed, me.dags.noise.source.Builder noise) {
|
||||||
|
@ -108,6 +108,10 @@ public class StandardTerrainProvider implements TerrainProvider {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected GeneratorContext getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
private TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2) {
|
private TerrainPopulator combine(TerrainPopulator tp1, TerrainPopulator tp2) {
|
||||||
return combine(tp1, tp2, context.seed, config.scale / 2);
|
return combine(tp1, tp2, context.seed, config.scale / 2);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 0cd63563bdc0fad258d78c21dfed1b14c975bdfd
|
Subproject commit 28b3c0bf7a47d22504cb958e5b2a03e585c76cc6
|
Loading…
Reference in New Issue
Block a user