9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 04:29:05 +00:00

Merge remote-tracking branch 'origin/Development' into Development

This commit is contained in:
DanMB
2022-06-25 16:00:53 -04:00
73 changed files with 1573 additions and 287 deletions

View File

@@ -0,0 +1,82 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.hunk.bits.Writable;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public interface ArrayCache<T> extends Writable<T> {
T get(int i);
void set(int i, T t);
void iset(int i, int v);
int getWidth();
int getHeight();
void writeCache(DataOutputStream dos) throws IOException;
static int zigZag(int coord, int size)
{
if(coord < 0)
{
coord = Math.abs(coord);
}
if(coord % (size * 2) >= size)
{
return (size) - (coord % size) - 1;
}
else {
return coord % size;
}
}
default void set(int x, int y, T v)
{
set((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()), v);
}
default T get(int x, int y)
{
try
{
return get((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()));
}
catch(Throwable e)
{
e.printStackTrace();
throw e;
}
}
default void iset(int x, int y, int v)
{
iset((zigZag(y, getHeight()) * getWidth()) + zigZag(x, getWidth()), v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ByteBitCache extends DataBitCache<Integer> {
public ByteBitCache(int width, int height) {
super(width, height);
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return (int) din.readByte();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeByte(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ByteCache implements ArrayCache<Integer> {
@Getter
private final int width;
@Getter
private final int height;
private final byte[] cache;
public ByteCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new byte[width * height];
}
public void set(int i, Integer v)
{
cache[i] = v.byteValue();
}
public Integer get(int i)
{
return (int)cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeByte(get(i));
}
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return (int) din.readByte();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeByte(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,58 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.util.hunk.bits.DataContainer;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public abstract class DataBitCache<T> implements ArrayCache<T> {
@Getter
private final int width;
@Getter
private final int height;
private final DataContainer<T> cache;
public DataBitCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new DataContainer<>(this, width * height);
}
public void set(int i, T v)
{
cache.set(i, v);
}
public T get(int i)
{
return cache.get(i);
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
cache.writeDos(dos);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class FloatBitCache extends DataBitCache<Float> {
public FloatBitCache(int width, int height) {
super(width, height);
}
@Override
public Float readNodeData(DataInputStream din) throws IOException {
return din.readFloat();
}
@Override
public void writeNodeData(DataOutputStream dos, Float integer) throws IOException {
dos.writeFloat(integer);
}
@Override
public void iset(int i, int v) {
set(i, (float)v);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FloatCache implements ArrayCache<Float> {
@Getter
private final int width;
@Getter
private final int height;
private final float[] cache;
public FloatCache(File file) throws IOException {
this(new DataInputStream(new FileInputStream(file)));
}
public FloatCache(DataInputStream din) throws IOException {
this(din.readInt(), din.readInt());
for(int i = 0; i < width * height; i++)
{
cache[i] = din.readFloat();
}
din.close();
}
public FloatCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new float[width * height];
}
public void set(int i, Float v)
{
cache[i] = v;
}
public Float get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeFloat(get(i));
}
}
@Override
public Float readNodeData(DataInputStream din) throws IOException {
return din.readFloat();
}
@Override
public void writeNodeData(DataOutputStream dos, Float integer) throws IOException {
dos.writeFloat(integer);
}
@Override
public void iset(int i, int v) {
set(i, (float) v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class IntBitCache extends DataBitCache<Integer> {
public IntBitCache(int width, int height) {
super(width, height);
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return din.readInt();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeInt(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,78 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import com.volmit.iris.util.hunk.bits.DataContainer;
import com.volmit.iris.util.hunk.bits.Writable;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class IntCache implements ArrayCache<Integer> {
@Getter
private final int width;
@Getter
private final int height;
private final int[] cache;
public IntCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new int[width * height];
}
public void set(int i, Integer v)
{
cache[i] = v;
}
public Integer get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeInt(get(i));
}
}
@Override
public Integer readNodeData(DataInputStream din) throws IOException {
return din.readInt();
}
@Override
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
dos.writeInt(integer);
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ShortBitCache extends DataBitCache<Short> {
public ShortBitCache(int width, int height) {
super(width, height);
}
@Override
public Short readNodeData(DataInputStream din) throws IOException {
return din.readShort();
}
@Override
public void writeNodeData(DataOutputStream dos, Short integer) throws IOException {
dos.writeShort(integer);
}
@Override
public void iset(int i, int v) {
set(i, (short) v);
}
}

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
import lombok.Getter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ShortCache implements ArrayCache<Short> {
@Getter
private final int width;
@Getter
private final int height;
private final short[] cache;
public ShortCache(int width, int height)
{
this.width = width;
this.height = height;
cache = new short[width * height];
}
public void set(int i, Short v)
{
cache[i] = v;
}
public Short get(int i)
{
return cache[i];
}
@Override
public void writeCache(DataOutputStream dos) throws IOException {
dos.writeInt(width);
dos.writeInt(height);
for(int i = 0; i < width * height; i++)
{
dos.writeShort(get(i));
}
}
@Override
public Short readNodeData(DataInputStream din) throws IOException {
return din.readShort();
}
@Override
public void writeNodeData(DataOutputStream dos, Short integer) throws IOException {
dos.writeShort(integer);
}
@Override
public void iset(int i, int v) {
set(i, (short) v);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
public class UByteBitCache extends ByteBitCache {
public UByteBitCache(int width, int height) {
super(width, height);
}
@Override
public void set(int i, Integer v) {
super.set(i, v + Byte.MIN_VALUE);
}
@Override
public Integer get(int i) {
return super.get(i) - Byte.MIN_VALUE;
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.cache;
public class UByteCache extends ByteCache {
public UByteCache(int width, int height) {
super(width, height);
}
@Override
public void set(int i, Integer v) {
super.set(i, v + Byte.MIN_VALUE);
}
@Override
public Integer get(int i) {
return super.get(i) - Byte.MIN_VALUE;
}
@Override
public void iset(int i, int v) {
set(i, v);
}
}

View File

@@ -0,0 +1,86 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.view;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.util.hunk.storage.AtomicHunk;
import lombok.Getter;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
@SuppressWarnings("ClassCanBeRecord")
public class BiomeGridHunkHolder extends AtomicHunk<Biome> {
@Getter
private final BiomeGrid chunk;
private final int minHeight;
private final int maxHeight;
public BiomeGridHunkHolder(BiomeGrid chunk, int minHeight, int maxHeight) {
super(16, maxHeight - minHeight, 16);
this.chunk = chunk;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return maxHeight - minHeight;
}
public void apply() {
for(int i = 0; i < getHeight(); i++) {
for(int j = 0; j < getWidth(); j++) {
for(int k = 0; k < getDepth(); k++) {
Biome b = super.getRaw(j, i, k);
if(b != null)
{
chunk.setBiome(j, i + minHeight, k, b);
}
}
}
}
}
@Override
public Biome getRaw(int x, int y, int z) {
Biome b = super.getRaw(x, y, z);
return b != null ? b : Biome.PLAINS;
}
public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) {
if(chunk instanceof LinkedTerrainChunk) {
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
return;
}
INMS.get().forceBiomeInto(x, y + minHeight, z, somethingVeryDirty, chunk);
}
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util.hunk.view;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.util.hunk.Hunk;
@@ -31,6 +32,7 @@ public class BiomeGridHunkView implements Hunk<Biome> {
private final BiomeGrid chunk;
private final int minHeight;
private final int maxHeight;
private int highest = -1000;
public BiomeGridHunkView(BiomeGrid chunk, int minHeight, int maxHeight) {
this.chunk = chunk;
@@ -56,6 +58,12 @@ public class BiomeGridHunkView implements Hunk<Biome> {
@Override
public void setRaw(int x, int y, int z, Biome t) {
chunk.setBiome(x, y + minHeight, z, t);
if(y > highest)
{
highest = y;
Iris.info("Highest = " + highest);
}
}
@Override

View File

@@ -0,0 +1,76 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.view;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.storage.AtomicHunk;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import java.util.concurrent.atomic.AtomicReferenceArray;
@SuppressWarnings("ClassCanBeRecord")
public class ChunkDataHunkHolder extends AtomicHunk<BlockData> {
private static final BlockData AIR = Material.AIR.createBlockData();
private final ChunkData chunk;
public ChunkDataHunkHolder(ChunkData chunk) {
super(16, chunk.getMaxHeight() - chunk.getMinHeight(), 16);
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return chunk.getMaxHeight() - chunk.getMinHeight();
}
@Override
public BlockData getRaw(int x, int y, int z) {
BlockData b = super.getRaw(x, y, z);
return b != null ? b : AIR;
}
public void apply() {
for(int i = 0; i < getHeight(); i++) {
for(int j = 0; j < getWidth(); j++) {
for(int k = 0; k < getDepth(); k++) {
BlockData b = super.getRaw(j, i, k);
if(b != null)
{
chunk.setBlock(j, i + chunk.getMinHeight(), k, b);
}
}
}
}
}
}

View File

@@ -32,7 +32,8 @@ public enum MantleFlag {
INITIAL_SPAWNED_MARKER,
CLEANED,
PLANNED,
ETCHED;
ETCHED,
TILE;
static StateList getStateList() {
return new StateList(MantleFlag.values());

View File

@@ -18,12 +18,10 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import lombok.AllArgsConstructor;
import com.volmit.iris.engine.object.TileData;
import lombok.Data;
@Data
@AllArgsConstructor
public class MatterTile {
private final CompoundTag tileData;
public class TileWrapper {
private final TileData<?> data;
}

View File

@@ -33,8 +33,8 @@ public class WorldMatter {
matter.slice(MatterEntityGroup.class).writeInto(at);
}
if(matter.hasSlice(MatterTile.class)) {
matter.slice(MatterTile.class).writeInto(at);
if(matter.hasSlice(TileWrapper.class)) {
matter.slice(TileWrapper.class).writeInto(at);
}
}
@@ -45,7 +45,7 @@ public class WorldMatter {
s.getHeader().setAuthor(author);
s.slice(BlockData.class).readFrom(c.getLowerNE());
s.slice(MatterEntityGroup.class).readFrom(c.getLowerNE());
s.slice(MatterTile.class).readFrom(c.getLowerNE());
s.slice(TileWrapper.class).readFrom(c.getLowerNE());
s.trimSlices();
return s;

View File

@@ -18,11 +18,12 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.TileData;
import com.volmit.iris.util.data.palette.Palette;
import com.volmit.iris.util.matter.MatterTile;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.matter.TileWrapper;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Location;
import org.bukkit.World;
@@ -31,43 +32,49 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@SuppressWarnings("rawtypes")
@Sliced
public class TileMatter extends RawMatter<MatterTile> {
public static final MatterTile EMPTY = new MatterTile(new CompoundTag());
public class TileMatter extends RawMatter<TileWrapper> {
public TileMatter() {
this(1, 1, 1);
}
@Override
public Palette<MatterTile> getGlobalPalette() {
public Palette<TileWrapper> getGlobalPalette() {
return null;
}
public TileMatter(int width, int height, int depth) {
super(width, height, depth, MatterTile.class);
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
super(width, height, depth, TileWrapper.class);
registerWriter(World.class, (w, d, x, y, z) -> {
CompoundTag tag = commonNbt(x, y, z, d.getData().getTileId());
INMS.get().deserializeTile(d.getData().toNBT(d.getData().toNBT(tag)), new Location(w, x, y, z));
Iris.warn("S: " + tag);
});
registerReader(World.class, (w, x, y, z) -> {
Location l = new Location(w, x, y, z);
if(INMS.get().hasTile(l)) {
CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null) {
return new MatterTile(tag);
}
}
return null;
TileData d = TileData.getTileState(w.getBlockAt(new Location(w, x, y, z)));
if(d == null)
return null;
return new TileWrapper(d);
});
}
@Override
public void writeNode(MatterTile b, DataOutputStream dos) throws IOException {
NBTUtil.write(b.getTileData(), dos, false);
public void writeNode(TileWrapper b, DataOutputStream dos) throws IOException {
b.getData().toBinary(dos);
}
@Override
public MatterTile readNode(DataInputStream din) throws IOException {
return new MatterTile((CompoundTag) NBTUtil.read(din, false).getTag());
public TileWrapper readNode(DataInputStream din) throws IOException {
return new TileWrapper(TileData.read(din));
}
private CompoundTag commonNbt(int x, int y, int z, String mobId) {
CompoundTag tag = new CompoundTag();
tag.putInt("x", x);
tag.putInt("y", y);
tag.putInt("z", z);
tag.putBoolean("keepPacked", false);
tag.putString("id", mobId);
return tag;
}
}

View File

@@ -21,15 +21,25 @@ package com.volmit.iris.util.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.IRare;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.cache.FloatBitCache;
import com.volmit.iris.util.cache.FloatCache;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.NoiseInjector;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.sources.CNGStream;
import lombok.Data;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
@Data
@@ -53,6 +63,7 @@ public class CNG {
private boolean trueFracturing = false;
private KList<CNG> children;
private CNG fracture;
private FloatCache cache;
private NoiseGenerator generator;
private NoiseInjector injector;
private RNG rng;
@@ -120,7 +131,7 @@ public class CNG {
@Override
public double noise(double x, double z) {
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) / 2D) + 0.5D;
return (cellularFilter.GetCellular((float) x, (float) z, str, 1) * 0.5) + 0.5D;
}
@Override
@@ -130,14 +141,55 @@ public class CNG {
}, 1D, 1);
}
public CNG cached(int size)
public CNG cached(int size, String key, File cacheFolder)
{
if(size <= 0)
{
return this;
}
generator = new CachedNoise(generator, size);
cache = null;
File f = new File(new File(cacheFolder, ".cache"), key + ".cnm");
FloatCache fbc;
boolean cached = false;
if(f.exists())
{
try {
fbc = new FloatCache(f);
cached = true;
} catch(IOException e) {
fbc = new FloatCache(size, size);
}
}
else {
fbc = new FloatCache(size, size);
}
if(!cached)
{
for(int i = 0; i < size; i++)
{
for(int j = 0; j < size; j++)
{
fbc.set(i, j, (float) noise(i, j));
}
}
try {
f.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(fos);
fbc.writeCache(dos);
dos.close();
Iris.info("Saved Noise Cache " + f.getName());
} catch(IOException e) {
throw new RuntimeException(e);
}
}
cache = fbc;
return this;
}
@@ -432,6 +484,11 @@ public class CNG {
}
public double noise(double... dim) {
if(cache != null && dim.length == 2)
{
return cache.get((int)dim[0], (int)dim[1]);
}
double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
double m = 1;
@@ -466,4 +523,18 @@ public class CNG {
public boolean isStatic() {
return generator != null && generator.isStatic();
}
public static void main(String[] a)
{
CNG cng = NoiseStyle.SIMPLEX.create(new RNG(1234));
PrecisionStopwatch p = PrecisionStopwatch.start();
double r = 0;
for(int i = 0; i < 30000000 * 10; i++)
{
r += cng.fit(-1000, 1000, i, i);
}
System.out.println(Form.duration(p.getMilliseconds(), 10) + " merged = " + r);
}
}

View File

@@ -51,6 +51,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
/**
* Represents a volume sender. A command sender with extra crap in it
@@ -230,7 +231,7 @@ public class VolmitSender implements CommandSender {
Iris.audiences.player(player()).showTitle(Title.title(
createComponent(title),
createComponent(subtitle),
Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
Title.Times.times(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
}
public void sendProgress(double percent, String thing) {
@@ -260,43 +261,43 @@ public class VolmitSender implements CommandSender {
Iris.audiences.player(player()).showTitle(Title.title(
createNoPrefixComponent(" "),
createNoPrefixComponent(subtitle),
Title.Times.of(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
Title.Times.times(Duration.ofMillis(i), Duration.ofMillis(s), Duration.ofMillis(o))));
}
private Component createNoPrefixComponent(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb(), 0.36);
return MiniMessage.get().parse(a);
return MiniMessage.miniMessage().deserialize(a);
}
private Component createNoPrefixComponentNoProcessing(String message) {
return MiniMessage.get().parse(message);
return MiniMessage.builder().postProcessor(c -> c).build().deserialize(message);
}
private Component createComponent(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
return MiniMessage.get().parse(a);
return MiniMessage.miniMessage().deserialize(a);
}
private Component createComponentRaw(String message) {
if(!IrisSettings.get().getGeneral().canUseCustomColors(this)) {
String t = C.translateAlternateColorCodes('&', MiniMessage.get().stripTokens(getTag() + message));
return MiniMessage.get().parse(t);
String t = C.translateAlternateColorCodes('&', MiniMessage.miniMessage().stripTags(getTag() + message));
return MiniMessage.miniMessage().deserialize(t);
}
String t = C.translateAlternateColorCodes('&', getTag() + message);
return MiniMessage.get().parse(t);
return MiniMessage.miniMessage().deserialize(t);
}
public <T> void showWaiting(String passive, CompletableFuture<T> f) {