9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 10:39:07 +00:00
This commit is contained in:
cyberpwn
2021-08-27 11:29:18 -04:00
parent 2fa5c7eca4
commit 3118f743a0
7 changed files with 166 additions and 30 deletions

View File

@@ -30,6 +30,7 @@ import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.*;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.modifier.IrisCarveModifier;
import com.volmit.iris.engine.modifier.IrisDepositModifier;
import com.volmit.iris.engine.modifier.IrisPostModifier;
import com.volmit.iris.engine.object.biome.IrisBiome;
@@ -66,7 +67,6 @@ import java.util.concurrent.atomic.AtomicLong;
@Data
public class IrisEngine implements Engine {
// TODO: Remove block population, stop using bukkit
private final AtomicInteger generated;
private final AtomicInteger generatedLast;
private final AtomicDouble perSecond;
@@ -95,6 +95,7 @@ public class IrisEngine implements Engine {
private EngineActuator<BlockData> decorantActuator;
private EngineActuator<Biome> biomeActuator;
private EngineModifier<BlockData> depositModifier;
private EngineModifier<BlockData> caveModifier;
private EngineModifier<BlockData> postModifier;
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
private final AtomicBoolean cleaning;
@@ -141,6 +142,7 @@ public class IrisEngine implements Engine {
decorantActuator.close();
biomeActuator.close();
depositModifier.close();
caveModifier.close();
postModifier.close();
effects.close();
}
@@ -157,6 +159,7 @@ public class IrisEngine implements Engine {
biomeActuator = new IrisBiomeActuator(this);
depositModifier = new IrisDepositModifier(this);
postModifier = new IrisPostModifier(this);
caveModifier = new IrisCarveModifier(this);
effects = new IrisEngineEffects(this);
J.a(this::computeBiomeMaxes);
} catch (Throwable e) {
@@ -334,6 +337,7 @@ public class IrisEngine implements Engine {
getBiomeActuator().close();
getDepositModifier().close();
getPostModifier().close();
getCaveModifier().close();
getMantle().close();
getComplex().close();
getData().dump();
@@ -411,8 +415,9 @@ public class IrisEngine implements Engine {
getBiomeActuator().actuate(x, z, vbiomes, multicore);
getDecorantActuator().actuate(x, z, blocks, multicore);
getPostModifier().modify(x, z, vblocks, multicore);
getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore);
getDepositModifier().modify(x, z, vblocks, multicore);
getCaveModifier().modify(x >> 4,z >> 4, vblocks, multicore);
getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore);
}
getMetrics().getTotal().put(p.getMilliseconds());
generated.incrementAndGet();

View File

@@ -52,6 +52,7 @@ import com.volmit.iris.util.mantle.MantleFlag;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterUpdate;
import com.volmit.iris.util.matter.slices.UpdateMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
@@ -95,16 +96,6 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
void recycle();
EngineActuator<BlockData> getTerrainActuator();
EngineActuator<BlockData> getDecorantActuator();
EngineActuator<Biome> getBiomeActuator();
EngineModifier<BlockData> getDepositModifier();
EngineModifier<BlockData> getPostModifier();
void close();
IrisContext getContext();
@@ -244,7 +235,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
default void updateChunk(Chunk c) {
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
PrecisionStopwatch p = PrecisionStopwatch.start();
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), UpdateMatter.MatterUpdate.class, (x, y, z, v) -> {
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterUpdate.class, (x, y, z, v) -> {
if (v != null && v.isUpdate()) {
int vx = x & 15;
int vz = z & 15;
@@ -299,6 +290,12 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
}
}
}
else
{
block.setType(Material.AIR, false);
block.setBlockData(data, true);
}
}
@Override

View File

@@ -0,0 +1,89 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.modifier;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedModifier;
import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.engine.object.regional.IrisRegion;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.HeightMap;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.matter.MatterCavern;
import com.volmit.iris.util.matter.slices.CavernMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.BlockVector;
public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
private final RNG rng;
private final BlockData AIR = Material.CAVE_AIR.createBlockData();
public IrisCarveModifier(Engine engine) {
super(engine, "Carve");
rng = new RNG(getEngine().getWorld().seed() + 3297778).nextParallelRNG(67648777);
}
@Override
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
PrecisionStopwatch p = PrecisionStopwatch.start();
Mantle mantle = getEngine().getMantle().getMantle();
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
mc.iterate(MatterCavern.class, (xx, yy, zz, c) -> {
int rx = xx & 15;
int rz = zz & 15;
boolean caveAbove = mantle.get(xx, yy+1, zz, MatterCavern.class) != null;
BlockData currentAbove = output.get(rx, yy+1, rz);
BlockData current = output.get(rx, yy, rz);
if(current.getMaterial().isAir())
{
return;
}
if(B.isFluid(currentAbove) && !caveAbove)
{
getEngine().getMantle().updateBlock(xx, yy+1, zz);
}
if(B.isFluid(current))
{
getEngine().getMantle().updateBlock(xx, yy, zz);
return;
}
if(B.isFoliage(currentAbove) && !caveAbove)
{
output.set(rx, yy+1, rz, AIR);
getEngine().getMantle().updateBlock(xx, yy+2, zz);
}
output.set(rx, yy, rz, AIR);
});
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.matter;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class MatterCavern {
private final boolean cavern;
}

View File

@@ -0,0 +1,28 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.matter;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class MatterUpdate {
private final boolean update;
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.util.matter.MatterCavern;
import com.volmit.iris.util.matter.Sliced;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -27,7 +28,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
@Sliced
public class CavernMatter extends RawMatter<CavernMatter.MatterCavern> {
public class CavernMatter extends RawMatter<MatterCavern> {
public static final MatterCavern ON = new MatterCavern(true);
public static final MatterCavern OFF = new MatterCavern(false);
@@ -41,18 +42,11 @@ public class CavernMatter extends RawMatter<CavernMatter.MatterCavern> {
@Override
public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException {
dos.writeBoolean(b.cavern);
dos.writeBoolean(b.isCavern());
}
@Override
public MatterCavern readNode(DataInputStream din) throws IOException {
return din.readBoolean() ? ON : OFF;
}
@Data
@AllArgsConstructor
public static class MatterCavern {
private final boolean cavern;
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.util.matter.MatterUpdate;
import com.volmit.iris.util.matter.Sliced;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -27,7 +28,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
@Sliced
public class UpdateMatter extends RawMatter<UpdateMatter.MatterUpdate> {
public class UpdateMatter extends RawMatter<MatterUpdate> {
public static final MatterUpdate ON = new MatterUpdate(true);
public static final MatterUpdate OFF = new MatterUpdate(false);
@@ -41,17 +42,11 @@ public class UpdateMatter extends RawMatter<UpdateMatter.MatterUpdate> {
@Override
public void writeNode(MatterUpdate b, DataOutputStream dos) throws IOException {
dos.writeBoolean(b.update);
dos.writeBoolean(b.isUpdate());
}
@Override
public MatterUpdate readNode(DataInputStream din) throws IOException {
return din.readBoolean() ? ON : OFF;
}
@Data
@AllArgsConstructor
public static class MatterUpdate {
private final boolean update;
}
}