mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Mantle fixes
This commit is contained in:
parent
1781ff36c6
commit
366c903f84
@ -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;
|
||||
|
23
src/main/java/com/volmit/iris/engine/mantle/MantleSized.java
Normal file
23
src/main/java/com/volmit/iris/engine/mantle/MantleSized.java
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.mantle;
|
||||
|
||||
public interface MantleSized {
|
||||
public int getMaxChunkSize();
|
||||
}
|
@ -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<String> flags;
|
||||
private final AtomicReferenceArray<Matter> 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)) {
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<IrisFeaturePositional> {
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user