mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cleanup
This commit is contained in:
parent
6683eee49a
commit
6a68da0559
@ -524,30 +524,18 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
try
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
String[] cc = e.getStackTrace()[1].getClassName().split("\\Q.\\E");
|
||||
|
||||
if(cc.length > 5)
|
||||
{
|
||||
if (cc.length > 5) {
|
||||
debug(cc[3] + "/" + cc[4] + "/" + cc[cc.length - 1], e.getStackTrace()[1].getLineNumber(), string);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
debug(cc[3] + "/" + cc[4], e.getStackTrace()[1].getLineNumber(), string);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable ex)
|
||||
{
|
||||
} catch (Throwable ex) {
|
||||
debug("Origin", -1, string);
|
||||
}
|
||||
}
|
||||
|
@ -102,40 +102,29 @@ public class CommandIrisStudioBeautify extends MortarCommand {
|
||||
}
|
||||
|
||||
private void fixBlocks(JSONObject obj, File f) {
|
||||
for(String i : obj.keySet())
|
||||
{
|
||||
for (String i : obj.keySet()) {
|
||||
Object o = obj.get(i);
|
||||
|
||||
if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":"))
|
||||
{
|
||||
if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) {
|
||||
obj.put(i, "minecraft:" + o);
|
||||
Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath());
|
||||
}
|
||||
|
||||
if(o instanceof JSONObject)
|
||||
{
|
||||
if (o instanceof JSONObject) {
|
||||
fixBlocks((JSONObject) o, f);
|
||||
}
|
||||
|
||||
else if(o instanceof JSONArray)
|
||||
{
|
||||
} else if (o instanceof JSONArray) {
|
||||
fixBlocks((JSONArray) o, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fixBlocks(JSONArray obj, File f) {
|
||||
for(int i = 0; i < obj.length(); i++)
|
||||
{
|
||||
for (int i = 0; i < obj.length(); i++) {
|
||||
Object o = obj.get(i);
|
||||
|
||||
if(o instanceof JSONObject)
|
||||
{
|
||||
if (o instanceof JSONObject) {
|
||||
fixBlocks((JSONObject) o, f);
|
||||
}
|
||||
|
||||
else if(o instanceof JSONArray)
|
||||
{
|
||||
} else if (o instanceof JSONArray) {
|
||||
fixBlocks((JSONArray) o, f);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.engine;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.*;
|
||||
@ -29,13 +28,9 @@ import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
||||
import com.volmit.iris.engine.object.engine.IrisEngineData;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
|
@ -36,7 +36,6 @@ import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.IrisLock;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -1069,6 +1069,7 @@ public interface Hunk<T> {
|
||||
|
||||
/**
|
||||
* Create a hunk that is optimized for specific uses
|
||||
*
|
||||
* @param w width
|
||||
* @param h height
|
||||
* @param d depth
|
||||
@ -1078,24 +1079,20 @@ public interface Hunk<T> {
|
||||
* @param <T> the type
|
||||
* @return the hunk
|
||||
*/
|
||||
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent)
|
||||
{
|
||||
if(type.equals(Double.class))
|
||||
{
|
||||
static <T> Hunk<T> newHunk(int w, int h, int d, Class<T> type, boolean packed, boolean concurrent) {
|
||||
if (type.equals(Double.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
if(type.equals(Integer.class))
|
||||
{
|
||||
if (type.equals(Integer.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
}
|
||||
|
||||
if(type.equals(Long.class))
|
||||
{
|
||||
if (type.equals(Long.class)) {
|
||||
return concurrent ?
|
||||
packed ? (Hunk<T>) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d)
|
||||
: packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d);
|
||||
@ -1449,8 +1446,7 @@ public interface Hunk<T> {
|
||||
c[1] = y;
|
||||
}
|
||||
|
||||
default boolean isEmpty()
|
||||
{
|
||||
default boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.util.hunk.storage;
|
||||
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.hunk.HunkFactory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -47,8 +47,7 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
public boolean isEmpty() {
|
||||
return data.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,10 @@ import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.HyperLock;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
|
||||
import java.io.*;
|
||||
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;
|
||||
import java.util.UUID;
|
||||
@ -43,8 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* The mantle can store any type of data slice anywhere and manage regions & IO on it's own.
|
||||
* This class is fully thread safe read & write
|
||||
*/
|
||||
public class Mantle
|
||||
{
|
||||
public class Mantle {
|
||||
private final File dataFolder;
|
||||
private final int worldHeight;
|
||||
private final Map<Long, Long> lastUse;
|
||||
@ -56,12 +58,12 @@ public class Mantle
|
||||
|
||||
/**
|
||||
* Create a new mantle
|
||||
*
|
||||
* @param dataFolder the data folder
|
||||
* @param worldHeight the world's height (in blocks)
|
||||
*/
|
||||
@BlockCoordinates
|
||||
public Mantle(File dataFolder, int worldHeight)
|
||||
{
|
||||
public Mantle(File dataFolder, int worldHeight) {
|
||||
this.hyperLock = new HyperLock();
|
||||
this.closed = new AtomicBoolean(false);
|
||||
this.dataFolder = dataFolder;
|
||||
@ -89,10 +91,8 @@ public class Mantle
|
||||
* @param <T> the type of data (generic method)
|
||||
*/
|
||||
@BlockCoordinates
|
||||
public <T> void set(int x, int y, int z, T t)
|
||||
{
|
||||
if(closed.get())
|
||||
{
|
||||
public <T> void set(int x, int y, int z, T t) {
|
||||
if (closed.get()) {
|
||||
throw new RuntimeException("The Mantle is closed");
|
||||
}
|
||||
|
||||
@ -111,8 +111,7 @@ public class Mantle
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(matter == null)
|
||||
{
|
||||
if (matter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,10 +136,8 @@ public class Mantle
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@BlockCoordinates
|
||||
public <T> T get(int x, int y, int z, Class<T> t)
|
||||
{
|
||||
if(closed.get())
|
||||
{
|
||||
public <T> T get(int x, int y, int z, Class<T> t) {
|
||||
if (closed.get()) {
|
||||
throw new RuntimeException("The Mantle is closed");
|
||||
}
|
||||
|
||||
@ -167,18 +164,15 @@ public class Mantle
|
||||
* any data to the mantle or it's Tectonic Plates. Closing will also flush any
|
||||
* loaded regions to the disk in parallel.
|
||||
*/
|
||||
public synchronized void close()
|
||||
{
|
||||
public synchronized void close() {
|
||||
Iris.debug("Closing The Mantle " + C.DARK_AQUA + dataFolder.getAbsolutePath());
|
||||
if(closed.get())
|
||||
{
|
||||
if (closed.get()) {
|
||||
throw new RuntimeException("The Mantle is closed");
|
||||
}
|
||||
|
||||
closed.set(true);
|
||||
BurstExecutor b = ioBurst.burst(loadedRegions.size());
|
||||
for(Long i : loadedRegions.keySet())
|
||||
{
|
||||
for (Long i : loadedRegions.keySet()) {
|
||||
b.queue(() -> {
|
||||
try {
|
||||
loadedRegions.get(i).write(fileForRegion(dataFolder, i));
|
||||
@ -196,34 +190,29 @@ public class Mantle
|
||||
/**
|
||||
* Save & unload regions that have not been used for more than the
|
||||
* specified amount of milliseconds
|
||||
*
|
||||
* @param idleDuration the duration
|
||||
*/
|
||||
public synchronized void trim(long idleDuration)
|
||||
{
|
||||
if(closed.get())
|
||||
{
|
||||
public synchronized void trim(long idleDuration) {
|
||||
if (closed.get()) {
|
||||
throw new RuntimeException("The Mantle is closed");
|
||||
}
|
||||
|
||||
Iris.debug("Trimming Tectonic Plates older than " + Form.duration((double) idleDuration, 0));
|
||||
unload.clear();
|
||||
|
||||
for(Long i : lastUse.keySet())
|
||||
{
|
||||
if(M.ms() - lastUse.get(i) >= idleDuration)
|
||||
{
|
||||
for (Long i : lastUse.keySet()) {
|
||||
if (M.ms() - lastUse.get(i) >= idleDuration) {
|
||||
unload.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for(Long i : unload)
|
||||
{
|
||||
for (Long i : unload) {
|
||||
TectonicPlate m = loadedRegions.remove(i);
|
||||
lastUse.remove(i);
|
||||
Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + i);
|
||||
|
||||
if(m != null)
|
||||
{
|
||||
if (m != null) {
|
||||
ioBurst.lazy(() -> {
|
||||
try {
|
||||
m.write(fileForRegion(dataFolder, i));
|
||||
@ -238,39 +227,33 @@ public class Mantle
|
||||
/**
|
||||
* This retreives a future of the Tectonic Plate at the given coordinates.
|
||||
* All methods accessing tectonic plates should go through this method
|
||||
*
|
||||
* @param x the region x
|
||||
* @param z the region z
|
||||
* @return the future of a tectonic plate.
|
||||
*/
|
||||
@RegionCoordinates
|
||||
private CompletableFuture<TectonicPlate> get(int x, int z)
|
||||
{
|
||||
private CompletableFuture<TectonicPlate> get(int x, int z) {
|
||||
return ioBurst.completeValue(() -> hyperLock.withResult(x, z, () -> {
|
||||
Long k = key(x, z);
|
||||
lastUse.put(k, M.ms());
|
||||
TectonicPlate region = loadedRegions.get(k);
|
||||
|
||||
if(region != null)
|
||||
{
|
||||
if (region != null) {
|
||||
return region;
|
||||
}
|
||||
|
||||
File file = fileForRegion(dataFolder, x, z);
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (file.exists()) {
|
||||
try {
|
||||
FileInputStream fin = new FileInputStream(file);
|
||||
DataInputStream din = new DataInputStream(fin);
|
||||
region = new TectonicPlate(worldHeight, din);
|
||||
din.close();
|
||||
loadedRegions.put(k, region);
|
||||
Iris.debug("Loaded Tectonic Plate " + C.DARK_GREEN + x + " " + z + C.DARK_AQUA + " " + file.getName());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead.");
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
@ -300,8 +283,7 @@ public class Mantle
|
||||
return f;
|
||||
}
|
||||
|
||||
public static Long key(int x, int z)
|
||||
{
|
||||
public static Long key(int x, int z) {
|
||||
return Cache.key(x, z);
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,10 @@
|
||||
|
||||
package com.volmit.iris.util.mantle;
|
||||
|
||||
import com.volmit.iris.engine.data.chunk.MCATerrainChunk;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.matter.IrisMatter;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
import com.volmit.iris.util.nbt.mca.Section;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@ -40,16 +37,17 @@ public class MantleChunk {
|
||||
|
||||
/**
|
||||
* Create a mantle chunk
|
||||
*
|
||||
* @param sectionHeight the height of the world in sections (blocks >> 4)
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public MantleChunk(int sectionHeight)
|
||||
{
|
||||
public MantleChunk(int sectionHeight) {
|
||||
sections = new AtomicReferenceArray<>(sectionHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a mantle chunk from a data stream
|
||||
*
|
||||
* @param sectionHeight the height of the world in sections (blocks >> 4)
|
||||
* @param din the data input
|
||||
* @throws IOException shit happens
|
||||
@ -59,10 +57,8 @@ public class MantleChunk {
|
||||
this(sectionHeight);
|
||||
int s = Varint.readUnsignedVarInt(din);
|
||||
|
||||
for(int i = 0; i < s; i++)
|
||||
{
|
||||
if(din.readBoolean())
|
||||
{
|
||||
for (int i = 0; i < s; i++) {
|
||||
if (din.readBoolean()) {
|
||||
sections.set(i, Matter.read(din));
|
||||
}
|
||||
}
|
||||
@ -70,59 +66,56 @@ public class MantleChunk {
|
||||
|
||||
/**
|
||||
* Check if a section exists (same as get(section) != null)
|
||||
*
|
||||
* @param section the section (0 - (worldHeight >> 4))
|
||||
* @return true if it exists
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public boolean exists(int section)
|
||||
{
|
||||
public boolean exists(int section) {
|
||||
return get(section) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get thje matter at the given section or null if it doesnt exist
|
||||
*
|
||||
* @param section the section (0 - (worldHeight >> 4))
|
||||
* @return the matter or null if it doesnt exist
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public Matter get(int section)
|
||||
{
|
||||
public Matter get(int section) {
|
||||
return sections.get(section);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all matter from this chunk
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
for(int i = 0; i < sections.length(); i++)
|
||||
{
|
||||
public void clear() {
|
||||
for (int i = 0; i < sections.length(); i++) {
|
||||
delete(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the matter from the given section
|
||||
*
|
||||
* @param section the section (0 - (worldHeight >> 4))
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public void delete(int section)
|
||||
{
|
||||
public void delete(int section) {
|
||||
sections.set(section, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create a new matter section at the given section
|
||||
*
|
||||
* @param section the section (0 - (worldHeight >> 4))
|
||||
* @return the matter
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public Matter getOrCreate(int section)
|
||||
{
|
||||
public Matter getOrCreate(int section) {
|
||||
Matter matter = get(section);
|
||||
|
||||
if(matter == null)
|
||||
{
|
||||
if (matter == null) {
|
||||
matter = new IrisMatter(16, 16, 16);
|
||||
sections.set(section, matter);
|
||||
}
|
||||
@ -132,23 +125,19 @@ public class MantleChunk {
|
||||
|
||||
/**
|
||||
* Write this chunk to a data stream
|
||||
*
|
||||
* @param dos the stream
|
||||
* @throws IOException shit happens
|
||||
*/
|
||||
public void write(DataOutputStream dos) throws IOException {
|
||||
Varint.writeUnsignedVarInt(sections.length(), dos);
|
||||
|
||||
for(int i = 0; i < sections.length(); i++)
|
||||
{
|
||||
if(exists(i))
|
||||
{
|
||||
for (int i = 0; i < sections.length(); i++) {
|
||||
if (exists(i)) {
|
||||
dos.writeBoolean(true);
|
||||
Matter matter = get(i);
|
||||
matter.writeDos(dos);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
dos.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,17 @@ public class TectonicPlate {
|
||||
|
||||
/**
|
||||
* Create a new tectonic plate
|
||||
*
|
||||
* @param worldHeight the height of the world
|
||||
*/
|
||||
public TectonicPlate(int worldHeight)
|
||||
{
|
||||
public TectonicPlate(int worldHeight) {
|
||||
this.sectionHeight = worldHeight >> 4;
|
||||
this.chunks = new AtomicReferenceArray<>(1024);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a tectonic plate from a data stream
|
||||
*
|
||||
* @param worldHeight the height of the world
|
||||
* @param din the data input
|
||||
* @throws IOException shit happens yo
|
||||
@ -53,10 +54,8 @@ public class TectonicPlate {
|
||||
public TectonicPlate(int worldHeight, DataInputStream din) throws IOException, ClassNotFoundException {
|
||||
this(worldHeight);
|
||||
|
||||
for(int i = 0; i < chunks.length(); i++)
|
||||
{
|
||||
if(din.readBoolean())
|
||||
{
|
||||
for (int i = 0; i < chunks.length(); i++) {
|
||||
if (din.readBoolean()) {
|
||||
chunks.set(i, new MantleChunk(sectionHeight, din));
|
||||
}
|
||||
}
|
||||
@ -64,63 +63,60 @@ public class TectonicPlate {
|
||||
|
||||
/**
|
||||
* Check if a chunk exists in this plate or not (same as get(x, z) != null)
|
||||
*
|
||||
* @param x the chunk relative x (0-31)
|
||||
* @param z the chunk relative z (0-31)
|
||||
* @return true if the chunk exists
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public boolean exists(int x, int z)
|
||||
{
|
||||
public boolean exists(int x, int z) {
|
||||
return get(x, z) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a chunk at the given coordinates or null if it doesnt exist
|
||||
*
|
||||
* @param x the chunk relative x (0-31)
|
||||
* @param z the chunk relative z (0-31)
|
||||
* @return the chunk or null if it doesnt exist
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public MantleChunk get(int x, int z)
|
||||
{
|
||||
public MantleChunk get(int x, int z) {
|
||||
return chunks.get(index(x, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all chunks from this tectonic plate
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
for(int i = 0; i < chunks.length(); i++)
|
||||
{
|
||||
public void clear() {
|
||||
for (int i = 0; i < chunks.length(); i++) {
|
||||
chunks.set(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a chunk from this tectonic plate
|
||||
*
|
||||
* @param x the chunk relative x (0-31)
|
||||
* @param z the chunk relative z (0-31)
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public void delete(int x, int z)
|
||||
{
|
||||
public void delete(int x, int z) {
|
||||
chunks.set(index(x, z), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a tectonic plate, or create one and insert it & return it if it diddnt exist
|
||||
*
|
||||
* @param x the chunk relative x (0-31)
|
||||
* @param z the chunk relative z (0-31)
|
||||
* @return the chunk (read or created & inserted)
|
||||
*/
|
||||
@ChunkCoordinates
|
||||
public MantleChunk getOrCreate(int x, int z)
|
||||
{
|
||||
public MantleChunk getOrCreate(int x, int z) {
|
||||
MantleChunk chunk = get(x, z);
|
||||
|
||||
if(chunk == null)
|
||||
{
|
||||
if (chunk == null) {
|
||||
chunk = new MantleChunk(sectionHeight);
|
||||
chunks.set(index(x, z), chunk);
|
||||
}
|
||||
@ -135,6 +131,7 @@ public class TectonicPlate {
|
||||
|
||||
/**
|
||||
* Write this tectonic plate to file
|
||||
*
|
||||
* @param file the file to write it to
|
||||
* @throws IOException shit happens
|
||||
*/
|
||||
@ -148,17 +145,16 @@ public class TectonicPlate {
|
||||
|
||||
/**
|
||||
* Write this tectonic plate to a data stream
|
||||
*
|
||||
* @param dos the data output
|
||||
* @throws IOException shit happens
|
||||
*/
|
||||
public void write(DataOutputStream dos) throws IOException {
|
||||
for(int i = 0; i < chunks.length(); i++)
|
||||
{
|
||||
for (int i = 0; i < chunks.length(); i++) {
|
||||
MantleChunk chunk = chunks.get(i);
|
||||
dos.writeBoolean(chunk != null);
|
||||
|
||||
if(chunk != null)
|
||||
{
|
||||
if (chunk != null) {
|
||||
chunk.write(dos);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -355,12 +354,10 @@ public interface Matter {
|
||||
return matter;
|
||||
}
|
||||
|
||||
default int getTotalCount()
|
||||
{
|
||||
default int getTotalCount() {
|
||||
int m = 0;
|
||||
|
||||
for(MatterSlice<?> i : getSliceMap().values())
|
||||
{
|
||||
for (MatterSlice<?> i : getSliceMap().values()) {
|
||||
m += i.getEntryCount();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ package com.volmit.iris.util.matter;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.hunk.storage.MappedHunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -116,17 +115,13 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
palette.writePalette(dos);
|
||||
dos.writeBoolean(isMapped());
|
||||
|
||||
if(isMapped())
|
||||
{
|
||||
if (isMapped()) {
|
||||
Varint.writeUnsignedVarInt(getEntryCount(), dos);
|
||||
iterateSyncIO((x, y, z, b) -> {
|
||||
Varint.writeUnsignedVarInt(Cache.to1D(x, y, z, w, h), dos);
|
||||
palette.writeNode(b, dos);
|
||||
});
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iterateSyncIO((x, y, z, b) -> palette.writeNode(b, dos));
|
||||
}
|
||||
}
|
||||
@ -135,8 +130,7 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
MatterPalette<T> palette = new MatterPalette<T>(this, din);
|
||||
if(din.readBoolean())
|
||||
{
|
||||
if (din.readBoolean()) {
|
||||
int nodes = Varint.readUnsignedVarInt(din);
|
||||
int[] pos;
|
||||
|
||||
@ -144,10 +138,7 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
pos = Cache.to3D(Varint.readUnsignedVarInt(din), w, h);
|
||||
setRaw(pos[0], pos[1], pos[2], palette.readNode(din));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
iterateSyncIO((x, y, z, b) -> setRaw(x, y, z, palette.readNode(din)));
|
||||
}
|
||||
}
|
||||
@ -156,18 +147,15 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
rotate(x, y, z, (_x, _y, _z) -> n.slice(getType()));
|
||||
}
|
||||
|
||||
default boolean containsKey(BlockVector v)
|
||||
{
|
||||
default boolean containsKey(BlockVector v) {
|
||||
return get(v.getBlockX(), v.getBlockY(), v.getBlockZ()) != null;
|
||||
}
|
||||
|
||||
default void put(BlockVector v, T d)
|
||||
{
|
||||
default void put(BlockVector v, T d) {
|
||||
set(v.getBlockX(), v.getBlockY(), v.getBlockZ(), d);
|
||||
}
|
||||
|
||||
default T get(BlockVector v)
|
||||
{
|
||||
default T get(BlockVector v) {
|
||||
return get(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
||||
import com.volmit.iris.engine.parallax.ParallaxWorld;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.World;
|
||||
|
@ -67,19 +67,12 @@ public class HyperLock {
|
||||
Throwable ee = null;
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
ee = e;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
unlock(x, z);
|
||||
|
||||
if(ee != null)
|
||||
{
|
||||
if (ee != null) {
|
||||
throw ee;
|
||||
}
|
||||
}
|
||||
@ -90,19 +83,12 @@ public class HyperLock {
|
||||
IOException ee = null;
|
||||
try {
|
||||
r.run();
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
ee = e;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
unlock(x, z);
|
||||
|
||||
if(ee != null)
|
||||
{
|
||||
if (ee != null) {
|
||||
throw ee;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user