diff --git a/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java index 808775b69..dd7c89886 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngineMantle.java @@ -23,10 +23,7 @@ import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.MantleComponent; -import com.volmit.iris.engine.mantle.components.MantleCarvingComponent; -import com.volmit.iris.engine.mantle.components.MantleFeatureComponent; -import com.volmit.iris.engine.mantle.components.MantleJigsawComponent; -import com.volmit.iris.engine.mantle.components.MantleObjectComponent; +import com.volmit.iris.engine.mantle.components.*; import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.engine.object.IrisDepositGenerator; import com.volmit.iris.engine.object.IrisFeaturePotential; @@ -63,6 +60,7 @@ public class IrisEngineMantle implements EngineMantle { radius = radCache.aquire(this::computeParallaxSize); components = new KList<>(); registerComponent(new MantleCarvingComponent(this)); + registerComponent(new MantleFluidBodyComponent(this)); registerComponent(new MantleFeatureComponent(this)); registerComponent(new MantleJigsawComponent(this)); registerComponent(new MantleObjectComponent(this)); diff --git a/src/main/java/com/volmit/iris/engine/mantle/components/MantleFluidBodyComponent.java b/src/main/java/com/volmit/iris/engine/mantle/components/MantleFluidBodyComponent.java new file mode 100644 index 000000000..d8120d736 --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/mantle/components/MantleFluidBodyComponent.java @@ -0,0 +1,60 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.mantle.components; + +import com.volmit.iris.engine.data.cache.Cache; +import com.volmit.iris.engine.mantle.EngineMantle; +import com.volmit.iris.engine.mantle.IrisMantleComponent; +import com.volmit.iris.engine.mantle.MantleWriter; +import com.volmit.iris.engine.object.IrisBiome; +import com.volmit.iris.engine.object.IrisCarving; +import com.volmit.iris.engine.object.IrisRegion; +import com.volmit.iris.util.documentation.ChunkCoordinates; +import com.volmit.iris.util.mantle.MantleFlag; +import com.volmit.iris.util.math.RNG; + +import java.util.function.Consumer; + +public class MantleFluidBodyComponent extends IrisMantleComponent { + public MantleFluidBodyComponent(EngineMantle engineMantle) { + super(engineMantle, MantleFlag.CARVED); + } + + @Override + public void generateLayer(MantleWriter writer, int x, int z, Consumer post) { + RNG rng = new RNG(Cache.key(x, z) + seed()); + int xxx = 8 + (x << 4); + int zzz = 8 + (z << 4); + IrisRegion region = getComplex().getRegionStream().get(xxx, zzz); + IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz); + carve(writer, rng, x, z, region, biome); + } + + @ChunkCoordinates + private void carve(MantleWriter writer, RNG rng, int cx, int cz, IrisRegion region, IrisBiome biome) { + carve(getDimension().getCarving(), writer, new RNG((rng.nextLong() * cx) + 490495 + cz), cx, cz); + carve(biome.getCarving(), writer, new RNG((rng.nextLong() * cx) + 490495 + cz), cx, cz); + carve(region.getCarving(), writer, new RNG((rng.nextLong() * cx) + 490495 + cz), cx, cz); + } + + @ChunkCoordinates + private void carve(IrisCarving carving, MantleWriter writer, RNG rng, int cx, int cz) { + carving.doCarving(writer, rng, getEngineMantle().getEngine(), cx << 4, -1, cz << 4); + } +} diff --git a/src/main/java/com/volmit/iris/util/matter/MatterFluidBody.java b/src/main/java/com/volmit/iris/util/matter/MatterFluidBody.java new file mode 100644 index 000000000..1846cf8e7 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/MatterFluidBody.java @@ -0,0 +1,30 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.matter; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class MatterFluidBody { + private final boolean body; + private final String customBiome; + private final boolean lava; +} diff --git a/src/main/java/com/volmit/iris/util/matter/slices/FluidBodyMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/FluidBodyMatter.java new file mode 100644 index 000000000..9354bbcbf --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/slices/FluidBodyMatter.java @@ -0,0 +1,57 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.matter.slices; + +import com.volmit.iris.util.matter.MatterFluidBody; +import com.volmit.iris.util.matter.Sliced; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +@Sliced +public class FluidBodyMatter extends RawMatter { + public static MatterFluidBody get(String customBiome, boolean lava) { + return new MatterFluidBody(true, customBiome, lava); + } + + public FluidBodyMatter() { + this(1, 1, 1); + } + + public FluidBodyMatter(int width, int height, int depth) { + super(width, height, depth, MatterFluidBody.class); + } + + @Override + public void writeNode(MatterFluidBody b, DataOutputStream dos) throws IOException { + dos.writeBoolean(b.isBody()); + dos.writeBoolean(b.isLava()); + dos.writeUTF(b.getCustomBiome()); + } + + @Override + public MatterFluidBody readNode(DataInputStream din) throws IOException { + boolean b = din.readBoolean(); + boolean l = din.readBoolean(); + String v = din.readUTF(); + + return new MatterFluidBody(b, v, l); + } +}