mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-09 17:26:22 +00:00
Cleanup
This commit is contained in:
@@ -34,9 +34,7 @@ import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.HyperLock;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
@@ -44,7 +42,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* The mantle can store any type of data slice anywhere and manage regions & IO on it's own.
|
||||
@@ -81,28 +78,23 @@ public class Mantle {
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public void raiseFlag(int x, int z, MantleFlag flag, Runnable r)
|
||||
{
|
||||
if(!hasFlag(x, z, flag))
|
||||
{
|
||||
public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) {
|
||||
if (!hasFlag(x, z, flag)) {
|
||||
flag(x, z, flag, true);
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public void lowerFlag(int x, int z, MantleFlag flag, Runnable r)
|
||||
{
|
||||
if(hasFlag(x, z, flag))
|
||||
{
|
||||
public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) {
|
||||
if (hasFlag(x, z, flag)) {
|
||||
flag(x, z, flag, false);
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public void flag(int x, int z, MantleFlag flag, boolean flagged)
|
||||
{
|
||||
public void flag(int x, int z, MantleFlag flag, boolean flagged) {
|
||||
try {
|
||||
get(x >> 5, z >> 5).get().getOrCreate(x & 31, z & 31).flag(flag, flagged);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
@@ -111,12 +103,9 @@ public class Mantle {
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator, MantleFlag... requiredFlags)
|
||||
{
|
||||
for(MantleFlag i : requiredFlags)
|
||||
{
|
||||
if(!hasFlag(x, z, i))
|
||||
{
|
||||
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator, MantleFlag... requiredFlags) {
|
||||
for (MantleFlag i : requiredFlags) {
|
||||
if (!hasFlag(x, z, i)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -129,8 +118,7 @@ public class Mantle {
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public boolean hasFlag(int x, int z, MantleFlag flag)
|
||||
{
|
||||
public boolean hasFlag(int x, int z, MantleFlag flag) {
|
||||
try {
|
||||
return get(x >> 5, z >> 5).get().getOrCreate(x & 31, z & 31).isFlagged(flag);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
@@ -274,7 +262,7 @@ public class Mantle {
|
||||
}
|
||||
|
||||
for (Long i : unload) {
|
||||
hyperLock.withLong(i, () ->{
|
||||
hyperLock.withLong(i, () -> {
|
||||
TectonicPlate m = loadedRegions.remove(i);
|
||||
lastUse.remove(i);
|
||||
|
||||
@@ -302,8 +290,7 @@ public class Mantle {
|
||||
Long k = key(x, z);
|
||||
TectonicPlate p = loadedRegions.get(k);
|
||||
|
||||
if(p != null)
|
||||
{
|
||||
if (p != null) {
|
||||
lastUse.put(k, M.ms());
|
||||
return CompletableFuture.completedFuture(p);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.mantle;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.collection.StateList;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.function.Consumer4;
|
||||
import com.volmit.iris.util.matter.IrisMatter;
|
||||
@@ -52,8 +48,7 @@ public class MantleChunk {
|
||||
sections = new AtomicReferenceArray<>(sectionHeight);
|
||||
flags = new AtomicIntegerArray(MantleFlag.values().length);
|
||||
|
||||
for (int i = 0; i < flags.length(); i++)
|
||||
{
|
||||
for (int i = 0; i < flags.length(); i++) {
|
||||
flags.set(i, 0);
|
||||
}
|
||||
}
|
||||
@@ -70,8 +65,7 @@ public class MantleChunk {
|
||||
this(sectionHeight);
|
||||
int s = din.readByte();
|
||||
|
||||
for(int i = 0; i < flags.length(); i++)
|
||||
{
|
||||
for (int i = 0; i < flags.length(); i++) {
|
||||
flags.set(i, din.readBoolean() ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -176,38 +170,30 @@ public class MantleChunk {
|
||||
}
|
||||
|
||||
private void trimSlice(int i) {
|
||||
if(exists(i))
|
||||
{
|
||||
if (exists(i)) {
|
||||
Matter m = get(i);
|
||||
|
||||
if(m.getSliceMap().isEmpty())
|
||||
{
|
||||
if (m.getSliceMap().isEmpty()) {
|
||||
sections.set(i, null);
|
||||
}
|
||||
|
||||
else{
|
||||
} else {
|
||||
m.trimSlices();
|
||||
if(m.getSliceMap().isEmpty())
|
||||
{
|
||||
if (m.getSliceMap().isEmpty()) {
|
||||
sections.set(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void iterate(Class<T> type, Consumer4<Integer, Integer, Integer,T> iterator) {
|
||||
for(int i = 0; i < sections.length(); i++)
|
||||
{
|
||||
public <T> void iterate(Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) {
|
||||
for (int i = 0; i < sections.length(); i++) {
|
||||
int bs = (i << 4);
|
||||
Matter matter = get(i);
|
||||
|
||||
if(matter != null)
|
||||
{
|
||||
if (matter != null) {
|
||||
MatterSlice<T> t = matter.getSlice(type);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
t.iterateSync((a, b, c, f) -> iterator.accept(a,b + bs, c, f));
|
||||
if (t != null) {
|
||||
t.iterateSync((a, b, c, f) -> iterator.accept(a, b + bs, c, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@ public enum MantleFlag {
|
||||
OBJECT,
|
||||
UPDATE,
|
||||
JIGSAW,
|
||||
FEATURE
|
||||
;
|
||||
static StateList getStateList()
|
||||
{
|
||||
FEATURE;
|
||||
|
||||
static StateList getStateList() {
|
||||
return new StateList(MantleFlag.values());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,10 +172,7 @@ public class TectonicPlate {
|
||||
if (chunk != null) {
|
||||
dos.writeBoolean(true);
|
||||
chunk.write(dos);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dos.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user