9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00

Merge remote-tracking branch 'upstream/master' into DecreeCommands

This commit is contained in:
CocoTheOwner
2021-08-25 13:08:45 +02:00
129 changed files with 2117 additions and 3505 deletions

View File

@@ -49,12 +49,10 @@ public class IrisContext {
}
public static void dereference() {
synchronized (context)
{
synchronized (context) {
for (Thread i : context.k()) {
if (!i.isAlive() || context.get(i).engine.isClosed()) {
if(context.get(i).engine.isClosed())
{
if (context.get(i).engine.isClosed()) {
Iris.debug("Dereferenced Context<Engine> " + i.getName() + " " + i.getId());
}

View File

@@ -21,7 +21,6 @@ package com.volmit.iris.util.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.scheduling.ChronoLatch;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
@@ -284,8 +283,7 @@ public class B {
return Material.valueOf(bdx.trim().toUpperCase());
} catch (Throwable e) {
Iris.reportError(e);
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Material: " + bdx);
}
return null;
@@ -295,8 +293,7 @@ public class B {
public static Material getMaterial(String bdx) {
Material m = getMaterialOrNull(bdx);
if(m == null)
{
if (m == null) {
return AIR_MATERIAL;
}
@@ -313,8 +310,7 @@ public class B {
BlockData bdx = parseBlockData(bd);
if (bdx == null) {
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data '" + bd + "'");
}
return AIR;
@@ -324,8 +320,7 @@ public class B {
} catch (Throwable e) {
Iris.reportError(e);
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data '" + bdxf + "'");
}
}
@@ -363,8 +358,7 @@ public class B {
return bx;
} catch (Throwable e) {
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data: " + ix);
}

View File

@@ -20,11 +20,9 @@ package com.volmit.iris.util.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
import com.volmit.iris.util.scheduling.jobs.Job;
import com.volmit.iris.util.scheduling.jobs.JobCollection;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import lombok.Builder;
@@ -111,8 +109,7 @@ public class IrisPackRepository {
public void install(VolmitSender sender) throws MalformedURLException {
File pack = Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, getRepo());
if(!pack.exists())
{
if (!pack.exists()) {
File dl = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID() + ".zip");
File work = new File(Iris.getTemp(), "extk-" + UUID.randomUUID());
new JobCollection(Form.capitalize(getRepo()),

View File

@@ -44,18 +44,13 @@ public class DecreeParameter {
public DecreeParameterHandler<?> getHandler() {
return handlerCache.aquire(() -> {
try
{
if(param.customHandler().equals(DummyHandler.class))
{
try {
if (param.customHandler().equals(DummyHandler.class)) {
return DecreeSystem.getHandler(getType());
}
return param.customHandler().getConstructor().newInstance();
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@@ -32,8 +32,7 @@ public interface DecreeParameterHandler<T> {
*/
KList<T> getPossibilities();
default boolean isDummy()
{
default boolean isDummy() {
return false;
}

View File

@@ -25,7 +25,6 @@ import com.volmit.iris.util.decree.DecreeSystem;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.FluidCollisionMode;
import org.bukkit.entity.Player;

View File

@@ -29,8 +29,7 @@ public class DummyHandler implements DecreeParameterHandler<Object> {
return null;
}
public boolean isDummy()
{
public boolean isDummy() {
return true;
}

View File

@@ -16,21 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.hunk.io;
package com.volmit.iris.util.function;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BooleanHunkIOAdapter extends PaletteHunkIOAdapter<Boolean> {
@Override
public void write(Boolean data, DataOutputStream dos) throws IOException {
dos.writeBoolean(data);
}
@Override
public Boolean read(DataInputStream din) throws IOException {
return din.readBoolean();
}
public interface NastySupplier<T> {
T get() throws Throwable;
}

View File

@@ -21,14 +21,12 @@ package com.volmit.iris.util.hunk;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.function.*;
import com.volmit.iris.util.hunk.io.HunkIOAdapter;
import com.volmit.iris.util.hunk.storage.*;
import com.volmit.iris.util.hunk.view.*;
import com.volmit.iris.util.interpolation.InterpolationMethod;
import com.volmit.iris.util.interpolation.InterpolationMethod3D;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.oldnbt.ByteArrayTag;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.stream.interpolation.Interpolated;
@@ -38,9 +36,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -229,18 +225,6 @@ public interface Hunk<T> {
return count.get();
}
default void write(OutputStream s, HunkIOAdapter<T> h) throws IOException {
h.write(this, s);
}
default ByteArrayTag writeByteArrayTag(HunkIOAdapter<T> h, String name) throws IOException {
return h.writeByteArrayTag(this, name);
}
default void write(File s, HunkIOAdapter<T> h) throws IOException {
h.write(this, s);
}
default boolean isAtomic() {
return false;
}
@@ -1450,8 +1434,7 @@ public interface Hunk<T> {
return false;
}
default boolean contains(int x, int y, int z)
{
default boolean contains(int x, int y, int z) {
return x < getWidth() && x >= 0 && y < getHeight() && y >= 0 && z < getDepth() && z >= 0;
}
}

View File

@@ -1,81 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.hunk.Hunk;
import java.io.*;
import java.util.concurrent.atomic.AtomicBoolean;
public abstract class BasicHunkIOAdapter<T> implements HunkIOAdapter<T> {
@Override
public void write(Hunk<T> t, OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
dos.writeShort(t.getWidth() + Short.MIN_VALUE);
dos.writeShort(t.getHeight() + Short.MIN_VALUE);
dos.writeShort(t.getDepth() + Short.MIN_VALUE);
dos.writeInt(t.getNonNullEntries() + Integer.MIN_VALUE);
AtomicBoolean failure = new AtomicBoolean(false);
t.iterate(0, (x, y, z, w) -> {
if (w != null) {
try {
dos.writeShort(x + Short.MIN_VALUE);
dos.writeShort(y + Short.MIN_VALUE);
dos.writeShort(z + Short.MIN_VALUE);
write(w, dos);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
failure.set(true);
}
}
});
dos.close();
}
@Override
public Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException {
DataInputStream din = new DataInputStream(in);
int w = din.readShort() - Short.MIN_VALUE;
int h = din.readShort() - Short.MIN_VALUE;
int d = din.readShort() - Short.MIN_VALUE;
int e = din.readInt() - Integer.MIN_VALUE;
Hunk<T> t = factory.apply(w, h, d);
for (int i = 0; i < e; i++) {
int x = din.readShort() - Short.MIN_VALUE;
int y = din.readShort() - Short.MIN_VALUE;
int z = din.readShort() - Short.MIN_VALUE;
T v = read(din);
if (v == null) {
throw new IOException("NULL VALUE AT " + x + " " + y + " " + z);
}
t.setRaw(x, y, z, v);
}
in.close();
return t;
}
}

View File

@@ -1,56 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.util.data.IOAdapter;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.io.CustomOutputStream;
import com.volmit.iris.util.oldnbt.ByteArrayTag;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public interface HunkIOAdapter<T> extends IOAdapter<T> {
void write(Hunk<T> t, OutputStream out) throws IOException;
Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException;
default void write(Hunk<T> t, File f) throws IOException {
f.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(f);
GZIPOutputStream gzo = new CustomOutputStream(fos, 6);
write(t, gzo);
}
default Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, File f) throws IOException {
return read(factory, new GZIPInputStream(new FileInputStream(f)));
}
default Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, ByteArrayTag f) throws IOException {
return read(factory, new ByteArrayInputStream(f.getValue()));
}
default ByteArrayTag writeByteArrayTag(Hunk<T> tHunk, String name) throws IOException {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
write(tHunk, boas);
return new ByteArrayTag(name, boas.toByteArray());
}
}

View File

@@ -1,101 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.oldnbt.CompoundTag;
import com.volmit.iris.util.oldnbt.NBTInputStream;
import com.volmit.iris.util.oldnbt.NBTOutputStream;
import com.volmit.iris.util.oldnbt.Tag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class HunkRegion {
private final File folder;
private CompoundTag compound;
private final int x;
private final int z;
public HunkRegion(File folder, int x, int z, CompoundTag compound) {
this.compound = fix(compound);
this.folder = folder;
this.x = x;
this.z = z;
folder.mkdirs();
}
public HunkRegion(File folder, int x, int z) {
this(folder, x, z, new CompoundTag(x + "." + z, new KMap<>()));
File f = getFile();
if (f.exists()) {
try {
NBTInputStream in = new NBTInputStream(new FileInputStream(f));
compound = fix((CompoundTag) in.readTag());
in.close();
} catch (Throwable e) {
Iris.reportError(e);
}
}
}
public CompoundTag getCompound() {
return compound;
}
private CompoundTag fix(CompoundTag readTag) {
Map<String, Tag> v = readTag.getValue();
if (!(v instanceof KMap)) {
return new CompoundTag(readTag.getName(), new KMap<>(v));
}
return readTag;
}
public File getFile() {
return new File(folder, x + "." + z + ".dat");
}
public void save() throws IOException {
synchronized (compound) {
File f = getFile();
FileOutputStream fos = new FileOutputStream(f);
NBTOutputStream out = new NBTOutputStream(fos);
out.writeTag(compound);
out.close();
}
}
public int getX() {
return x;
}
public int getZ() {
return z;
}
}

View File

@@ -1,262 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.tile.TileData;
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.function.Function2;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.oldnbt.ByteArrayTag;
import com.volmit.iris.util.oldnbt.CompoundTag;
import com.volmit.iris.util.oldnbt.Tag;
import com.volmit.iris.util.parallel.MultiBurst;
import org.bukkit.block.TileState;
import org.bukkit.block.data.BlockData;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
public class HunkRegionSlice<T> {
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
public static final Function2<Integer, CompoundTag, HunkRegionSlice<TileData<? extends TileState>>> TILE = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new TileDataHunkIOAdapter(), c, "tile");
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t);
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t);
private final Function3<Integer, Integer, Integer, Hunk<T>> factory;
private final HunkIOAdapter<T> adapter;
private final CompoundTag compound;
private final String key;
private final KMap<Position2, Hunk<T>> loadedChunks;
private final KMap<Position2, Long> lastUse;
private final KSet<Position2> save;
private final int height;
public HunkRegionSlice(int height, Function3<Integer, Integer, Integer, Hunk<T>> factory, HunkIOAdapter<T> adapter, CompoundTag compound, String key) {
this.height = height;
this.loadedChunks = new KMap<>();
this.factory = factory;
this.adapter = adapter;
this.compound = compound;
this.save = new KSet<>();
this.key = key;
this.lastUse = new KMap<>();
}
public synchronized int cleanup(long t) {
int v = 0;
if (loadedChunks.size() != lastUse.size()) {
Iris.warn("Incorrect chunk use counts in " + key + " region slice.");
for (Position2 i : lastUse.k()) {
if (!loadedChunks.containsKey(i)) {
Iris.warn(" Missing LoadChunkKey " + i);
}
}
}
for (Position2 i : lastUse.k()) {
Long l = lastUse.get(i);
if (l == null || M.ms() - l > t) {
v++;
MultiBurst.burst.lazy(() -> {
unload(i.getX(), i.getZ());
});
}
}
return v;
}
public synchronized void clear() {
for (String i : new KList<>(compound.getValue().keySet())) {
if (i.startsWith(key + ".")) {
compound.getValue().remove(i);
}
}
}
public synchronized void save(MultiBurst burst) {
try {
for (Position2 i : save.copy()) {
if (i == null) {
continue;
}
save(i.getX(), i.getZ());
try {
save.remove(i);
} catch (Throwable eer) {
Iris.reportError(eer);
}
}
} catch (Throwable ee) {
Iris.reportError(ee);
}
}
public boolean contains(int x, int z) {
return compound.getValue().containsKey(key(x, z));
}
public void delete(int x, int z) {
compound.getValue().remove(key(x, z));
}
public Hunk<T> read(int x, int z) throws IOException {
AtomicReference<IOException> e = new AtomicReference<>();
Hunk<T> xt = null;
Tag t = compound.getValue().get(key(x, z));
if ((t instanceof ByteArrayTag)) {
try {
xt = adapter.read(factory, (ByteArrayTag) t);
} catch (IOException xe) {
Iris.reportError(xe);
e.set(xe);
}
}
if (xt != null) {
return xt;
}
if (e.get() != null) {
throw e.get();
}
return null;
}
public void write(Hunk<T> hunk, int x, int z) throws IOException {
compound.getValue().put(key(x, z), hunk.writeByteArrayTag(adapter, key(x, z)));
}
public synchronized int unloadAll() {
int v = 0;
for (Position2 i : loadedChunks.k()) {
unload(i.getX(), i.getZ());
v++;
}
save.clear();
loadedChunks.clear();
lastUse.clear();
return v;
}
public void save(Hunk<T> region, int x, int z) {
try {
write(region, x, z);
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
public boolean isLoaded(int x, int z) {
return loadedChunks.containsKey(new Position2(x, z));
}
public void save(int x, int z) {
if (isLoaded(x, z)) {
save(get(x, z), x, z);
}
}
public void unload(int x, int z) {
Position2 key = new Position2(x, z);
if (isLoaded(x, z)) {
if (save.contains(key)) {
save(x, z);
save.remove(key);
}
lastUse.remove(key);
loadedChunks.remove(key);
}
}
public Hunk<T> load(int x, int z) {
if (isLoaded(x, z)) {
return loadedChunks.get(new Position2(x, z));
}
Hunk<T> v = null;
if (contains(x, z)) {
try {
v = read(x, z);
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
if (v == null) {
v = factory.apply(16, height, 16);
}
loadedChunks.put(new Position2(x, z), v);
return v;
}
public Hunk<T> get(int x, int z) {
Position2 key = new Position2(x, z);
Hunk<T> c = loadedChunks.get(key);
if (c == null) {
c = load(x, z);
}
lastUse.put(new Position2(x, z), M.ms());
return c;
}
public Hunk<T> getR(int x, int z) {
return get(x, z).readOnly();
}
public Hunk<T> getRW(int x, int z) {
save.add(new Position2(x, z));
return get(x, z);
}
private String key(int x, int z) {
if (x < 0 || x >= 32 || z < 0 || z >= 32) {
throw new IndexOutOfBoundsException("The chunk " + x + " " + z + " is out of bounds max is 31x31");
}
return key + "." + x + "." + z;
}
public int getLoadCount() {
return loadedChunks.size();
}
}

View File

@@ -1,97 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.DataPalette;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.hunk.Hunk;
import java.io.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class PaletteHunkIOAdapter<T> implements HunkIOAdapter<T> {
@Override
public void write(Hunk<T> t, OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
dos.writeShort(t.getWidth() + Short.MIN_VALUE);
dos.writeShort(t.getHeight() + Short.MIN_VALUE);
dos.writeShort(t.getDepth() + Short.MIN_VALUE);
AtomicInteger nonNull = new AtomicInteger(0);
DataPalette<T> palette = new DataPalette<>();
t.iterateSync((x, y, z, w) -> {
if (w != null) {
palette.getIndex(w);
nonNull.getAndAdd(1);
}
});
palette.write(this, dos);
dos.writeInt(nonNull.get() + Integer.MIN_VALUE);
AtomicBoolean failure = new AtomicBoolean(false);
t.iterateSync((x, y, z, w) -> {
if (w != null) {
try {
dos.writeShort(x + Short.MIN_VALUE);
dos.writeShort(y + Short.MIN_VALUE);
dos.writeShort(z + Short.MIN_VALUE);
dos.writeShort(palette.getIndex(w) + Short.MIN_VALUE);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
failure.set(true);
}
}
});
dos.close();
}
@Override
public Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException {
DataInputStream din = new DataInputStream(in);
int w = din.readShort() - Short.MIN_VALUE;
int h = din.readShort() - Short.MIN_VALUE;
int d = din.readShort() - Short.MIN_VALUE;
DataPalette<T> palette = DataPalette.getPalette(this, din);
int e = din.readInt() - Integer.MIN_VALUE;
Hunk<T> t = factory.apply(w, h, d);
for (int i = 0; i < e; i++) {
int x = din.readShort() - Short.MIN_VALUE;
int y = din.readShort() - Short.MIN_VALUE;
int z = din.readShort() - Short.MIN_VALUE;
int vf = din.readShort() - Short.MIN_VALUE;
T v = null;
if (palette.getPalette().hasIndex(vf)) {
v = palette.getPalette().get(vf);
}
if (v != null) {
t.setRaw(x, y, z, v);
}
}
in.close();
return t;
}
}

View File

@@ -1,45 +0,0 @@
/*
* 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.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.tile.TileData;
import org.bukkit.block.TileState;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class TileDataHunkIOAdapter extends PaletteHunkIOAdapter<TileData<? extends TileState>> {
@Override
public void write(TileData<? extends TileState> data, DataOutputStream dos) throws IOException {
data.toBinary(dos);
}
@Override
public TileData<? extends TileState> read(DataInputStream din) throws IOException {
try {
return TileData.read(din);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
throw new IOException();
}
}
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.hunk.storage;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.function.Consumer4IO;
import com.volmit.iris.util.hunk.Hunk;
@@ -49,15 +48,14 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
}
public boolean isEmpty() {
synchronized(data)
{
synchronized (data) {
return data.isEmpty();
}
}
@Override
public void setRaw(int x, int y, int z, T t) {
synchronized(data) {
synchronized (data) {
if (t == null) {
data.remove(index(x, y, z));
return;
@@ -73,8 +71,7 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
synchronized(data)
{
synchronized (data) {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
@@ -90,8 +87,7 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
synchronized(data)
{
synchronized (data) {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
@@ -107,16 +103,14 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public void empty(T b) {
synchronized(data)
{
synchronized (data) {
data.clear();
}
}
@Override
public T getRaw(int x, int y, int z) {
synchronized(data)
{
synchronized (data) {
return data.get(index(x, y, z));
}
}

View File

@@ -45,7 +45,6 @@ import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -90,10 +89,11 @@ public class Mantle {
/**
* Raise a flag if it is lowered currently, If the flag was raised, execute the runnable
* @param x the chunk x
* @param z the chunk z
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag to raise
* @param r the runnable to fire if the flag is now raised (and was previously lowered)
* @param r the runnable to fire if the flag is now raised (and was previously lowered)
*/
@ChunkCoordinates
public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -106,23 +106,24 @@ public class Mantle {
/**
* Obtain a cached writer which only contains cached chunks.
* This avoids locking on regions when writing to lots of chunks
* @param x the x chunk
* @param z the z chunk
*
* @param x the x chunk
* @param z the z chunk
* @param radius the radius chunks
* @return the writer
*/
@ChunkCoordinates
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius)
{
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius) {
return new MantleWriter(engineMantle, this, x, z, radius);
}
/**
* Lower a flag if it is raised. If the flag was lowered (meaning it was previously raised), execute the runnable
* @param x the chunk x
* @param z the chunk z
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag to lower
* @param r the runnable that is fired if the flag was raised but is now lowered
* @param r the runnable that is fired if the flag was raised but is now lowered
*/
@ChunkCoordinates
public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -133,16 +134,16 @@ public class Mantle {
}
@ChunkCoordinates
public MantleChunk getChunk(int x, int z)
{
return get(x>>5, z>>5).getOrCreate(x & 31, z & 31);
public MantleChunk getChunk(int x, int z) {
return get(x >> 5, z >> 5).getOrCreate(x & 31, z & 31);
}
/**
* Flag or unflag a chunk
* @param x the chunk x
* @param z the chunk z
* @param flag the flag
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag
* @param flagged should it be set to flagged or not
*/
@ChunkCoordinates
@@ -152,29 +153,29 @@ public class Mantle {
/**
* Check very quickly if a tectonic plate exists via cached or the file system
*
* @param x the x region coordinate
* @param z the z region coordinate
* @return true if it exists
*/
@RegionCoordinates
public boolean hasTectonicPlate(int x, int z)
{
public boolean hasTectonicPlate(int x, int z) {
Long k = key(x, z);
return loadedRegions.containsKey(k) || fileForRegion(dataFolder, k).exists();
}
/**
* Iterate data in a chunk
* @param x the chunk x
* @param z the chunk z
* @param type the type of data to iterate
*
* @param x the chunk x
* @param z the chunk z
* @param type the type of data to iterate
* @param iterator the iterator (x,y,z,data) -> do stuff
* @param <T> the type of data to iterate
* @param <T> the type of data to iterate
*/
@ChunkCoordinates
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) {
if(!hasTectonicPlate(x >> 5, z >> 5))
{
if (!hasTectonicPlate(x >> 5, z >> 5)) {
return;
}
@@ -183,15 +184,15 @@ public class Mantle {
/**
* Does this chunk have a flag on it?
* @param x the x
* @param z the z
*
* @param x the x
* @param z the z
* @param flag the flag to test
* @return true if it's flagged
*/
@ChunkCoordinates
public boolean hasFlag(int x, int z, MantleFlag flag) {
if(!hasTectonicPlate(x >> 5, z >> 5))
{
if (!hasTectonicPlate(x >> 5, z >> 5)) {
return false;
}
@@ -222,14 +223,10 @@ public class Mantle {
return;
}
if(t instanceof IrisFeaturePositional)
{
if (t instanceof IrisFeaturePositional) {
get((x >> 4) >> 5, (z >> 4) >> 5)
.getOrCreate((x >> 4) & 31, (z >> 4) & 31).addFeature((IrisFeaturePositional) t);
}
else
{
} else {
Matter matter = get((x >> 4) >> 5, (z >> 4) >> 5)
.getOrCreate((x >> 4) & 31, (z >> 4) & 31)
.getOrCreate(y >> 4);
@@ -260,8 +257,7 @@ public class Mantle {
throw new RuntimeException("The Mantle is closed");
}
if(!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5))
{
if (!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5)) {
return null;
}
@@ -277,10 +273,10 @@ public class Mantle {
/**
* Is this mantle closed
*
* @return true if it is
*/
public boolean isClosed()
{
public boolean isClosed() {
return closed.get();
}
@@ -307,13 +303,9 @@ public class Mantle {
});
}
try
{
try {
b.complete();
}
catch(Throwable e)
{
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -457,9 +449,10 @@ public class Mantle {
/**
* Get the file for a region
*
* @param folder the folder
* @param x the x coord
* @param z the z coord
* @param x the x coord
* @param z the z coord
* @return the file
*/
public static File fileForRegion(File folder, int x, int z) {
@@ -468,14 +461,14 @@ public class Mantle {
/**
* Get the file for the given region
*
* @param folder the data folder
* @param key the region key
* @param key the region key
* @return the file
*/
public static File fileForRegion(File folder, Long key) {
File f = new File(folder, "p." + key + ".ttp");
if(!f.getParentFile().exists())
{
if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
return f;
@@ -483,6 +476,7 @@ public class Mantle {
/**
* Get the long value representing a chunk or region coordinate
*
* @param x the x
* @param z the z
* @return the value
@@ -497,33 +491,33 @@ public class Mantle {
/**
* Set a sphere into the mantle
* @param cx the center x
* @param cy the center y
* @param cz the center z
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param radius the radius of this sphere
* @param fill should it be filled? or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param fill should it be filled? or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data)
{
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) {
setElipsoid(cx, cy, cz, radius, radius, radius, fill, data);
}
/**
* Set an elipsoid into the mantle
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param rx the x radius
* @param ry the y radius
* @param rz the z radius
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param rx the x radius
* @param ry the y radius
* @param rz the z radius
* @param fill should it be filled or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
public <T> void setElipsoid(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data)
{
public <T> void setElipsoid(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data) {
rx += 0.5;
ry += 0.5;
rz += 0.5;
@@ -535,11 +529,13 @@ public class Mantle {
final int ceilRadiusZ = (int) Math.ceil(rz);
double nextXn = 0;
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
forX:
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextYn = 0;
forY: for (int y = 0; y <= ceilRadiusY; ++y) {
forY:
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn;
nextYn = (y + 1) * invRadiusY;
double nextZn = 0;
@@ -564,15 +560,15 @@ public class Mantle {
}
}
set(x + cx,y + cy,z + cz, data);
set(-x + cx,y + cy,z + cz, data);
set(x + cx,-y + cy,z + cz, data);
set(x + cx,y + cy,-z + cz, data);
set(-x + cx,y + cy,-z + cz, data);
set(-x + cx,-y + cy,z + cz, data);
set(x + cx,-y + cy,-z + cz, data);
set(-x + cx,y + cy,-z + cz, data);
set(-x + cx,-y + cy,-z + cz, data);
set(x + cx, y + cy, z + cz, data);
set(-x + cx, y + cy, z + cz, data);
set(x + cx, -y + cy, z + cz, data);
set(x + cx, y + cy, -z + cz, data);
set(-x + cx, y + cy, -z + cz, data);
set(-x + cx, -y + cy, z + cz, data);
set(x + cx, -y + cy, -z + cz, data);
set(-x + cx, y + cy, -z + cz, data);
set(-x + cx, -y + cy, -z + cz, data);
}
}
}
@@ -580,26 +576,23 @@ public class Mantle {
/**
* Set a cuboid of data in the mantle
* @param x1 the min x
* @param y1 the min y
* @param z1 the min z
* @param x2 the max x
* @param y2 the max y
* @param z2 the max z
*
* @param x1 the min x
* @param y1 the min y
* @param z1 the min z
* @param x2 the max x
* @param y2 the max y
* @param z2 the max z
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data)
{
int j,k;
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) {
int j, k;
for(int i = x1; i <= x2; i++)
{
for(j = x1; j <= x2; j++)
{
for(k = x1; k <= x2; k++)
{
set(i,j,k,data);
for (int i = x1; i <= x2; i++) {
for (j = x1; j <= x2; j++) {
for (k = x1; k <= x2; k++) {
set(i, j, k, data);
}
}
}
@@ -607,13 +600,14 @@ public class Mantle {
/**
* Set a pyramid of data in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param size the size of the pyramid (width of base & height)
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param size the size of the pyramid (width of base & height)
* @param filled should it be filled or hollow
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
@SuppressWarnings("ConstantConditions")
public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) {
@@ -636,10 +630,11 @@ public class Mantle {
/**
* Set a 3d tube spline interpolated with Kochanek Bartels
*
* @param nodevectors the vector points
* @param radius the radius
* @param filled if it should be filled or hollow
* @param data the data to set
* @param radius the radius
* @param filled if it should be filled or hollow
* @param data the data to set
*/
public <T> void setSpline(List<Vector> nodevectors, double radius, boolean filled, T data) {
setSpline(nodevectors, 0, 0, 0, 10, radius, filled, data);
@@ -647,15 +642,16 @@ public class Mantle {
/**
* Set a 3d tube spline interpolated with Kochanek Bartels
*
* @param nodevectors the spline points
* @param tension the tension 0
* @param bias the bias 0
* @param continuity the continuity 0
* @param quality the quality 10
* @param radius the radius
* @param filled filled or hollow
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param tension the tension 0
* @param bias the bias 0
* @param continuity the continuity 0
* @param quality the quality 10
* @param radius the radius
* @param filled filled or hollow
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setSpline(List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled, T data) {
Set<IrisPosition> vset = new KSet<>();
@@ -687,25 +683,26 @@ public class Mantle {
/**
* Set a 3d line
* @param a the first point
* @param b the second point
*
* @param a the first point
* @param b the second point
* @param radius the radius
* @param filled hollow or filled?
* @param data the data
* @param <T> the type of data to apply to the mantle
* @param data the data
* @param <T> the type of data to apply to the mantle
*/
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data)
{
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) {
setLine(ImmutableList.of(a, b), radius, filled, data);
}
/**
* Set lines for points
*
* @param vectors the points
* @param radius the radius
* @param filled hollow or filled?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param radius the radius
* @param filled hollow or filled?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setLine(List<IrisPosition> vectors, double radius, boolean filled, T data) {
Set<IrisPosition> vset = new KSet<>();
@@ -770,28 +767,30 @@ public class Mantle {
/**
* Set a cylinder in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radius the radius
* @param height the height of the cyl
* @param filled filled or not
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled){
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) {
setCylinder(cx, cy, cz, data, radius, radius, height, filled);
}
/**
* Set a cylinder in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radiusX the x radius
* @param radiusZ the z radius
* @param height the height of this cyl
* @param filled filled or hollow?
* @param height the height of this cyl
* @param filled filled or hollow?
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) {
int affected = 0;
@@ -817,7 +816,8 @@ public class Mantle {
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0;
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
forX:
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextZn = 0;
@@ -850,23 +850,18 @@ public class Mantle {
}
}
public <T> void set(IrisPosition pos, T data)
{
public <T> void set(IrisPosition pos, T data) {
set(pos.getX(), pos.getY(), pos.getZ(), data);
}
public <T> void set(List<IrisPosition> positions, T data)
{
for(IrisPosition i : positions)
{
public <T> void set(List<IrisPosition> positions, T data) {
for (IrisPosition i : positions) {
set(i, data);
}
}
public <T> void set(Set<IrisPosition> positions, T data)
{
for(IrisPosition i : positions)
{
public <T> void set(Set<IrisPosition> positions, T data) {
for (IrisPosition i : positions) {
set(i, data);
}
}

View File

@@ -19,15 +19,12 @@
package com.volmit.iris.util.mantle;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
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;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterSlice;
import com.volmit.iris.util.matter.slices.ZoneMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -87,8 +84,7 @@ public class MantleChunk {
short v = din.readShort();
for(int i = 0; i < v; i++)
{
for (int i = 0; i < v; i++) {
features.add(zm.readNode(din));
}
}
@@ -187,8 +183,7 @@ public class MantleChunk {
dos.writeShort(features.size());
for(IrisFeaturePositional i : features)
{
for (IrisFeaturePositional i : features) {
zm.writeNode(i, dos);
}
}

View File

@@ -23,7 +23,6 @@ import com.volmit.iris.engine.data.cache.Cache;
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.storage.ArrayHunk;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.io.*;

View File

@@ -30,7 +30,7 @@ public class INode {
private double continuity;
public INode() {
this(new Vector(0,0,0));
this(new Vector(0, 0, 0));
}
public INode(INode other) {

View File

@@ -89,15 +89,15 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
* Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex.
*
* @param baseIndex node index
* @param f1 coefficient for baseIndex-1
* @param f2 coefficient for baseIndex
* @param f3 coefficient for baseIndex+1
* @param f4 coefficient for baseIndex+2
* @param f1 coefficient for baseIndex-1
* @param f2 coefficient for baseIndex
* @param f3 coefficient for baseIndex+1
* @param f4 coefficient for baseIndex+2
* @return linear combination of nodes[n-1..n+2] with f1..4
*/
private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
final Vector r1 = retrieve(baseIndex - 1).multiply(f1);
final Vector r2 = retrieve(baseIndex ).multiply(f2);
final Vector r2 = retrieve(baseIndex).multiply(f2);
final Vector r3 = retrieve(baseIndex + 1).multiply(f3);
final Vector r4 = retrieve(baseIndex + 2).multiply(f4);
@@ -108,7 +108,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
* Retrieves a node. Indexes are clamped to the valid range.
*
* @param index node index to retrieve
* @return nodes[clamp(0, nodes.length-1)]
* @return nodes[clamp(0, nodes.length - 1)]
*/
private Vector retrieve(int index) {
if (index < 0) {
@@ -204,11 +204,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
case 1:
// This case is merely a speed-up for a very common case
return arcLengthRecursive(indexLeft, remainderLeft, 1.0)
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
default:
return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0)
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
}
}

View File

@@ -18,45 +18,60 @@
package com.volmit.iris.util.math;
import net.minecraft.SystemUtils;
import net.minecraft.core.BaseBlockPosition;
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.math.NumberUtils;
import java.util.Random;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.IntPredicate;
public class MathHelper {
public static final float a = MathHelper.c(2.0f);
private static final float[] b = (float[]) a((Object) new float[65536], var0 ->
{
for (int var1 = 0; var1 < ((float[]) var0).length; ++var1) {
((float[]) var0)[var1] = (float) Math.sin((double) var1 * 3.141592653589793 * 2.0 / 65536.0);
private static final int h = 1024;
private static final float i = 1024.0F;
private static final long j = 61440L;
private static final long k = 16384L;
private static final long l = -4611686018427387904L;
private static final long m = -9223372036854775808L;
public static final float a = 3.1415927F;
public static final float b = 1.5707964F;
public static final float c = 6.2831855F;
public static final float d = 0.017453292F;
public static final float e = 57.295776F;
public static final float f = 1.0E-5F;
public static final float g = c(2.0F);
private static final float n = 10430.378F;
private static final float[] o = (float[]) SystemUtils.a(new float[65536], (var0x) -> {
for (int var1 = 0; var1 < var0x.length; ++var1) {
var0x[var1] = (float) Math.sin((double) var1 * 3.141592653589793D * 2.0D / 65536.0D);
}
});
public static <T> T a(T var0, Consumer<T> var1) {
var1.accept(var0);
return var0;
});
private static final Random p = new Random();
private static final int[] q = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
private static final double r = 0.16666666666666666D;
private static final int s = 8;
private static final int t = 257;
private static final double u = Double.longBitsToDouble(4805340802404319232L);
private static final double[] v = new double[257];
private static final double[] w = new double[257];
public MathHelper() {
}
private static final Random c = new Random();
private static final int[] d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
private static final double e = Double.longBitsToDouble(4805340802404319232L);
private static final double[] f = new double[257];
private static final double[] g = new double[257];
public static float sin(float var0) {
return b[(int) (var0 * 10430.378f) & 65535];
return o[(int) (var0 * 10430.378F) & '\uffff'];
}
public static float cos(float var0) {
return b[(int) (var0 * 10430.378f + 16384.0f) & 65535];
return o[(int) (var0 * 10430.378F + 16384.0F) & '\uffff'];
}
public static float c(float var0) {
return (float) Math.sqrt(var0);
}
public static float sqrt(double var0) {
return (float) Math.sqrt(var0);
return (float) Math.sqrt((double) var0);
}
public static int d(float var0) {
@@ -64,16 +79,24 @@ public class MathHelper {
return var0 < (float) var1 ? var1 - 1 : var1;
}
public static int a(double var0) {
return (int) (var0 + 1024.0D) - 1024;
}
public static int floor(double var0) {
int var2 = (int) var0;
return var0 < (double) var2 ? var2 - 1 : var2;
}
public static long d(double var0) {
public static long c(double var0) {
long var2 = (long) var0;
return var0 < (double) var2 ? var2 - 1L : var2;
}
public static int d(double var0) {
return (int) (var0 >= 0.0D ? var0 : -var0 + 1.0D);
}
public static float e(float var0) {
return Math.abs(var0);
}
@@ -87,50 +110,77 @@ public class MathHelper {
return var0 > (float) var1 ? var1 + 1 : var1;
}
public static int f(double var0) {
public static int e(double var0) {
int var2 = (int) var0;
return var0 > (double) var2 ? var2 + 1 : var2;
}
public static byte a(byte var0, byte var1, byte var2) {
if (var0 < var1) {
return var1;
} else {
return var0 > var2 ? var2 : var0;
}
}
public static int clamp(int var0, int var1, int var2) {
if (var0 < var1) {
return var1;
} else {
return var0 > var2 ? var2 : var0;
}
}
public static long a(long var0, long var2, long var4) {
if (var0 < var2) {
return var2;
} else {
return var0 > var4 ? var4 : var0;
}
return Math.min(var0, var2);
}
public static float a(float var0, float var1, float var2) {
if (var0 < var1) {
return var1;
} else {
return var0 > var2 ? var2 : var0;
}
return Math.min(var0, var2);
}
public static double a(double var0, double var2, double var4) {
if (var0 < var2) {
return var2;
} else {
return var0 > var4 ? var4 : var0;
}
return Math.min(var0, var4);
}
public static double b(double var0, double var2, double var4) {
if (var4 < 0.0) {
if (var4 < 0.0D) {
return var0;
} else {
return var4 > 1.0D ? var2 : d(var4, var0, var2);
}
if (var4 > 1.0) {
return var2;
}
public static float b(float var0, float var1, float var2) {
if (var2 < 0.0F) {
return var0;
} else {
return var2 > 1.0F ? var1 : h(var2, var0, var1);
}
return MathHelper.d(var4, var0, var2);
}
public static double a(double var0, double var2) {
if (var0 < 0.0) {
if (var0 < 0.0D) {
var0 = -var0;
}
if (var2 < 0.0) {
if (var2 < 0.0D) {
var2 = -var2;
}
return Math.max(var0, var2);
return var0 > var2 ? var0 : var2;
}
public static int a(int var0, int var1) {
@@ -138,89 +188,131 @@ public class MathHelper {
}
public static int nextInt(Random var0, int var1, int var2) {
if (var1 >= var2) {
return var1;
}
return var0.nextInt(var2 - var1 + 1) + var1;
return var1 >= var2 ? var1 : var0.nextInt(var2 - var1 + 1) + var1;
}
public static float a(Random var0, float var1, float var2) {
if (var1 >= var2) {
return var1;
}
return var0.nextFloat() * (var2 - var1) + var1;
return var1 >= var2 ? var1 : var0.nextFloat() * (var2 - var1) + var1;
}
public static double a(Random var0, double var1, double var3) {
if (var1 >= var3) {
return var1;
}
return var0.nextDouble() * (var3 - var1) + var1;
return var1 >= var3 ? var1 : var0.nextDouble() * (var3 - var1) + var1;
}
public static double a(long[] var0) {
long var1 = 0L;
for (long var6 : var0) {
long[] var3 = var0;
int var4 = var0.length;
for (int var5 = 0; var5 < var4; ++var5) {
long var6 = var3[var5];
var1 += var6;
}
return (double) var1 / (double) var0.length;
}
public static boolean a(float var0, float var1) {
return Math.abs(var1 - var0) < 1.0E-5F;
}
public static boolean b(double var0, double var2) {
return Math.abs(var2 - var0) < 9.999999747378752E-6;
return Math.abs(var2 - var0) < 9.999999747378752E-6D;
}
public static int b(int var0, int var1) {
return Math.floorMod(var0, var1);
}
public static float g(float var0) {
float var1 = var0 % 360.0f;
if (var1 >= 180.0f) {
var1 -= 360.0f;
public static float b(float var0, float var1) {
return (var0 % var1 + var1) % var1;
}
public static double c(double var0, double var2) {
return (var0 % var2 + var2) % var2;
}
public static int b(int var0) {
int var1 = var0 % 360;
if (var1 >= 180) {
var1 -= 360;
}
if (var1 < -180.0f) {
var1 += 360.0f;
if (var1 < -180) {
var1 += 360;
}
return var1;
}
public static double g(double var0) {
double var2 = var0 % 360.0;
if (var2 >= 180.0) {
var2 -= 360.0;
public static float g(float var0) {
float var1 = var0 % 360.0F;
if (var1 >= 180.0F) {
var1 -= 360.0F;
}
if (var2 < -180.0) {
var2 += 360.0;
if (var1 < -180.0F) {
var1 += 360.0F;
}
return var1;
}
public static double f(double var0) {
double var2 = var0 % 360.0D;
if (var2 >= 180.0D) {
var2 -= 360.0D;
}
if (var2 < -180.0D) {
var2 += 360.0D;
}
return var2;
}
public static float c(float var0, float var1) {
return MathHelper.g(var1 - var0);
return g(var1 - var0);
}
public static float d(float var0, float var1) {
return MathHelper.e(MathHelper.c(var0, var1));
}
public static float b(float var0, float var1, float var2) {
float var3 = MathHelper.c(var0, var1);
float var4 = MathHelper.a(var3, -var2, var2);
return var1 - var4;
return e(c(var0, var1));
}
public static float c(float var0, float var1, float var2) {
var2 = MathHelper.e(var2);
if (var0 < var1) {
return MathHelper.a(var0 + var2, var0, var1);
}
return MathHelper.a(var0 - var2, var1, var0);
float var3 = c(var0, var1);
float var4 = a(var3, -var2, var2);
return var1 - var4;
}
public static float d(float var0, float var1, float var2) {
float var3 = MathHelper.c(var0, var1);
return MathHelper.c(var0, var0 + var3, var2);
var2 = e(var2);
return var0 < var1 ? a(var0 + var2, var0, var1) : a(var0 - var2, var1, var0);
}
public static float e(float var0, float var1, float var2) {
float var3 = c(var0, var1);
return d(var0, var0 + var3, var2);
}
public static int a(String var0, int var1) {
return NumberUtils.toInt(var0, var1);
}
public static int a(String var0, int var1, int var2) {
return Math.max(var2, a(var0, var1));
}
public static double a(String var0, double var1) {
try {
return Double.parseDouble(var0);
} catch (Throwable var4) {
return var1;
}
}
public static double a(String var0, double var1, double var3) {
return Math.max(var3, a(var0, var1));
}
public static int c(int var0) {
@@ -238,166 +330,250 @@ public class MathHelper {
}
public static int e(int var0) {
var0 = MathHelper.d(var0) ? var0 : MathHelper.c(var0);
return d[(int) ((long) var0 * 125613361L >> 27) & 31];
var0 = d(var0) ? var0 : c(var0);
return q[(int) ((long) var0 * 125613361L >> 27) & 31];
}
public static int f(int var0) {
return MathHelper.e(var0) - (MathHelper.d(var0) ? 0 : 1);
return e(var0) - (d(var0) ? 0 : 1);
}
public static int f(float var0, float var1, float var2) {
return b(d(var0 * 255.0F), d(var1 * 255.0F), d(var2 * 255.0F));
}
public static int b(int var0, int var1, int var2) {
int var3 = (var0 << 8) + var1;
var3 = (var3 << 8) + var2;
return var3;
}
public static int c(int var0, int var1) {
int var2;
if (var1 == 0) {
return 0;
}
if (var0 == 0) {
return var1;
}
if (var0 < 0) {
var1 *= -1;
}
if ((var2 = var0 % var1) == 0) {
return var0;
}
return var0 + var1 - var2;
int var2 = (var0 & 16711680) >> 16;
int var3 = (var1 & 16711680) >> 16;
int var4 = (var0 & '\uff00') >> 8;
int var5 = (var1 & '\uff00') >> 8;
int var6 = (var0 & 255) >> 0;
int var7 = (var1 & 255) >> 0;
int var8 = (int) ((float) var2 * (float) var3 / 255.0F);
int var9 = (int) ((float) var4 * (float) var5 / 255.0F);
int var10 = (int) ((float) var6 * (float) var7 / 255.0F);
return var0 & -16777216 | var8 << 16 | var9 << 8 | var10;
}
public static int a(int var0, float var1, float var2, float var3) {
int var4 = (var0 & 16711680) >> 16;
int var5 = (var0 & '\uff00') >> 8;
int var6 = (var0 & 255) >> 0;
int var7 = (int) ((float) var4 * var1);
int var8 = (int) ((float) var5 * var2);
int var9 = (int) ((float) var6 * var3);
return var0 & -16777216 | var7 << 16 | var8 << 8 | var9;
}
public static float h(float var0) {
return var0 - (float) MathHelper.d(var0);
return var0 - (float) d(var0);
}
public static double h(double var0) {
return var0 - (double) MathHelper.d(var0);
public static double g(double var0) {
return var0 - (double) c(var0);
}
public static long a(BlockPosition var0) {
public static Vec3D a(Vec3D var0, Vec3D var1, Vec3D var2, Vec3D var3, double var4) {
double var6 = ((-var4 + 2.0D) * var4 - 1.0D) * var4 * 0.5D;
double var8 = ((3.0D * var4 - 5.0D) * var4 * var4 + 2.0D) * 0.5D;
double var10 = ((-3.0D * var4 + 4.0D) * var4 + 1.0D) * var4 * 0.5D;
double var12 = (var4 - 1.0D) * var4 * var4 * 0.5D;
return new Vec3D(var0.b * var6 + var1.b * var8 + var2.b * var10 + var3.b * var12, var0.c * var6 + var1.c * var8 + var2.c * var10 + var3.c * var12, var0.d * var6 + var1.d * var8 + var2.d * var10 + var3.d * var12);
}
public static long a(BaseBlockPosition var0) {
return c(var0.getX(), var0.getY(), var0.getZ());
}
public static long c(int var0, int var1, int var2) {
long var3 = (var0 * 3129871L) ^ (long) var2 * 116129781L ^ (long) var1;
long var3 = (long) (var0 * 3129871) ^ (long) var2 * 116129781L ^ (long) var1;
var3 = var3 * var3 * 42317861L + var3 * 11L;
return var3 >> 16;
}
public static UUID a(Random var0) {
long var1 = var0.nextLong() & -61441L | 16384L;
long var3 = var0.nextLong() & 0x3FFFFFFFFFFFFFFFL | Long.MIN_VALUE;
long var3 = var0.nextLong() & 4611686018427387903L | -9223372036854775808L;
return new UUID(var1, var3);
}
public static UUID a() {
return MathHelper.a(c);
return a(p);
}
public static double c(double var0, double var2, double var4) {
return (var0 - var2) / (var4 - var2);
}
public static double d(double var0, double var2) {
double var9;
boolean var6;
boolean var7;
boolean var8;
double var4 = var2 * var2 + var0 * var0;
if (Double.isNaN(var4)) {
return Double.NaN;
public static boolean a(Vec3D var0, Vec3D var1, AxisAlignedBB var2) {
double var3 = (var2.a + var2.d) * 0.5D;
double var5 = (var2.d - var2.a) * 0.5D;
double var7 = var0.b - var3;
if (Math.abs(var7) > var5 && var7 * var1.b >= 0.0D) {
return false;
} else {
double var9 = (var2.b + var2.e) * 0.5D;
double var11 = (var2.e - var2.b) * 0.5D;
double var13 = var0.c - var9;
if (Math.abs(var13) > var11 && var13 * var1.c >= 0.0D) {
return false;
} else {
double var15 = (var2.c + var2.f) * 0.5D;
double var17 = (var2.f - var2.c) * 0.5D;
double var19 = var0.d - var15;
if (Math.abs(var19) > var17 && var19 * var1.d >= 0.0D) {
return false;
} else {
double var21 = Math.abs(var1.b);
double var23 = Math.abs(var1.c);
double var25 = Math.abs(var1.d);
double var27 = var1.c * var19 - var1.d * var13;
if (Math.abs(var27) > var11 * var25 + var17 * var23) {
return false;
} else {
var27 = var1.d * var7 - var1.b * var19;
if (Math.abs(var27) > var5 * var25 + var17 * var21) {
return false;
} else {
var27 = var1.b * var13 - var1.c * var7;
return Math.abs(var27) < var5 * var23 + var11 * var21;
}
}
}
}
}
@SuppressWarnings("unused")
boolean bl = var6 = var0 < 0.0;
if (var6) {
var0 = -var0;
}
@SuppressWarnings("unused")
boolean bl2 = var7 = var2 < 0.0;
if (var7) {
var2 = -var2;
}
@SuppressWarnings("unused")
boolean bl3 = var8 = var0 > var2;
if (var8) {
var9 = var2;
var2 = var0;
var0 = var9;
}
var9 = MathHelper.i(var4);
double var11 = e + (var0 *= var9);
int var13 = (int) Double.doubleToRawLongBits(var11);
double var14 = f[var13];
double var16 = g[var13];
double var18 = var11 - e;
double var20 = var0 * var16 - (var2 *= var9) * var18;
double var22 = (6.0 + var20 * var20) * var20 * 0.16666666666666666;
double var24 = var14 + var22;
if (var8) {
var24 = 1.5707963267948966 - var24;
}
if (var7) {
var24 = 3.141592653589793 - var24;
}
if (var6) {
var24 = -var24;
}
return var24;
}
public static double i(double var0) {
double var2 = 0.5 * var0;
long var4 = Double.doubleToRawLongBits(var0);
var4 = 6910469410427058090L - (var4 >> 1);
var0 = Double.longBitsToDouble(var4);
var0 *= 1.5 - var2 * var0 * var0;
public static double d(double var0, double var2) {
double var4 = var2 * var2 + var0 * var0;
if (Double.isNaN(var4)) {
return 0.0D / 0.0;
} else {
boolean var6 = var0 < 0.0D;
if (var6) {
var0 = -var0;
}
boolean var7 = var2 < 0.0D;
if (var7) {
var2 = -var2;
}
boolean var8 = var0 > var2;
double var9;
if (var8) {
var9 = var2;
var2 = var0;
var0 = var9;
}
var9 = h(var4);
var2 *= var9;
var0 *= var9;
double var11 = u + var0;
int var13 = (int) Double.doubleToRawLongBits(var11);
double var14 = v[var13];
double var16 = w[var13];
double var18 = var11 - u;
double var20 = var0 * var16 - var2 * var18;
double var22 = (6.0D + var20 * var20) * var20 * 0.16666666666666666D;
double var24 = var14 + var22;
if (var8) {
var24 = 1.5707963267948966D - var24;
}
if (var7) {
var24 = 3.141592653589793D - var24;
}
if (var6) {
var24 = -var24;
}
return var24;
}
}
public static float i(float var0) {
float var1 = 0.5F * var0;
int var2 = Float.floatToIntBits(var0);
var2 = 1597463007 - (var2 >> 1);
var0 = Float.intBitsToFloat(var2);
var0 *= 1.5F - var1 * var0 * var0;
return var0;
}
public static int f(float var0, float var1, float var2) {
float var9;
public static double h(double var0) {
double var2 = 0.5D * var0;
long var4 = Double.doubleToRawLongBits(var0);
var4 = 6910469410427058090L - (var4 >> 1);
var0 = Double.longBitsToDouble(var4);
var0 *= 1.5D - var2 * var0 * var0;
return var0;
}
public static float j(float var0) {
int var1 = Float.floatToIntBits(var0);
var1 = 1419967116 - var1 / 3;
float var2 = Float.intBitsToFloat(var1);
var2 = 0.6666667F * var2 + 1.0F / (3.0F * var2 * var2 * var0);
var2 = 0.6666667F * var2 + 1.0F / (3.0F * var2 * var2 * var0);
return var2;
}
public static int g(float var0, float var1, float var2) {
int var3 = (int) (var0 * 6.0F) % 6;
float var4 = var0 * 6.0F - (float) var3;
float var5 = var2 * (1.0F - var1);
float var6 = var2 * (1.0F - var4 * var1);
float var7 = var2 * (1.0F - (1.0F - var4) * var1);
float var8;
float var9;
float var10;
int var3 = (int) (var0 * 6.0f) % 6;
float var4 = var0 * 6.0f - (float) var3;
float var5 = var2 * (1.0f - var1);
float var6 = var2 * (1.0f - var4 * var1);
float var7 = var2 * (1.0f - (1.0f - var4) * var1);
switch (var3) {
case 0 -> {
case 0:
var8 = var2;
var9 = var7;
var10 = var5;
}
case 1 -> {
break;
case 1:
var8 = var6;
var9 = var2;
var10 = var5;
}
case 2 -> {
break;
case 2:
var8 = var5;
var9 = var2;
var10 = var7;
}
case 3 -> {
break;
case 3:
var8 = var5;
var9 = var6;
var10 = var2;
}
case 4 -> {
break;
case 4:
var8 = var7;
var9 = var5;
var10 = var2;
}
case 5 -> {
break;
case 5:
var8 = var2;
var9 = var5;
var10 = var6;
}
default -> {
break;
default:
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
}
}
int var11 = MathHelper.clamp((int) (var8 * 255.0f), 0, 255);
int var12 = MathHelper.clamp((int) (var9 * 255.0f), 0, 255);
int var13 = MathHelper.clamp((int) (var10 * 255.0f), 0, 255);
int var11 = clamp((int) (var8 * 255.0F), 0, 255);
int var12 = clamp((int) (var9 * 255.0F), 0, 255);
int var13 = clamp((int) (var10 * 255.0F), 0, 255);
return var11 << 16 | var12 << 8 | var13;
}
@@ -410,22 +586,103 @@ public class MathHelper {
return var0;
}
public static long a(long var0) {
var0 ^= var0 >>> 33;
var0 *= -49064778989728563L;
var0 ^= var0 >>> 33;
var0 *= -4265267296055464877L;
var0 ^= var0 >>> 33;
return var0;
}
public static double[] a(double... var0) {
float var1 = 0.0F;
double[] var2f = var0;
int var3 = var0.length;
for (int var4 = 0; var4 < var3; ++var4) {
double var5 = var2f[var4];
var1 = (float) ((double) var1 + var5);
}
int var2;
for (var2 = 0; var2 < var0.length; ++var2) {
var0[var2] /= (double) var1;
}
for (var2 = 0; var2 < var0.length; ++var2) {
var0[var2] += var2 == 0 ? 0.0D : var0[var2 - 1];
}
return var0;
}
public static int a(Random var0, double[] var1) {
double var2 = var0.nextDouble();
for (int var4 = 0; var4 < var1.length; ++var4) {
if (var2 < var1[var4]) {
return var4;
}
}
return var1.length;
}
public static double[] a(double var0, double var2, double var4, int var6, int var7) {
double[] var8 = new double[var7 - var6 + 1];
int var9 = 0;
for (int var10 = var6; var10 <= var7; ++var10) {
var8[var9] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var10 - var4) * ((double) var10 - var4) / (2.0D * var2 * var2)));
++var9;
}
return var8;
}
public static double[] a(double var0, double var2, double var4, double var6, double var8, double var10, int var12, int var13) {
double[] var14 = new double[var13 - var12 + 1];
int var15 = 0;
for (int var16 = var12; var16 <= var13; ++var16) {
var14[var15] = Math.max(0.0D, var0 * StrictMath.exp(-((double) var16 - var4) * ((double) var16 - var4) / (2.0D * var2 * var2)) + var6 * StrictMath.exp(-((double) var16 - var10) * ((double) var16 - var10) / (2.0D * var8 * var8)));
++var15;
}
return var14;
}
public static double[] a(double var0, double var2, int var4, int var5) {
double[] var6 = new double[var5 - var4 + 1];
int var7 = 0;
for (int var8 = var4; var8 <= var5; ++var8) {
var6[var7] = Math.max(var0 * StrictMath.log((double) var8) + var2, 0.0D);
++var7;
}
return var6;
}
public static int a(int var0, int var1, IntPredicate var2) {
int var3 = var1 - var0;
while (var3 > 0) {
int var4 = var3 / 2;
int var5 = var0 + var4;
if (var2.test(var5)) {
var3 = var4;
continue;
} else {
var0 = var5 + 1;
var3 -= var4 + 1;
}
var0 = var5 + 1;
var3 -= var4 + 1;
}
return var0;
}
public static float g(float var0, float var1, float var2) {
public static float h(float var0, float var1, float var2) {
return var1 + var0 * (var2 - var1);
}
@@ -434,46 +691,118 @@ public class MathHelper {
}
public static double a(double var0, double var2, double var4, double var6, double var8, double var10) {
return MathHelper.d(var2, MathHelper.d(var0, var4, var6), MathHelper.d(var0, var8, var10));
return d(var2, d(var0, var4, var6), d(var0, var8, var10));
}
public static double a(double var0, double var2, double var4, double var6, double var8, double var10, double var12, double var14, double var16, double var18, double var20) {
return MathHelper.d(var4, MathHelper.a(var0, var2, var6, var8, var10, var12), MathHelper.a(var0, var2, var14, var16, var18, var20));
return d(var4, a(var0, var2, var6, var8, var10, var12), a(var0, var2, var14, var16, var18, var20));
}
public static double i(double var0) {
return var0 * var0 * var0 * (var0 * (var0 * 6.0D - 15.0D) + 10.0D);
}
public static double j(double var0) {
return var0 * var0 * var0 * (var0 * (var0 * 6.0 - 15.0) + 10.0);
return 30.0D * var0 * var0 * (var0 - 1.0D) * (var0 - 1.0D);
}
public static int k(double var0) {
if (var0 == 0.0) {
if (var0 == 0.0D) {
return 0;
} else {
return var0 > 0.0D ? 1 : -1;
}
return var0 > 0.0 ? 1 : -1;
}
public static float i(float var0, float var1, float var2) {
return var1 + var0 * g(var2 - var1);
}
public static float j(float var0, float var1, float var2) {
return Math.min(var0 * var0 * 0.6F + var1 * var1 * ((3.0F + var1) / 4.0F) + var2 * var2 * 0.8F, 1.0F);
}
@Deprecated
public static float j(float var0, float var1, float var2) {
public static float k(float var0, float var1, float var2) {
float var3;
for (var3 = var1 - var0; var3 < -180.0f; var3 += 360.0f) {
for (var3 = var1 - var0; var3 < -180.0F; var3 += 360.0F) {
}
while (var3 >= 180.0f) {
var3 -= 360.0f;
while (var3 >= 180.0F) {
var3 -= 360.0F;
}
return var0 + var2 * var3;
}
@Deprecated
public static float l(double var0) {
while (var0 >= 180.0D) {
var0 -= 360.0D;
}
while (var0 < -180.0D) {
var0 += 360.0D;
}
return (float) var0;
}
public static float e(float var0, float var1) {
return (Math.abs(var0 % var1 - var1 * 0.5F) - var1 * 0.25F) / (var1 * 0.25F);
}
public static float k(float var0) {
return var0 * var0;
}
public static double m(double var0) {
return var0 * var0;
}
public static int h(int var0) {
return var0 * var0;
}
public static double a(double var0, double var2, double var4, double var6, double var8) {
return b(var6, var8, c(var0, var2, var4));
}
public static double b(double var0, double var2, double var4, double var6, double var8) {
return d(c(var0, var2, var4), var6, var8);
}
public static double n(double var0) {
return var0 + (2.0D * (new Random((long) floor(var0 * 3000.0D))).nextDouble() - 1.0D) * 1.0E-7D / 2.0D;
}
public static int d(int var0, int var1) {
return (var0 + var1 - 1) / var1 * var1;
}
public static int b(Random var0, int var1, int var2) {
return var0.nextInt(var2 - var1 + 1) + var1;
}
public static float b(Random var0, float var1, float var2) {
return var0.nextFloat() * (var2 - var1) + var1;
}
public static float c(Random var0, float var1, float var2) {
return var1 + (float) var0.nextGaussian() * var2;
}
public static double a(int var0, double var1, int var3) {
return Math.sqrt((double) (var0 * var0) + var1 * var1 + (double) (var3 * var3));
}
static {
for (int var02 = 0; var02 < 257; ++var02) {
// TODO: WARNING HEIGHT
double var1 = (double) var02 / 256.0;
for (int var0 = 0; var0 < 257; ++var0) {
double var1 = (double) var0 / 256.0D;
double var3 = Math.asin(var1);
MathHelper.g[var02] = Math.cos(var3);
MathHelper.f[var02] = var3;
w[var0] = Math.cos(var3);
v[var0] = var3;
}
}
}

View File

@@ -18,16 +18,13 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.BlockPosition;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_17_R1.block.data.type.CraftLeaves;
import org.bukkit.entity.Entity;
import java.io.*;
@@ -190,13 +187,9 @@ public interface Matter {
slice = (MatterSlice<T>) createSlice(c, this);
if (slice == null) {
try
{
try {
throw new RuntimeException("Bad slice " + c.getCanonicalName());
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.util.matter.Sliced;

View File

@@ -18,6 +18,8 @@
package com.volmit.iris.util.nbt.mca;
import com.volmit.iris.Iris;
import com.volmit.iris.util.io.IO;
import com.volmit.iris.util.nbt.io.NBTDeserializer;
import com.volmit.iris.util.nbt.io.NBTSerializer;
import com.volmit.iris.util.nbt.io.NamedTag;
@@ -658,11 +660,7 @@ public class Chunk {
level.putInt("zPos", zPos);
level.putLong("LastUpdate", lastUpdate);
level.putLong("InhabitedTime", inhabitedTime);
if (dataVersion < 2202) {
if (biomes != null && biomes.length == 256) level.putIntArray("Biomes", biomes);
} else {
if (biomes != null && biomes.length == 1024) level.putIntArray("Biomes", biomes);
}
if (biomes != null && biomes.length == 1024) level.putIntArray("Biomes", biomes);
if (heightMaps != null) level.put("Heightmaps", heightMaps);
if (carvingMasks != null) level.put("CarvingMasks", carvingMasks);
if (entities != null) level.put("Entities", entities);
@@ -688,14 +686,4 @@ public class Chunk {
public int sectionCount() {
return sections.length();
}
public void runLighting() {
for (int s = 15; s >= 0; s--) {
Section section = getSection(s);
if (section != null) {
section.runLighting();
}
}
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.nbt.mca;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.nbt.tag.CompoundTag;

View File

@@ -28,7 +28,6 @@ import com.volmit.iris.util.math.M;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.StringTag;
import com.volmit.iris.util.parallel.HyperLock;
import com.volmit.iris.util.scheduling.IrisLock;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@@ -39,10 +38,38 @@ import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
public class NBTWorld {
private static final BlockData AIR = B.get("AIR");
private static final Map<String, CompoundTag> blockDataCache = new KMap<>();
private static final Map<BlockData, CompoundTag> blockDataCache = new KMap<>();
private static final Function<BlockData, CompoundTag> BLOCK_DATA_COMPUTE = (blockData) -> {
CompoundTag s = new CompoundTag();
String data = blockData.getAsString(true);
NamespacedKey key = blockData.getMaterial().getKey();
s.putString("Name", key.getNamespace() + ":" + key.getKey());
if (data.contains("[")) {
String raw = data.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
CompoundTag props = new CompoundTag();
if (raw.contains(",")) {
for (String i : raw.split("\\Q,\\E")) {
String[] m = i.split("\\Q=\\E");
String k = m[0];
String v = m[1];
props.put(k, new StringTag(v));
}
} else {
String[] m = raw.split("\\Q=\\E");
String k = m[0];
String v = m[1];
props.put(k, new StringTag(v));
}
s.put("Properties", props);
}
return s;
};
private static final Map<Biome, Integer> biomeIds = computeBiomeIDs();
private final KMap<Long, MCAFile> loadedRegions;
private final HyperLock hyperLock = new HyperLock();
@@ -184,38 +211,8 @@ public class NBTWorld {
return b;
}
public static CompoundTag getCompound(BlockData blockData) {
String data = blockData.getAsString(true);
if (blockDataCache.containsKey(data)) {
return blockDataCache.get(data).clone();
}
CompoundTag s = new CompoundTag();
NamespacedKey key = blockData.getMaterial().getKey();
s.putString("Name", key.getNamespace() + ":" + key.getKey());
if (data.contains("[")) {
String raw = data.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
CompoundTag props = new CompoundTag();
if (raw.contains(",")) {
for (String i : raw.split("\\Q,\\E")) {
String[] m = i.split("\\Q=\\E");
String k = m[0];
String v = m[1];
props.put(k, new StringTag(v));
}
} else {
String[] m = raw.split("\\Q=\\E");
String k = m[0];
String v = m[1];
props.put(k, new StringTag(v));
}
s.put("Properties", props);
}
blockDataCache.put(data, s.clone());
return s;
public static CompoundTag getCompound(BlockData bd) {
return blockDataCache.computeIfAbsent(bd, BLOCK_DATA_COMPUTE).clone();
}
public BlockData getBlockData(int x, int y, int z) {
@@ -238,8 +235,7 @@ public class NBTWorld {
getChunkSection(x >> 4, y >> 4, z >> 4).setBlockStateAt(x & 15, y & 15, z & 15, getCompound(data), false);
}
public int getBiomeId(Biome b)
{
public int getBiomeId(Biome b) {
return biomeIds.get(b);
}
@@ -259,8 +255,7 @@ public class NBTWorld {
return s;
}
public Chunk getChunk(int x, int z)
{
public Chunk getChunk(int x, int z) {
return getChunk(getMCA(x >> 5, z >> 5), x, z);
}
@@ -275,11 +270,18 @@ public class NBTWorld {
return c;
}
public Chunk getNewChunk(MCAFile mca, int x, int z) {
Chunk c = Chunk.newChunk();
mca.setChunk(x & 31, z & 31, c);
return c;
}
public long getIdleDuration(int x, int z) {
return hyperLock.withResult(x, z, () -> {
Long l = lastUse.get(Cache.key(x, z));
return l == null ? 0 : (M.ms() - l);
});
return hyperLock.withResult(x, z, () -> {
Long l = lastUse.get(Cache.key(x, z));
return l == null ? 0 : (M.ms() - l);
});
}
public MCAFile getMCA(int x, int z) {

View File

@@ -18,26 +18,17 @@
package com.volmit.iris.util.nbt.mca;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.nbt.mca.palettes.DataPaletteBlock;
import com.volmit.iris.util.nbt.tag.ByteArrayTag;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import com.volmit.iris.util.nbt.tag.LongArrayTag;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLongArray;
public class Section {
private CompoundTag data;
private Map<String, List<PaletteIndex>> valueIndexedPalette = new KMap<>();
private ListTag<CompoundTag> palette;
private DataPaletteBlock palette;
private byte[] blockLight;
private AtomicLongArray blockStates;
private byte[] skyLight;
private int dataVersion;
@@ -52,83 +43,18 @@ public class Section {
if (rawPalette == null) {
return;
}
palette = rawPalette.asCompoundTagList();
for (int i = 0; i < palette.size(); i++) {
CompoundTag data = palette.get(i);
putValueIndexedPalette(data, i);
}
ByteArrayTag blockLight = sectionRoot.getByteArrayTag("BlockLight");
palette = new DataPaletteBlock();
LongArrayTag blockStates = sectionRoot.getLongArrayTag("BlockStates");
palette.load((ListTag<CompoundTag>) rawPalette, blockStates.getValue());
ByteArrayTag blockLight = sectionRoot.getByteArrayTag("BlockLight");
ByteArrayTag skyLight = sectionRoot.getByteArrayTag("SkyLight");
if ((loadFlags & LoadFlags.BLOCK_LIGHTS) != 0) {
this.blockLight = blockLight != null ? blockLight.getValue() : null;
}
if ((loadFlags & LoadFlags.BLOCK_STATES) != 0) {
this.blockStates = blockStates != null ? new AtomicLongArray(blockStates.getValue()) : null;
}
if ((loadFlags & LoadFlags.SKY_LIGHT) != 0) {
this.skyLight = skyLight != null ? skyLight.getValue() : null;
}
this.blockLight = blockLight != null ? blockLight.getValue() : null;
this.skyLight = skyLight != null ? skyLight.getValue() : null;
}
Section() {
}
void putValueIndexedPalette(CompoundTag data, int index) {
PaletteIndex leaf = new PaletteIndex(data, index);
String name = data.getString("Name");
List<PaletteIndex> leaves = valueIndexedPalette.get(name);
if (leaves == null) {
leaves = new ArrayList<>(1);
leaves.add(leaf);
valueIndexedPalette.put(name, leaves);
} else {
for (PaletteIndex pal : leaves) {
if (pal.data.equals(data)) {
return;
}
}
leaves.add(leaf);
}
}
PaletteIndex getValueIndexedPalette(CompoundTag data) {
List<PaletteIndex> leaves = valueIndexedPalette.get(data.getString("Name"));
if (leaves == null) {
return null;
}
for (PaletteIndex leaf : leaves) {
if (leaf.data.equals(data)) {
return leaf;
}
}
return null;
}
public void runLighting() {
for (int x = 1; x < 14; x++) {
for (int z = 1; z < 14; z++) {
for (int y = 0; y < 16; y++) {
}
}
}
}
@SuppressWarnings("ClassCanBeRecord")
private static class PaletteIndex {
final CompoundTag data;
final int index;
PaletteIndex(CompoundTag data, int index) {
this.data = data;
this.index = index;
}
}
/**
* Checks whether the data of this Section is empty.
*
@@ -147,17 +73,11 @@ public class Section {
* @param blockZ The z-coordinate of the block in this Section
* @return The block state data of this block.
*/
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
try {
int index = getBlockIndex(blockX, blockY, blockZ);
int paletteIndex = getPaletteIndex(index);
return palette.get(paletteIndex);
} catch (Throwable ignored) {
Iris.reportError(ignored);
public synchronized CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
synchronized (palette)
{
return palette.getBlock(blockX&15, blockY&15, blockZ&15);
}
return null;
}
/**
@@ -167,116 +87,12 @@ public class Section {
* @param blockY The y-coordinate of the block in this Section
* @param blockZ The z-coordinate of the block in this Section
* @param state The block state to be set
* @param cleanup When <code>true</code>, it will cleanup the palette of this section.
* This option should only be used moderately to avoid unnecessary recalculation of the palette indices.
* Recalculating the Palette should only be executed once right before saving the Section to file.
*/
public synchronized void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
int paletteSizeBefore = palette.size();
int paletteIndex = addToPalette(state);
//power of 2 --> bits must increase, but only if the palette size changed
//otherwise we would attempt to update all blockstates and the entire palette
//every time an existing blockstate was added while having 2^x blockstates in the palette
if (paletteSizeBefore != palette.size() && (paletteIndex & (paletteIndex - 1)) == 0) {
adjustBlockStateBits(null, blockStates);
cleanup = true;
synchronized (palette)
{
palette.setBlock(blockX&15, blockY&15, blockZ&15, state);
}
setPaletteIndex(getBlockIndex(blockX, blockY, blockZ), paletteIndex, blockStates);
if (cleanup) {
cleanupPaletteAndBlockStates();
}
}
/**
* Returns the index of the block data in the palette.
*
* @param blockStateIndex The index of the block in this section, ranging from 0-4095.
* @return The index of the block data in the palette.
*/
public int getPaletteIndex(int blockStateIndex) {
int bits = blockStates.length() >> 6;
if (dataVersion < 2527) {
double blockStatesIndex = blockStateIndex / (4096D / blockStates.length());
int longIndex = (int) blockStatesIndex;
int startBit = (int) ((blockStatesIndex - Math.floor(blockStatesIndex)) * 64D);
if (startBit + bits > 64) {
long prev = bitRange(blockStates.get(longIndex), startBit, 64);
long next = bitRange(blockStates.get(longIndex + 1), 0, startBit + bits - 64);
return (int) ((next << 64 - startBit) + prev);
} else {
return (int) bitRange(blockStates.get(longIndex), startBit, startBit + bits);
}
} else {
int indicesPerLong = (int) (64D / bits);
int blockStatesIndex = blockStateIndex / indicesPerLong;
int startBit = (blockStateIndex % indicesPerLong) * bits;
return (int) bitRange(blockStates.get(blockStatesIndex), startBit, startBit + bits);
}
}
/**
* Sets the index of the block data in the BlockStates. Does not adjust the size of the BlockStates array.
*
* @param blockIndex The index of the block in this section, ranging from 0-4095.
* @param paletteIndex The block state to be set (index of block data in the palette).
* @param blockStates The block states to be updated.
*/
public synchronized void setPaletteIndex(int blockIndex, int paletteIndex, AtomicLongArray blockStates) {
int bits = blockStates.length() >> 6;
if (dataVersion < 2527) {
double blockStatesIndex = blockIndex / (4096D / blockStates.length());
int longIndex = (int) blockStatesIndex;
int startBit = (int) ((blockStatesIndex - Math.floor(longIndex)) * 64D);
if (startBit + bits > 64) {
blockStates.set(longIndex, updateBits(blockStates.get(longIndex), paletteIndex, startBit, 64));
blockStates.set(longIndex + 1, updateBits(blockStates.get(longIndex + 1), paletteIndex, startBit - 64, startBit + bits - 64));
} else {
blockStates.set(longIndex, updateBits(blockStates.get(longIndex), paletteIndex, startBit, startBit + bits));
}
} else {
int indicesPerLong = (int) (64D / bits);
int blockStatesIndex = blockIndex / indicesPerLong;
int startBit = (blockIndex % indicesPerLong) * bits;
blockStates.set(blockStatesIndex, updateBits(blockStates.get(blockStatesIndex), paletteIndex, startBit, startBit + bits));
}
}
/**
* Fetches the palette of this Section.
*
* @return The palette of this Section.
*/
public ListTag<CompoundTag> getPalette() {
return palette;
}
synchronized int addToPalette(CompoundTag data) {
PaletteIndex index;
if ((index = getValueIndexedPalette(data)) != null) {
return index.index;
}
palette.add(data);
putValueIndexedPalette(data, palette.size() - 1);
return palette.size() - 1;
}
int getBlockIndex(int blockX, int blockY, int blockZ) {
return (blockY & 0xF) * 256 + (blockZ & 0xF) * 16 + (blockX & 0xF);
}
static long updateBits(long n, long m, int i, int j) {
//replace i to j in n with j - i bits of m
long mShifted = i > 0 ? (m & ((1L << j - i) - 1)) << i : (m & ((1L << j - i) - 1)) >>> -i;
return ((n & ((j > 63 ? 0 : (~0L << j)) | (i < 0 ? 0 : ((1L << i) - 1L)))) | mShifted);
}
static long bitRange(long value, int from, int to) {
int waste = 64 - to;
return (value << waste) >>> (waste + from);
}
/**
@@ -284,69 +100,14 @@ public class Section {
* This should only be used moderately to avoid unnecessary recalculation of the palette indices.
* Recalculating the Palette should only be executed once right before saving the Section to file.
*/
public synchronized void cleanupPaletteAndBlockStates() {
Map<Integer, Integer> oldToNewMapping = cleanupPalette();
adjustBlockStateBits(oldToNewMapping, blockStates);
}
public void cleanupPaletteAndBlockStates() {
private synchronized Map<Integer, Integer> cleanupPalette() {
//create index - palette mapping
Map<Integer, Integer> allIndices = new Int2IntOpenHashMap();
for (int i = 0; i < 4096; i++) {
int paletteIndex = getPaletteIndex(i);
allIndices.put(paletteIndex, paletteIndex);
}
//delete unused blocks from palette
//start at index 1 because we need to keep minecraft:air
int index = 1;
valueIndexedPalette = new HashMap<>(valueIndexedPalette.size());
putValueIndexedPalette(palette.get(0), 0);
for (int i = 1; i < palette.size(); i++) {
if (!allIndices.containsKey(index)) {
palette.remove(i);
i--;
} else {
putValueIndexedPalette(palette.get(i), i);
allIndices.put(index, i);
}
index++;
}
return allIndices;
}
synchronized void adjustBlockStateBits(Map<Integer, Integer> oldToNewMapping, AtomicLongArray blockStates) {
//increases or decreases the amount of bits used per BlockState
//based on the size of the palette. oldToNewMapping can be used to update indices
//if the palette had been cleaned up before using MCAFile#cleanupPalette().
int newBits = 32 - Integer.numberOfLeadingZeros(palette.size() - 1);
newBits = Math.max(newBits, 4);
AtomicLongArray newBlockStates;
if (dataVersion < 2527) {
newBlockStates = newBits == blockStates.length() / 64 ? blockStates : new AtomicLongArray(newBits * 64);
} else {
int newLength = (int) Math.ceil(4096D / (64D / newBits));
newBlockStates = newBits == blockStates.length() / 64 ? blockStates : new AtomicLongArray(newLength);
}
if (oldToNewMapping != null) {
for (int i = 0; i < 4096; i++) {
setPaletteIndex(i, oldToNewMapping.get(getPaletteIndex(i)), newBlockStates);
}
} else {
for (int i = 0; i < 4096; i++) {
setPaletteIndex(i, getPaletteIndex(i), newBlockStates);
}
}
this.blockStates = newBlockStates;
}
/**
* @return The block light array of this Section
*/
public byte[] getBlockLight() {
public synchronized byte[] getBlockLight() {
return blockLight;
}
@@ -356,40 +117,17 @@ public class Section {
* @param blockLight The block light array
* @throws IllegalArgumentException When the length of the array is not 2048
*/
public void setBlockLight(byte[] blockLight) {
public synchronized void setBlockLight(byte[] blockLight) {
if (blockLight != null && blockLight.length != 2048) {
throw new IllegalArgumentException("BlockLight array must have a length of 2048");
}
this.blockLight = blockLight;
}
/**
* @return The indices of the block states of this Section.
*/
public AtomicLongArray getBlockStates() {
return blockStates;
}
/**
* Sets the block state indices to a custom value.
*
* @param blockStates The block state indices.
* @throws NullPointerException If <code>blockStates</code> is <code>null</code>
* @throws IllegalArgumentException When <code>blockStates</code>' length is &lt; 256 or &gt; 4096 and is not a multiple of 64
*/
public synchronized void setBlockStates(AtomicLongArray blockStates) {
if (blockStates == null) {
throw new NullPointerException("BlockStates cannot be null");
} else if (blockStates.length() % 64 != 0 || blockStates.length() < 256 || blockStates.length() > 4096) {
throw new IllegalArgumentException("BlockStates must have a length > 255 and < 4097 and must be divisible by 64");
}
this.blockStates = blockStates;
}
/**
* @return The sky light values of this Section
*/
public byte[] getSkyLight() {
public synchronized byte[] getSkyLight() {
return skyLight;
}
@@ -399,7 +137,7 @@ public class Section {
* @param skyLight The custom sky light values
* @throws IllegalArgumentException If the length of the array is not 2048
*/
public void setSkyLight(byte[] skyLight) {
public synchronized void setSkyLight(byte[] skyLight) {
if (skyLight != null && skyLight.length != 2048) {
throw new IllegalArgumentException("SkyLight array must have a length of 2048");
}
@@ -413,11 +151,7 @@ public class Section {
*/
public static Section newSection() {
Section s = new Section();
s.blockStates = new AtomicLongArray(256);
s.palette = new ListTag<>(CompoundTag.class);
CompoundTag air = new CompoundTag();
air.putString("Name", "minecraft:air");
s.palette.add(air);
s.palette = new DataPaletteBlock();
s.data = new CompoundTag();
return s;
}
@@ -430,23 +164,18 @@ public class Section {
* @param y The Y-value of this Section
* @return A reference to the raw CompoundTag this Section is based on
*/
public CompoundTag updateHandle(int y) {
public synchronized CompoundTag updateHandle(int y) {
data.putByte("Y", (byte) y);
if (palette != null) {
data.put("Palette", palette);
synchronized (palette)
{
palette.save(data, "Palette", "BlockStates");
}
}
if (blockLight != null) {
data.putByteArray("BlockLight", blockLight);
}
if (blockStates != null) {
long[] c = new long[blockStates.length()];
for (int i = 0; i < c.length; i++) {
c[i] = blockStates.get(i);
}
data.putLongArray("BlockStates", c);
}
if (skyLight != null) {
data.putByteArray("SkyLight", skyLight);
}

View File

@@ -0,0 +1,125 @@
/*
* 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.nbt.mca.palettes;
import org.apache.commons.lang3.Validate;
import java.util.function.IntConsumer;
public class DataBits {
private static final int[] a = new int[]{-1, -1, 0, -2147483648, 0, 0, 1431655765, 1431655765, 0, -2147483648, 0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756, 0, -2147483648, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0, 390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378, 306783378, 0, 286331153, 286331153, 0, -2147483648, 0, 3, 252645135, 252645135, 0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0, 204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970, 178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862, 0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0, 138547332, 138547332, 0, -2147483648, 0, 4, 130150524, 130150524, 0, 126322567, 126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197, 0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0, 104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893, 97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282, 0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0, 84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431, 79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303, 0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0, 70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, -2147483648, 0, 5};
private final long[] data;
private final int c;
private final long paletteSize;
private final int blockSize;
private final int f;
private final int g;
private final int h;
private final int i;
public DataBits(int var0, int var1) {
this(var0, var1, (long[]) null);
}
public DataBits(int bitsPerBlock, int var1, long[] data) {
Validate.inclusiveBetween(1L, 32L, (long) bitsPerBlock);
this.blockSize = var1;
this.c = bitsPerBlock;
this.paletteSize = (1L << bitsPerBlock) - 1L;
this.f = (char) (64 / bitsPerBlock);
int var3 = 3 * (this.f - 1);
this.g = a[var3 + 0];
this.h = a[var3 + 1];
this.i = a[var3 + 2];
int var4 = (var1 + this.f - 1) / this.f;
if (data != null) {
if (data.length != var4) {
throw new RuntimeException("Invalid length given for storage, got: " + data.length + " but expected: " + var4);
}
this.data = data;
} else {
this.data = new long[var4];
}
}
private int b(int var0) {
long var1 = Integer.toUnsignedLong(this.g);
long var3 = Integer.toUnsignedLong(this.h);
return (int) ((long) var0 * var1 + var3 >> 32 >> this.i);
}
public int setBlockResulting(int blockIndex, int paletteIndex) {
Validate.inclusiveBetween(0L, (long) (this.blockSize - 1), (long) blockIndex);
Validate.inclusiveBetween(0L, this.paletteSize, (long) paletteIndex);
int var2 = this.b(blockIndex);
long var3 = this.data[var2];
int var5 = (blockIndex - var2 * this.f) * this.c;
int var6 = (int) (var3 >> var5 & this.paletteSize);
this.data[var2] = var3 & ~(this.paletteSize << var5) | ((long) paletteIndex & this.paletteSize) << var5;
return var6;
}
public void setBlock(int blockIndex, int paletteIndex) {
Validate.inclusiveBetween(0L, (long) (this.blockSize - 1), (long) blockIndex);
Validate.inclusiveBetween(0L, this.paletteSize, (long) paletteIndex);
int var2 = this.b(blockIndex);
long var3 = this.data[var2];
int var5 = (blockIndex - var2 * this.f) * this.c;
this.data[var2] = var3 & ~(this.paletteSize << var5) | ((long) paletteIndex & this.paletteSize) << var5;
}
public int getIndexFromPos(int var0) {
Validate.inclusiveBetween(0L, (long) (this.blockSize - 1), (long) var0);
int var1 = this.b(var0);
long var2 = this.data[var1];
int var4 = (var0 - var1 * this.f) * this.c;
return (int) (var2 >> var4 & this.paletteSize);
}
public long[] getData() {
return this.data;
}
public int b() {
return this.blockSize;
}
public int getBitsPerBlock() {
return this.c;
}
public void a(IntConsumer var0) {
int var1 = 0;
long[] var3 = this.data;
int var4 = var3.length;
for (long l : var3) {
long var5 = l;
for (int j = 0; j < this.f; ++j) {
var0.accept((int) (var5 & this.paletteSize));
var5 >>= this.c;
++var1;
if (var1 >= this.blockSize) {
return;
}
}
}
}
}

View File

@@ -16,21 +16,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.hunk.io;
package com.volmit.iris.util.nbt.mca.palettes;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
public class StringHunkIOAdapter extends PaletteHunkIOAdapter<String> {
import java.util.function.Predicate;
@Override
public void write(String data, DataOutputStream dos) throws IOException {
dos.writeUTF(data);
}
public interface DataPalette {
int getIndex(CompoundTag block);
@Override
public String read(DataInputStream din) throws IOException {
return din.readUTF();
}
boolean contains(Predicate<CompoundTag> predicate);
CompoundTag getByIndex(int index);
int size();
void replace(ListTag<CompoundTag> palette);
}

View File

@@ -0,0 +1,225 @@
/*
* 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.nbt.mca.palettes;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.util.math.MathHelper;
import com.volmit.iris.util.nbt.io.SNBTSerializer;
import com.volmit.iris.util.nbt.mca.NBTWorld;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import com.volmit.iris.util.scheduling.J;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import lombok.Getter;
import net.minecraft.world.level.chunk.ChunkSection;
import org.bukkit.Material;
import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Getter
public class DataPaletteBlock implements DataPaletteExpandable {
private static final int d = 4096;
public static final int HASH_BITS = 9;
public static final int LINEAR_BITS = 4;
private final DataPalette globalPalette;
private final DataPaletteExpandable f = (var0x, var1x) -> 0;
private final RegistryBlockID stolenRegistry;
private final CompoundTag defAir;
private static final AtomicCache<RegistryBlockID> reg = new AtomicCache<>();
private static final AtomicCache<DataPaletteGlobal> global = new AtomicCache<>();
private static final CompoundTag air = NBTWorld.getCompound(Material.AIR.createBlockData());
protected DataBits dataBits;
private DataPalette currentPalette;
private int bits = 0;
public DataPaletteBlock() {
this(global(), registry(), air);
}
public DataPaletteBlock(DataPalette var0,
RegistryBlockID var1,
CompoundTag airType) {
this.globalPalette = var0;
this.stolenRegistry = var1;
this.defAir = airType;
this.changeBitsTo(4);
}
private static RegistryBlockID registry()
{
return ((DataPaletteGlobal) global()).getRegistry();
}
private static DataPalette global() {
return global.aquire(() -> new DataPaletteGlobal(J.attemptResult(() -> INMS.get().computeBlockIDRegistry()), air));
}
private static int blockIndex(int x, int y, int z) {
return y << 8 | z << 4 | x;
}
private void changeBitsTo(int newbits) {
if (newbits != bits) {
bits = newbits;
if (bits <= LINEAR_BITS) {
bits = LINEAR_BITS;
currentPalette = new DataPaletteLinear(bits, this);
} else if (bits < HASH_BITS) {
currentPalette = new DataPaletteHash(bits, this);
} else {
currentPalette = globalPalette;
bits = MathHelper.e(stolenRegistry.size());
}
currentPalette.getIndex(defAir);
dataBits = new DataBits(bits, 4096);
}
}
public int onResize(int newBits, CompoundTag newData) {
DataBits oldBits = dataBits;
DataPalette oldPalette = currentPalette;
changeBitsTo(newBits);
for (int i = 0; i < oldBits.b(); ++i) {
CompoundTag block = oldPalette.getByIndex(oldBits.getIndexFromPos(i));
if (block != null) {
setBlockIndex(i, block);
}
}
return currentPalette.getIndex(newData);
}
@Deprecated
public CompoundTag setBlockAndReturn(int x, int y, int z, CompoundTag block) {
return setBlockIndexAndReturn(blockIndex(x, y, z), block);
}
@Deprecated
private CompoundTag setBlockIndexAndReturn(int index, CompoundTag block) {
int paletteIndex = currentPalette.getIndex(block);
int res = dataBits.setBlockResulting(index, paletteIndex);
CompoundTag testBlock = currentPalette.getByIndex(res);
return testBlock == null ? defAir : testBlock;
}
public void setBlock(int x, int y, int z, CompoundTag block) {
setBlockIndex(blockIndex(x, y, z), block);
}
private void setBlockIndex(int blockIndex, CompoundTag block) {
int paletteIndex = currentPalette.getIndex(block);
dataBits.setBlock(blockIndex, paletteIndex);
}
public CompoundTag getBlock(int x, int y, int z) {
return getByIndex(blockIndex(x, y, z));
}
protected CompoundTag getByIndex(int index) {
if(currentPalette == null)
{
return null;
}
CompoundTag data = currentPalette.getByIndex(dataBits.getIndexFromPos(index));
return data == null ? defAir : data;
}
public void load(ListTag<CompoundTag> palettedata, long[] databits) {
int readBits = Math.max(4, MathHelper.e(palettedata.size()));
if (readBits != bits) {
changeBitsTo(readBits);
}
currentPalette.replace(palettedata);
int dblen = databits.length * 64 / 4096;
if (currentPalette == globalPalette) {
DataPalette hashPalette = new DataPaletteHash(readBits, f);
hashPalette.replace(palettedata);
DataBits var5 = new DataBits(readBits, 4096, databits);
for (int i = 0; i < 4096; ++i) {
dataBits.setBlock(i, globalPalette.getIndex(hashPalette.getByIndex(var5.getIndexFromPos(i))));
}
} else if (dblen == bits) {
System.arraycopy(databits, 0, dataBits.getData(), 0, databits.length);
} else {
DataBits var4 = new DataBits(dblen, 4096, databits);
for (int i = 0; i < 4096; ++i) {
dataBits.setBlock(i, var4.getIndexFromPos(i));
}
}
}
public void save(CompoundTag to, String paletteName, String blockStatesName) {
DataPaletteHash hashpal = new DataPaletteHash(bits, f);
CompoundTag cursor = defAir;
int palIndex = hashpal.getIndex(defAir);
int[] paletteIndex = new int[4096];
int i;
for (i = 0; i < 4096; ++i) {
CompoundTag entry = getByIndex(i);
if (!entry.equals(cursor)) {
cursor = entry;
palIndex = hashpal.getIndex(entry);
}
paletteIndex[i] = palIndex;
}
ListTag<CompoundTag> npalette = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
hashpal.writePalette(npalette);
to.put(paletteName, npalette);
int bits = Math.max(4, MathHelper.e(npalette.size()));
DataBits writeBits = new DataBits(bits, 4096);
for (i = 0; i < paletteIndex.length; ++i) {
writeBits.setBlock(i, paletteIndex[i]);
}
to.putLongArray(blockStatesName, writeBits.getData());
to.putString("DEBUG_PALETTE_MODE", currentPalette.getClass().getSimpleName());
}
public boolean contains(Predicate<CompoundTag> var0) {
return currentPalette.contains(var0);
}
public void a(PaletteConsumer<CompoundTag> var0) {
Int2IntMap var1 = new Int2IntOpenHashMap();
dataBits.a((var1x) -> var1.put(var1x, var1.get(var1x) + 1));
var1.int2IntEntrySet().forEach((var1x) -> var0.accept(currentPalette.getByIndex(var1x.getIntKey()), var1x.getIntValue()));
}
@FunctionalInterface
public interface PaletteConsumer<T> {
void accept(T var1, int var2);
}
}

View File

@@ -16,30 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.oldnbt;
package com.volmit.iris.util.nbt.mca.palettes;
/**
* The <code>TAG_End</code> tag.
*
* @author Graham Edgecombe
*/
public final class EndTag extends Tag {
/**
* Creates the tag.
*/
public EndTag() {
super("");
}
@Override
public Object getValue() {
return null;
}
@Override
public String toString() {
return "TAG_End";
}
import com.volmit.iris.util.nbt.tag.CompoundTag;
interface DataPaletteExpandable {
int onResize(int newBits, CompoundTag newData);
}

View File

@@ -0,0 +1,56 @@
/*
* 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.nbt.mca.palettes;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.function.Predicate;
@RequiredArgsConstructor
public class DataPaletteGlobal implements DataPalette {
@Getter
private final RegistryBlockID registry;
private final CompoundTag air;
public int getIndex(CompoundTag block) {
int id = this.registry.getId(block);
return id == -1 ? 0 : id;
}
public boolean contains(Predicate<CompoundTag> predicate) {
return true;
}
public CompoundTag getByIndex(int index) {
CompoundTag block = registry.fromId(index);
return block == null ? air : block;
}
public int size() {
return registry.size();
}
@Override
public void replace(ListTag<CompoundTag> palette) {
throw new UnsupportedOperationException("Cannot replace the global palette!");
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.nbt.mca.palettes;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import java.util.function.Predicate;
public class DataPaletteHash implements DataPalette {
private final RegistryID registryId;
private final DataPaletteExpandable expander;
private final int bits;
public DataPaletteHash(int bits, DataPaletteExpandable expander) {
this.bits = bits;
this.expander = expander;
this.registryId = new RegistryID(1 << bits);
}
public int getIndex(CompoundTag block) {
int id = registryId.getId(block);
if (id == -1) {
id = registryId.c(block);
if (id >= 1 << bits) {
id = expander.onResize(bits + 1, block);
}
}
return id;
}
public boolean contains(Predicate<CompoundTag> predicate) {
for (int i = 0; i < size(); ++i) {
if (predicate.test(registryId.fromId(i))) {
return true;
}
}
return false;
}
public CompoundTag getByIndex(int index) {
return registryId.fromId(index);
}
public int size() {
return registryId.size();
}
public void replace(ListTag<CompoundTag> palette) {
registryId.clear();
for (int i = 0; i < palette.size(); ++i) {
registryId.c(palette.get(i));
}
}
public void writePalette(ListTag<CompoundTag> list) {
for (int i = 0; i < size(); ++i) {
list.add(registryId.fromId(i));
}
}
}

View File

@@ -0,0 +1,82 @@
/*
* 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.nbt.mca.palettes;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import java.util.function.Predicate;
public class DataPaletteLinear implements DataPalette {
private final CompoundTag[] palette;
private final DataPaletteExpandable expander;
private final int e;
private int size;
public DataPaletteLinear(int bits, DataPaletteExpandable expander) {
this.palette = new CompoundTag[1 << bits];
this.e = bits;
this.expander = expander;
this.size = 0;
}
public int getIndex(CompoundTag block) {
int i;
for (i = 0; i < size; ++i) {
if (palette[i].equals(block)) {
return i;
}
}
i = size;
if (i < palette.length) {
palette[i] = block;
++size;
return i;
} else {
return expander.onResize(e + 1, block);
}
}
public boolean contains(Predicate<CompoundTag> predicate) {
for (int i = 0; i < this.size; ++i) {
if (predicate.test(palette[i])) {
return true;
}
}
return false;
}
public CompoundTag getByIndex(int index) {
return index >= 0 && index < size ? palette[index] : null;
}
public int size() {
return size;
}
public void replace(ListTag<CompoundTag> palette) {
for (int i = 0; i < palette.size(); ++i) {
this.palette[i] = palette.get(i);
}
this.size = palette.size();
}
}

View File

@@ -16,24 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.hunk.io;
package com.volmit.iris.util.nbt.mca.palettes;
import com.volmit.iris.util.data.B;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public interface Registry extends Iterable<CompoundTag> {
int getId(CompoundTag block);
public class BlockDataHunkIOAdapter extends PaletteHunkIOAdapter<BlockData> {
@Override
public void write(BlockData blockData, DataOutputStream dos) throws IOException {
dos.writeUTF(blockData.getAsString(true));
}
@Override
public BlockData read(DataInputStream din) throws IOException {
return B.get(din.readUTF());
}
}
CompoundTag fromId(int id);
}

View File

@@ -0,0 +1,65 @@
/*
* 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.nbt.mca.palettes;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import java.util.*;
public class RegistryBlockID implements Registry {
private final Map<CompoundTag, Integer> indexMap;
private final List<CompoundTag> indexes;
public RegistryBlockID(Map<CompoundTag, Integer> c, List<CompoundTag> d) {
this.indexMap = c;
this.indexes = d;
}
public RegistryBlockID() {
this(512);
}
public RegistryBlockID(int var0) {
this.indexes = Lists.newArrayListWithExpectedSize(var0);
this.indexMap = new HashMap<>(var0);
}
public int getId(CompoundTag block) {
Integer var1 = this.indexMap.get(block);
return var1 == null ? -1 : var1;
}
public final CompoundTag fromId(int id) {
return id >= 0 && id < this.indexes.size() ? this.indexes.get(id) : null;
}
public Iterator<CompoundTag> iterator() {
return Iterators.filter(this.indexes.iterator(), Objects::nonNull);
}
public boolean hasIndex(int var0) {
return this.fromId(var0) != null;
}
public int size() {
return this.indexMap.size();
}
}

View File

@@ -0,0 +1,176 @@
/*
* 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.nbt.mca.palettes;
import com.google.common.collect.Iterators;
import com.volmit.iris.util.math.MathHelper;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Objects;
public class RegistryID implements Registry {
public static final int a = -1;
private static final CompoundTag b = null;
private static final float c = 0.8F;
private CompoundTag[] d;
private int[] e;
private CompoundTag[] f;
private int g;
private int size;
public RegistryID(int var0) {
var0 = (int) ((float) var0 / 0.8F);
this.d = new CompoundTag[var0];
this.f = new CompoundTag[var0];
this.e = new int[var0];
}
public int getId(CompoundTag block) {
return this.c(this.b(block, this.d(block)));
}
public CompoundTag fromId(int id) {
return id >= 0 && id < this.f.length ? this.f[id] : null;
}
private int c(int var0) {
return var0 == -1 ? -1 : this.e[var0];
}
public boolean b(CompoundTag var0) {
return this.getId(var0) != -1;
}
public boolean b(int var0) {
return this.fromId(var0) != null;
}
public int c(CompoundTag var0) {
int var1 = this.c();
this.a(var0, var1);
return var1;
}
private int c() {
while (this.g < this.f.length && this.f[this.g] != null) {
++this.g;
}
return this.g;
}
private void d(int var0) {
CompoundTag[] var1 = this.d;
int[] var2 = this.e;
this.d = new CompoundTag[var0];
this.e = new int[var0];
this.f = new CompoundTag[var0];
this.g = 0;
this.size = 0;
for (int var3 = 0; var3 < var1.length; ++var3) {
if (var1[var3] != null) {
this.a(var1[var3], var2[var3]);
}
}
}
public void a(CompoundTag var0, int var1) {
int var2 = Math.max(var1, this.size + 1);
int var3;
if ((float) var2 >= (float) this.d.length * 0.8F) {
for (var3 = this.d.length << 1; var3 < var1; var3 <<= 1) {
}
this.d(var3);
}
var3 = this.e(this.d(var0));
this.d[var3] = var0;
this.e[var3] = var1;
this.f[var1] = var0;
++this.size;
if (var1 == this.g) {
++this.g;
}
}
private int d(CompoundTag block) {
return (MathHelper.g(System.identityHashCode(block)) & 2147483647) % this.d.length;
}
private int b(CompoundTag block, int var1) {
int var2;
for (var2 = var1; var2 < this.d.length; ++var2) {
if (this.d[var2] == null) {
return -1;
}
if (this.d[var2].equals(block)) {
return var2;
}
}
for (var2 = 0; var2 < var1; ++var2) {
if (this.d[var2] == null) {
return -1;
}
if (this.d[var2].equals(block)) {
return var2;
}
}
return -1;
}
private int e(int var0) {
int var1;
for (var1 = var0; var1 < this.d.length; ++var1) {
if (this.d[var1] == null) {
return var1;
}
}
for (var1 = 0; var1 < var0; ++var1) {
if (this.d[var1] == null) {
return var1;
}
}
throw new RuntimeException("Overflowed :(");
}
public Iterator<CompoundTag> iterator() {
return Iterators.filter(Iterators.forArray(this.f), Objects::nonNull);
}
public void clear() {
Arrays.fill(this.d, null);
Arrays.fill(this.f, null);
this.g = 0;
this.size = 0;
}
public int size() {
return this.size;
}
}

View File

@@ -22,6 +22,7 @@ import com.volmit.iris.engine.data.io.MaxDepthIO;
import com.volmit.iris.util.collection.KList;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
/**
@@ -42,6 +43,11 @@ public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<
super(createEmptyValue(3));
}
public ListTag<T> makeAtomic() {
setValue(new CopyOnWriteArrayList<>(getValue()));
return this;
}
@Override
public byte getID() {
return ID;
@@ -302,7 +308,7 @@ public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<
@Override
public int hashCode() {
return Objects.hash(getTypeClass().hashCode(), getValue().hashCode());
return Objects.hash(getValue().hashCode());
}
@Override

View File

@@ -94,7 +94,7 @@ public abstract class Tag<T> implements Cloneable {
/**
* @return The value of this Tag.
*/
protected T getValue() {
public T getValue() {
return value;
}

View File

@@ -25,19 +25,16 @@ public class Worm {
private double position;
private double velocity;
public Worm(double startPosition, double startVelocity)
{
public Worm(double startPosition, double startVelocity) {
this.position = startPosition;
this.velocity = startVelocity;
}
public void unstep()
{
public void unstep() {
position -= velocity;
}
public void step()
{
public void step() {
position += velocity;
}
}

View File

@@ -18,34 +18,28 @@
package com.volmit.iris.util.noise;
import com.volmit.iris.util.math.Position2;
import lombok.Data;
@Data
public class Worm2
{
public class Worm2 {
private final Worm x;
private final Worm z;
public Worm2(Worm x, Worm z)
{
public Worm2(Worm x, Worm z) {
this.x = x;
this.z = z;
}
public Worm2(int x, int z, int vx, int vz)
{
public Worm2(int x, int z, int vx, int vz) {
this(new Worm(x, vx), new Worm(z, vz));
}
public void step()
{
public void step() {
x.step();
z.step();
}
public void unstep()
{
public void unstep() {
x.unstep();
z.unstep();
}

View File

@@ -21,33 +21,28 @@ package com.volmit.iris.util.noise;
import lombok.Data;
@Data
public class Worm3
{
public class Worm3 {
private final Worm x;
private final Worm y;
private final Worm z;
public Worm3(Worm x,Worm y, Worm z)
{
public Worm3(Worm x, Worm y, Worm z) {
this.x = x;
this.y = y;
this.z = z;
}
public Worm3(int x, int y, int z, int vx, int vy, int vz)
{
public Worm3(int x, int y, int z, int vx, int vy, int vz) {
this(new Worm(x, vx), new Worm(y, vy), new Worm(z, vz));
}
public void step()
{
public void step() {
x.step();
y.step();
z.step();
}
public void unstep()
{
public void unstep() {
x.unstep();
y.unstep();
z.unstep();

View File

@@ -32,18 +32,15 @@ public class WormIterator2 {
private int maxDistance;
private int maxIterations;
public boolean hasNext()
{
public boolean hasNext() {
double dist = maxDistance - (Math.max(Math.abs(worm.getX().getVelocity()), Math.abs(worm.getZ().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm2 next()
{
if(worm == null)
{
public Worm2 next() {
if (worm == null) {
worm = new Worm2(x, z, 0, 0);
return worm;
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.util.function.NoiseProvider;
import lombok.Builder;
import lombok.Data;
@@ -34,28 +33,24 @@ public class WormIterator3 {
private int maxDistance;
private int maxIterations;
public boolean hasNext()
{
if(worm == null)
{
public boolean hasNext() {
if (worm == null) {
return true;
}
double dist = maxDistance - (Math.max(Math.max(Math.abs(worm.getX().getVelocity()),
Math.abs(worm.getZ().getVelocity())),
Math.abs(worm.getZ().getVelocity())),
Math.abs(worm.getY().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((y * y) - (worm.getY().getPosition() * worm.getY().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
+ ((y * y) - (worm.getY().getPosition() * worm.getY().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm3 next()
{
public Worm3 next() {
maxIterations--;
if(worm == null)
{
if (worm == null) {
worm = new Worm3(x, y, z, 0, 0, 0);
return worm;
}

View File

@@ -1,67 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Byte_Array</code> tag.
*
* @author Graham Edgecombe
*/
public final class ByteArrayTag extends Tag {
/**
* The value.
*/
private final byte[] value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public ByteArrayTag(String name, byte[] value) {
super(name);
this.value = value;
}
@Override
public byte[] getValue() {
return value;
}
@Override
public String toString() {
StringBuilder hex = new StringBuilder();
for (byte b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase();
if (hexDigits.length() == 1) {
hex.append("0");
}
hex.append(hexDigits).append(" ");
}
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Byte_Array" + append + ": " + hex;
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Byte</code> tag.
*
* @author Graham Edgecombe
*/
public final class ByteTag extends Tag {
/**
* The value.
*/
private final byte value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public ByteTag(String name, byte value) {
super(name);
this.value = value;
}
@Override
public Byte getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Byte" + append + ": " + value;
}
}

View File

@@ -1,67 +0,0 @@
/*
* 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.oldnbt;
import java.util.Map;
/**
* The <code>TAG_Compound</code> tag.
*
* @author Graham Edgecombe
*/
public final class CompoundTag extends Tag {
/**
* The value.
*/
private final Map<String, Tag> value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public CompoundTag(String name, Map<String, Tag> value) {
super(name);
this.value = value;
}
@Override
public Map<String, Tag> getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Double</code> tag.
*
* @author Graham Edgecombe
*/
public final class DoubleTag extends Tag {
/**
* The value.
*/
private final double value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public DoubleTag(String name, double value) {
super(name);
this.value = value;
}
@Override
public Double getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Double" + append + ": " + value;
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Float</code> tag.
*
* @author Graham Edgecombe
*/
public final class FloatTag extends Tag {
/**
* The value.
*/
private final float value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public FloatTag(String name, float value) {
super(name);
this.value = value;
}
@Override
public Float getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Float" + append + ": " + value;
}
}

View File

@@ -1,61 +0,0 @@
/*
* 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.oldnbt;
import java.util.Arrays;
/**
* The <code>TAG_Int_Array</code> tag.
*
* @author Neil Wightman
*/
public final class IntArrayTag extends Tag {
/**
* The value.
*/
private final int[] value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public IntArrayTag(String name, int[] value) {
super(name);
this.value = value;
}
@Override
public int[] getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Int_Array" + append + ": " + Arrays.toString(value);
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Int</code> tag.
*
* @author Graham Edgecombe
*/
public final class IntTag extends Tag {
/**
* The value.
*/
private final int value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public IntTag(String name, int value) {
super(name);
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Int" + append + ": " + value;
}
}

View File

@@ -1,84 +0,0 @@
/*
* 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.oldnbt;
import java.util.Collections;
import java.util.List;
/**
* The <code>TAG_List</code> tag.
*
* @author Graham Edgecombe
*/
public final class ListTag extends Tag {
/**
* The type.
*/
private final Class<? extends Tag> type;
/**
* The value.
*/
private final List<Tag> value;
/**
* Creates the tag.
*
* @param name The name.
* @param type The type of item in the list.
* @param value The value.
*/
public ListTag(String name, Class<? extends Tag> type, List<Tag> value) {
super(name);
this.type = type;
this.value = Collections.unmodifiableList(value);
}
/**
* Gets the type of item in this list.
*
* @return The type of item in this list.
*/
public Class<? extends Tag> getType() {
return type;
}
@Override
public List<Tag> getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
for (Tag t : value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
}
bldr.append("}");
return bldr.toString();
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Long</code> tag.
*
* @author Graham Edgecombe
*/
public final class LongTag extends Tag {
/**
* The value.
*/
private final long value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public LongTag(String name, long value) {
super(name);
this.value = value;
}
@Override
public Long getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Long" + append + ": " + value;
}
}

View File

@@ -1,63 +0,0 @@
/*
* 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.oldnbt;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
* A class which holds constant values.
*
* @author Graham Edgecombe
*/
public final class NBTConstants {
/**
* The character set used by NBT (UTF-8).
*/
public static final Charset CHARSET = StandardCharsets.UTF_8;
/**
* Tag type constants.
*/
public static final int TYPE_END = 0,
TYPE_BYTE = 1,
TYPE_SHORT = 2,
TYPE_INT = 3,
TYPE_LONG = 4,
TYPE_FLOAT = 5,
TYPE_DOUBLE = 6,
TYPE_BYTE_ARRAY = 7,
TYPE_STRING = 8,
TYPE_LIST = 9,
TYPE_COMPOUND = 10,
TYPE_INT_ARRAY = 11;
/**
* Default private constructor.
*/
private NBTConstants() {
}
}

View File

@@ -1,189 +0,0 @@
/*
* 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.oldnbt;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
/*
Changes :
Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
* <p>
* This class reads <strong>NBT</strong>, or
* <strong>Named Binary Tag</strong> streams, and produces an object graph of subclasses of the <code>Tag</code> object.</p>
*
* <p>
* The NBT format was created by Markus Persson, and the specification may be found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*
* @author Graham Edgecombe
*/
public final class NBTInputStream implements Closeable {
/**
* The data input stream.
*/
private final DataInputStream is;
/**
* Create a new <code>NBTInputStream</code>, which will source its data from the specified input stream.
*
* @param is The output stream
*/
public NBTInputStream(DataInputStream is) {
this.is = is;
}
/**
* Creates a new <code>NBTInputStream</code>, which will source its data from the specified input stream.
* The stream will be decompressed using GZIP.
*
* @param is The input stream.
* @throws IOException if an I/O error occurs.
*/
public NBTInputStream(InputStream is) throws IOException {
this.is = new DataInputStream(new GZIPInputStream(is));
}
/**
* Reads an NBT tag from the stream.
*
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
public Tag readTag() throws IOException {
return readTag(0);
}
/**
* Reads an NBT from the stream.
*
* @param depth The depth of this tag.
* @return The tag that was read.
* @throws IOException if an I/O error occurs.
*/
private Tag readTag(int depth) throws IOException {
int type = is.readByte() & 0xFF;
String name;
if (type != NBTConstants.TYPE_END) {
int nameLength = is.readShort() & 0xFFFF;
byte[] nameBytes = new byte[nameLength];
is.readFully(nameBytes);
name = new String(nameBytes, NBTConstants.CHARSET);
} else {
name = "";
}
return readTagPayload(type, name, depth);
}
/**
* Reads the payload of a tag, given the name and type.
*
* @param type The type.
* @param name The name.
* @param depth The depth.
* @return The tag.
* @throws IOException if an I/O error occurs.
*/
private Tag readTagPayload(int type, String name, int depth) throws IOException {
switch (type) {
case NBTConstants.TYPE_END:
if (depth == 0) {
throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
} else {
return new EndTag();
}
case NBTConstants.TYPE_BYTE:
return new ByteTag(name, is.readByte());
case NBTConstants.TYPE_SHORT:
return new ShortTag(name, is.readShort());
case NBTConstants.TYPE_INT:
return new IntTag(name, is.readInt());
case NBTConstants.TYPE_LONG:
return new LongTag(name, is.readLong());
case NBTConstants.TYPE_FLOAT:
return new FloatTag(name, is.readFloat());
case NBTConstants.TYPE_DOUBLE:
return new DoubleTag(name, is.readDouble());
case NBTConstants.TYPE_BYTE_ARRAY:
int length = is.readInt();
byte[] bytes = new byte[length];
is.readFully(bytes);
return new ByteArrayTag(name, bytes);
case NBTConstants.TYPE_STRING:
length = is.readShort();
bytes = new byte[length];
is.readFully(bytes);
return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
case NBTConstants.TYPE_LIST:
int childType = is.readByte();
length = is.readInt();
List<Tag> tagList = new ArrayList<>();
for (int i = 0; i < length; i++) {
Tag tag = readTagPayload(childType, "", depth + 1);
if (tag instanceof EndTag) {
throw new IOException("TAG_End not permitted in a list.");
}
tagList.add(tag);
}
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<>();
while (true) {
Tag tag = readTag(depth + 1);
if (tag instanceof EndTag) {
break;
} else {
tagMap.put(tag.getName(), tag);
}
}
return new CompoundTag(name, tagMap);
case NBTConstants.TYPE_INT_ARRAY:
length = is.readInt();
int[] value = new int[length];
for (int i = 0; i < length; i++) {
value[i] = is.readInt();
}
return new IntArrayTag(name, value);
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
@Override
public void close() throws IOException {
is.close();
}
}

View File

@@ -1,262 +0,0 @@
/*
* 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.oldnbt;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.GZIPOutputStream;
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
* <p>
* This class writes <strong>NBT</strong>, or
* <strong>Named Binary Tag</strong> <code>Tag</code> objects to an underlying <code>OutputStream</code>.</p>
*
* <p>
* The NBT format was created by Markus Persson, and the specification may be found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
*
* @author Graham Edgecombe
*/
@SuppressWarnings({"EmptyMethod", "JavaDoc"})
public final class NBTOutputStream implements Closeable {
/**
* The output stream.
*/
private final DataOutputStream os;
/**
* Create a new <code>NBTOutputStream</code>, which will write data to the specified underlying output stream.
*
* @param os The output stream
*/
public NBTOutputStream(DataOutputStream os) {
this.os = os;
}
/**
* Creates a new <code>NBTOutputStream</code>, which will write data to the specified underlying output stream.
* the stream will be compressed using GZIP.
*
* @param os The output stream.
* @throws IOException if an I/O error occurs.
*/
public NBTOutputStream(OutputStream os) throws IOException {
this.os = new DataOutputStream(new GZIPOutputStream(os));
}
/**
* Writes a tag.
*
* @param tag The tag to write.
* @throws IOException if an I/O error occurs.
*/
public void writeTag(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
String name = tag.getName();
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
writeTagPayload(tag);
}
/**
* Writes tag payload.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END -> writeEndTagPayload((EndTag) tag);
case NBTConstants.TYPE_BYTE -> writeByteTagPayload((ByteTag) tag);
case NBTConstants.TYPE_SHORT -> writeShortTagPayload((ShortTag) tag);
case NBTConstants.TYPE_INT -> writeIntTagPayload((IntTag) tag);
case NBTConstants.TYPE_LONG -> writeLongTagPayload((LongTag) tag);
case NBTConstants.TYPE_FLOAT -> writeFloatTagPayload((FloatTag) tag);
case NBTConstants.TYPE_DOUBLE -> writeDoubleTagPayload((DoubleTag) tag);
case NBTConstants.TYPE_BYTE_ARRAY -> writeByteArrayTagPayload((ByteArrayTag) tag);
case NBTConstants.TYPE_STRING -> writeStringTagPayload((StringTag) tag);
case NBTConstants.TYPE_LIST -> writeListTagPayload((ListTag) tag);
case NBTConstants.TYPE_COMPOUND -> writeCompoundTagPayload((CompoundTag) tag);
case NBTConstants.TYPE_INT_ARRAY -> writeIntArrayTagPayload((IntArrayTag) tag);
default -> throw new IOException("Invalid tag type: " + type + ".");
}
}
/**
* Writes a <code>TAG_Byte</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteTagPayload(ByteTag tag) throws IOException {
os.writeByte(tag.getValue());
}
/**
* Writes a <code>TAG_Byte_Array</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
byte[] bytes = tag.getValue();
os.writeInt(bytes.length);
os.write(bytes);
}
/**
* Writes a <code>TAG_Compound</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for (Tag childTag : tag.getValue().values()) {
writeTag(childTag);
}
os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a <code>TAG_List</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeListTagPayload(ListTag tag) throws IOException {
Class<? extends Tag> clazz = tag.getType();
List<Tag> tags = tag.getValue();
int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (Tag value : tags) {
writeTagPayload(value);
}
}
/**
* Writes a <code>TAG_String</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeStringTagPayload(StringTag tag) throws IOException {
byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length);
os.write(bytes);
}
/**
* Writes a <code>TAG_Double</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue());
}
/**
* Writes a <code>TAG_Float</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeFloatTagPayload(FloatTag tag) throws IOException {
os.writeFloat(tag.getValue());
}
/**
* Writes a <code>TAG_Long</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeLongTagPayload(LongTag tag) throws IOException {
os.writeLong(tag.getValue());
}
/**
* Writes a <code>TAG_Int</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeIntTagPayload(IntTag tag) throws IOException {
os.writeInt(tag.getValue());
}
/**
* Writes a <code>TAG_Short</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeShortTagPayload(ShortTag tag) throws IOException {
os.writeShort(tag.getValue());
}
/**
* Writes a <code>TAG_Empty</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
/**
* Writes a <code>TAG_Int_Array</code> tag.
*
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
final int[] values = tag.getValue();
os.writeInt(values.length);
for (final int value : values) {
os.writeInt(value);
}
}
@Override
public void close() throws IOException {
os.close();
}
}

View File

@@ -1,137 +0,0 @@
/*
* 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.oldnbt;
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
* A class which contains NBT-related utility methods. This currently supports reading 19133 but <b>only</b> writing 19132.
*
* @author Graham Edgecombe
*/
public final class NBTUtils {
/**
* Gets the type name of a tag.
*
* @param clazz The tag class.
* @return The type name.
*/
public static String getTypeName(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return "TAG_Byte_Array";
} else if (clazz.equals(ByteTag.class)) {
return "TAG_Byte";
} else if (clazz.equals(CompoundTag.class)) {
return "TAG_Compound";
} else if (clazz.equals(DoubleTag.class)) {
return "TAG_Double";
} else if (clazz.equals(EndTag.class)) {
return "TAG_End";
} else if (clazz.equals(FloatTag.class)) {
return "TAG_Float";
} else if (clazz.equals(IntTag.class)) {
return "TAG_Int";
} else if (clazz.equals(ListTag.class)) {
return "TAG_List";
} else if (clazz.equals(LongTag.class)) {
return "TAG_Long";
} else if (clazz.equals(ShortTag.class)) {
return "TAG_Short";
} else if (clazz.equals(StringTag.class)) {
return "TAG_String";
} else if (clazz.equals(IntArrayTag.class)) {
return "TAG_Int_Array";
} else {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
/**
* Gets the type code of a tag class.
*
* @param clazz The tag class.
* @return The type code.
* @throws IllegalArgumentException if the tag class is invalid.
*/
public static int getTypeCode(Class<? extends Tag> clazz) {
if (clazz.equals(ByteArrayTag.class)) {
return NBTConstants.TYPE_BYTE_ARRAY;
} else if (clazz.equals(ByteTag.class)) {
return NBTConstants.TYPE_BYTE;
} else if (clazz.equals(CompoundTag.class)) {
return NBTConstants.TYPE_COMPOUND;
} else if (clazz.equals(DoubleTag.class)) {
return NBTConstants.TYPE_DOUBLE;
} else if (clazz.equals(EndTag.class)) {
return NBTConstants.TYPE_END;
} else if (clazz.equals(FloatTag.class)) {
return NBTConstants.TYPE_FLOAT;
} else if (clazz.equals(IntTag.class)) {
return NBTConstants.TYPE_INT;
} else if (clazz.equals(ListTag.class)) {
return NBTConstants.TYPE_LIST;
} else if (clazz.equals(LongTag.class)) {
return NBTConstants.TYPE_LONG;
} else if (clazz.equals(ShortTag.class)) {
return NBTConstants.TYPE_SHORT;
} else if (clazz.equals(StringTag.class)) {
return NBTConstants.TYPE_STRING;
} else if (clazz.equals(IntArrayTag.class)) {
return NBTConstants.TYPE_INT_ARRAY;
} else {
throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ").");
}
}
/**
* Gets the class of a type of tag.
*
* @param type The type.
* @return The class.
* @throws IllegalArgumentException if the tag type is invalid.
*/
public static Class<? extends Tag> getTypeClass(int type) {
return switch (type) {
case NBTConstants.TYPE_END -> EndTag.class;
case NBTConstants.TYPE_BYTE -> ByteTag.class;
case NBTConstants.TYPE_SHORT -> ShortTag.class;
case NBTConstants.TYPE_INT -> IntTag.class;
case NBTConstants.TYPE_LONG -> LongTag.class;
case NBTConstants.TYPE_FLOAT -> FloatTag.class;
case NBTConstants.TYPE_DOUBLE -> DoubleTag.class;
case NBTConstants.TYPE_BYTE_ARRAY -> ByteArrayTag.class;
case NBTConstants.TYPE_STRING -> StringTag.class;
case NBTConstants.TYPE_LIST -> ListTag.class;
case NBTConstants.TYPE_COMPOUND -> CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY -> IntArrayTag.class;
default -> throw new IllegalArgumentException("Invalid tag type : " + type + ".");
};
}
/**
* Default private constructor.
*/
private NBTUtils() {
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_Short</code> tag.
*
* @author Graham Edgecombe
*/
public final class ShortTag extends Tag {
/**
* The value.
*/
private final short value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public ShortTag(String name, short value) {
super(name);
this.value = value;
}
@Override
public Short getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_Short" + append + ": " + value;
}
}

View File

@@ -1,59 +0,0 @@
/*
* 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.oldnbt;
/**
* The <code>TAG_String</code> tag.
*
* @author Graham Edgecombe
*/
public final class StringTag extends Tag {
/**
* The value.
*/
private final String value;
/**
* Creates the tag.
*
* @param name The name.
* @param value The value.
*/
public StringTag(String name, String value) {
super(name);
this.value = value;
}
@Override
public String getValue() {
return value;
}
@Override
public String toString() {
String name = getName();
String append = "";
if (name != null && !name.equals("")) {
append = "(\"" + this.getName() + "\")";
}
return "TAG_String" + append + ": " + value;
}
}

View File

@@ -1,58 +0,0 @@
/*
* 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.oldnbt;
/**
* Represents a single NBT tag.
*
* @author Graham Edgecombe
*/
public abstract class Tag {
/**
* The name of this tag.
*/
private final String name;
/**
* Creates the tag with the specified name.
*
* @param name The name.
*/
public Tag(String name) {
this.name = name;
}
/**
* Gets the name of this tag.
*
* @return The name of this tag.
*/
public final String getName() {
return name;
}
/**
* Gets the value of this tag.
*
* @return The value of this tag.
*/
public abstract Object getValue();
}

View File

@@ -23,7 +23,9 @@ import com.volmit.iris.util.collection.KList;
import lombok.Setter;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@SuppressWarnings("ALL")
public class BurstExecutor {
@@ -48,10 +50,8 @@ public class BurstExecutor {
}
public BurstExecutor queue(List<Runnable> r) {
if(!multicore)
{
for(Runnable i : new KList<>(r))
{
if (!multicore) {
for (Runnable i : new KList<>(r)) {
i.run();
}
@@ -68,10 +68,8 @@ public class BurstExecutor {
}
public BurstExecutor queue(Runnable[] r) {
if(!multicore)
{
for(Runnable i : new KList<>(r))
{
if (!multicore) {
for (Runnable i : new KList<>(r)) {
i.run();
}
@@ -88,8 +86,7 @@ public class BurstExecutor {
}
public void complete() {
if(!multicore)
{
if (!multicore) {
return;
}
@@ -99,8 +96,7 @@ public class BurstExecutor {
}
try {
for(Future<?> i : futures)
{
for (Future<?> i : futures) {
i.get();
}

View File

@@ -23,12 +23,10 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.PreservationSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
public class MultiBurst {
public static final MultiBurst burst = new MultiBurst();
@@ -74,13 +72,9 @@ public class MultiBurst {
}
public void burst(boolean multicore, Runnable... r) {
if(multicore)
{
if (multicore) {
burst(r);
}
else
{
} else {
sync(r);
}
}
@@ -90,19 +84,15 @@ public class MultiBurst {
}
public void burst(boolean multicore, List<Runnable> r) {
if(multicore)
{
if (multicore) {
burst(r);
}
else {
} else {
sync(r);
}
}
private void sync(List<Runnable> r) {
for(Runnable i : new KList<>(r))
{
for (Runnable i : new KList<>(r)) {
i.run();
}
}

View File

@@ -26,8 +26,7 @@ public interface IrisService extends Listener {
void onDisable();
default void postShutdown(Runnable r)
{
default void postShutdown(Runnable r) {
Iris.instance.postShutdown(r);
}
}

View File

@@ -426,7 +426,7 @@ public class VolmitSender implements CommandSender {
}
}
public void sendDecreeHelpNode(VirtualDecreeCommand i){
public void sendDecreeHelpNode(VirtualDecreeCommand i) {
if (isPlayer()) {
String newline = "<reset>\n";

View File

@@ -23,6 +23,7 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.function.NastyFunction;
import com.volmit.iris.util.function.NastyFuture;
import com.volmit.iris.util.function.NastyRunnable;
import com.volmit.iris.util.function.NastySupplier;
import com.volmit.iris.util.math.FinalInteger;
import com.volmit.iris.util.parallel.MultiBurst;
import org.bukkit.Bukkit;
@@ -125,6 +126,18 @@ public class J {
return attemptCatch(r) == null;
}
public static <T> T attemptResult(NastySupplier<T> r) {
try
{
return r.get();
}
catch(Throwable e)
{
return null;
}
}
public static Throwable attemptCatch(NastyRunnable r) {
try {
r.run();

View File

@@ -29,8 +29,7 @@ public abstract class ParallelQueueJob<T> extends QueueJob<T> {
BurstExecutor b = MultiBurst.burst.burst(queue.size());
KList<T> q = queue.copy();
queue.clear();
for(T i : q)
{
for (T i : q) {
b.queue(() -> {
execute(i);
completeWork();

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.scheduling.jobs;
import com.sun.jna.platform.unix.X11;
import com.volmit.iris.util.collection.KList;
import java.util.concurrent.atomic.AtomicInteger;