diff --git a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java index 97e55341c..f1277e18c 100644 --- a/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java +++ b/src/main/java/com/volmit/iris/engine/mantle/EngineMantle.java @@ -22,7 +22,6 @@ import com.volmit.iris.Iris; import com.volmit.iris.core.project.loader.IrisData; import com.volmit.iris.engine.IrisComplex; import com.volmit.iris.engine.framework.Engine; -import com.volmit.iris.engine.framework.EngineComponent; import com.volmit.iris.engine.framework.EngineFramework; import com.volmit.iris.engine.framework.EngineTarget; import com.volmit.iris.engine.object.common.IObjectPlacer; diff --git a/src/main/java/com/volmit/iris/engine/mantle/MantleSized.java b/src/main/java/com/volmit/iris/engine/mantle/MantleSized.java new file mode 100644 index 000000000..1668a182d --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/mantle/MantleSized.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface MantleSized { + public int getMaxChunkSize(); +} diff --git a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java index 136c3b27e..574c4a650 100644 --- a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java +++ b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java @@ -18,6 +18,9 @@ package com.volmit.iris.util.mantle; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.matter.IrisMatter; @@ -33,6 +36,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray; * Mantle Chunks are fully atomic & thread safe */ public class MantleChunk { + private final KSet flags; private final AtomicReferenceArray sections; /** @@ -43,6 +47,7 @@ public class MantleChunk { @ChunkCoordinates public MantleChunk(int sectionHeight) { sections = new AtomicReferenceArray<>(sectionHeight); + flags = new KSet<>(); } /** @@ -55,7 +60,13 @@ public class MantleChunk { */ public MantleChunk(int sectionHeight, DataInputStream din) throws IOException, ClassNotFoundException { this(sectionHeight); - int s = Varint.readUnsignedVarInt(din); + int s = din.readByte(); + int f = din.readByte(); + + for(int i = 0; i < f; i++) + { + flags.add(din.readUTF()); + } for (int i = 0; i < s; i++) { if (din.readBoolean()) { @@ -64,6 +75,24 @@ public class MantleChunk { } } + public void flag(String s, boolean f) + { + if(f) + { + flags.add(s); + } + + else + { + flags.remove(s); + } + } + + public boolean isFlagged(String s) + { + return flags.contains(s); + } + /** * Check if a section exists (same as get(section) != null) * @@ -130,7 +159,13 @@ public class MantleChunk { * @throws IOException shit happens */ public void write(DataOutputStream dos) throws IOException { - Varint.writeUnsignedVarInt(sections.length(), dos); + dos.writeByte(sections.length()); + dos.writeByte(flags.size()); + + for(String i : flags) + { + dos.writeUTF(i); + } for (int i = 0; i < sections.length(); i++) { if (exists(i)) { diff --git a/src/main/java/com/volmit/iris/util/matter/slices/ZoneMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/ZoneMatter.java new file mode 100644 index 000000000..35a914042 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/matter/slices/ZoneMatter.java @@ -0,0 +1,59 @@ +/* + * 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.engine.object.feature.IrisFeaturePositional; +import com.volmit.iris.util.matter.Sliced; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +@Sliced +public class ZoneMatter extends RawMatter { + public ZoneMatter() { + this(1, 1, 1); + } + + public ZoneMatter(int width, int height, int depth) { + super(width, height, depth, IrisFeaturePositional.class); + } + + @Override + public void setRaw(int x, int y, int z, IrisFeaturePositional t) { + for(int i = 0; i < getHeight(); i++) + { + if(get(x, i, z) == null) + { + super.setRaw(x, i, z, t); + break; + } + } + } + + @Override + public void writeNode(IrisFeaturePositional b, DataOutputStream dos) throws IOException { + b.write(dos); + } + + @Override + public IrisFeaturePositional readNode(DataInputStream din) throws IOException { + return IrisFeaturePositional.read(din); + } +}