mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-09 09:16:12 +00:00
Fixes
This commit is contained in:
@@ -191,7 +191,7 @@ public interface MatterSlice<T> extends Hunk<T>, PaletteType<T>, Writable<T> {
|
||||
default void read(DataInputStream din) throws IOException {
|
||||
if((this instanceof PaletteOrHunk f && f.isPalette()))
|
||||
{
|
||||
f.setPalette(DataContainer.readDin(din, this));
|
||||
f.setPalette(new DataContainer<>(din, this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,67 +19,20 @@
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.palette.PalettedContainer;
|
||||
import com.volmit.iris.util.hunk.bits.DataContainer;
|
||||
import com.volmit.iris.util.hunk.bits.Writable;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import org.checkerframework.checker.units.qual.K;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatterTest {
|
||||
public static void test()
|
||||
{
|
||||
try
|
||||
{
|
||||
CNG cng = NoiseStyle.STATIC.create(new RNG(1337));
|
||||
Writable<Integer> ffs = new Writable<Integer>() {
|
||||
@Override
|
||||
public Integer readNodeData(DataInputStream din) throws IOException {
|
||||
return din.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNodeData(DataOutputStream dos, Integer integer) throws IOException {
|
||||
dos.writeInt(integer);
|
||||
}
|
||||
};
|
||||
DataContainer<Integer> p = new DataContainer<>(ffs, 32);
|
||||
|
||||
for(int i = 0; i < 32; i++)
|
||||
{
|
||||
p.set(i,cng.fit(1, 7, i, i * 2));
|
||||
}
|
||||
|
||||
byte[] dat = p.write();
|
||||
Iris.info("RAW DATA: " + IO.bytesToHex(dat));
|
||||
|
||||
DataContainer<Integer> f = DataContainer.read(new ByteArrayInputStream(dat), ffs);
|
||||
byte[] d2 = f.write();
|
||||
if(Arrays.equals(dat, d2))
|
||||
{
|
||||
Iris.info("Correct! All data matches!");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Iris.warn("No match");
|
||||
Iris.error("RAW DATA: " + IO.bytesToHex(d2));
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +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.matter.slices;
|
||||
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.util.data.palette.Palette;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Sliced
|
||||
public class BiomeMatter extends RegistryMatter<IrisBiome> {
|
||||
public BiomeMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Palette<IrisBiome> getGlobalPalette() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BiomeMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, IrisBiome.class);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package com.volmit.iris.util.matter.slices;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.palette.Palette;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -31,6 +32,8 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class BlockMatter extends RawMatter<BlockData> {
|
||||
public static final BlockData AIR = Material.AIR.createBlockData();
|
||||
|
||||
public BlockMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
@@ -41,7 +44,7 @@ public class BlockMatter extends RawMatter<BlockData> {
|
||||
}
|
||||
|
||||
public BlockMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, BlockData.class);
|
||||
super(width, height, depth, BlockData.class, AIR);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x, y, z).setBlockData(d)));
|
||||
registerReader(World.class, (w, x, y, z) -> {
|
||||
BlockData d = w.getBlockAt(x, y, z).getBlockData();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BooleanMatter extends RawMatter<Boolean> {
|
||||
}
|
||||
|
||||
public BooleanMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, Boolean.class);
|
||||
super(width, height, depth, Boolean.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,8 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class CavernMatter extends RawMatter<MatterCavern> {
|
||||
public static final MatterCavern EMPTY = new MatterCavern(false, "", (byte) 0);
|
||||
|
||||
public CavernMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
@@ -39,7 +41,7 @@ public class CavernMatter extends RawMatter<MatterCavern> {
|
||||
}
|
||||
|
||||
public CavernMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterCavern.class);
|
||||
super(width, height, depth, MatterCavern.class, EMPTY);
|
||||
}
|
||||
|
||||
public static MatterCavern get(String customBiome, int liquid) {
|
||||
|
||||
@@ -23,11 +23,13 @@ import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
|
||||
@Sliced
|
||||
public class CompoundMatter extends NBTMatter<CompoundTag> {
|
||||
public static final CompoundTag EMPTY = new CompoundTag();
|
||||
|
||||
public CompoundMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
public CompoundMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, CompoundTag.class);
|
||||
super(width, height, depth, CompoundTag.class, EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class EntityMatter extends RawMatter<MatterEntityGroup> {
|
||||
public static final MatterEntityGroup EMPTY = new MatterEntityGroup();
|
||||
private transient KMap<IrisPosition, KList<Entity>> entityCache = new KMap<>();
|
||||
|
||||
public EntityMatter() {
|
||||
@@ -54,7 +55,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
|
||||
}
|
||||
|
||||
public EntityMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterEntityGroup.class);
|
||||
super(width, height, depth, MatterEntityGroup.class, EMPTY);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> {
|
||||
for (MatterEntity i : d.getEntities()) {
|
||||
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
|
||||
|
||||
@@ -1,64 +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.matter.slices;
|
||||
|
||||
import com.volmit.iris.util.data.palette.Palette;
|
||||
import com.volmit.iris.util.matter.MatterFluidBody;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class FluidBodyMatter extends RawMatter<MatterFluidBody> {
|
||||
public FluidBodyMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Palette<MatterFluidBody> getGlobalPalette() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public FluidBodyMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterFluidBody.class);
|
||||
}
|
||||
|
||||
public static MatterFluidBody get(String customBiome, boolean lava) {
|
||||
return new MatterFluidBody(true, customBiome, lava);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNode(MatterFluidBody b, DataOutputStream dos) throws IOException {
|
||||
dos.writeBoolean(b.isBody());
|
||||
dos.writeBoolean(b.isLava());
|
||||
dos.writeUTF(b.getCustomBiome());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatterFluidBody readNode(DataInputStream din) throws IOException {
|
||||
boolean b = din.readBoolean();
|
||||
boolean l = din.readBoolean();
|
||||
String v = din.readUTF();
|
||||
|
||||
return new MatterFluidBody(b, v, l);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class IntMatter extends RawMatter<Integer> {
|
||||
}
|
||||
|
||||
public IntMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, Integer.class);
|
||||
super(width, height, depth, Integer.class, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class LongMatter extends RawMatter<Long> {
|
||||
}
|
||||
|
||||
public LongMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, Long.class);
|
||||
super(width, height, depth, Long.class, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class MarkerMatter extends RawMatter<MatterMarker> {
|
||||
public static final MatterMarker NONE = new MatterMarker("none");
|
||||
public static final MatterMarker CAVE_FLOOR = new MatterMarker("cave_floor");
|
||||
public static final MatterMarker CAVE_CEILING = new MatterMarker("cave_ceiling");
|
||||
private static final KMap<String, MatterMarker> markers = new KMap<>();
|
||||
@@ -44,7 +45,7 @@ public class MarkerMatter extends RawMatter<MatterMarker> {
|
||||
}
|
||||
|
||||
public MarkerMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterMarker.class);
|
||||
super(width, height, depth, MatterMarker.class, NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,8 @@ package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.util.data.palette.Palette;
|
||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import com.volmit.iris.util.nbt.tag.IntTag;
|
||||
import com.volmit.iris.util.nbt.tag.Tag;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -28,8 +30,8 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NBTMatter<T extends Tag<?>> extends RawMatter<T> {
|
||||
public NBTMatter(int width, int height, int depth, Class<T> c) {
|
||||
super(width, height, depth, c);
|
||||
public NBTMatter(int width, int height, int depth, Class<T> c, T e) {
|
||||
super(width, height, depth, c, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,60 +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.matter.slices;
|
||||
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.data.palette.Palette;
|
||||
import com.volmit.iris.util.matter.MatterTile;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Sliced
|
||||
public class PlayerMatter extends RawMatter<Player> {
|
||||
public PlayerMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Palette<Player> getGlobalPalette() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlayerMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, Player.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNode(Player b, DataOutputStream dos) throws IOException {
|
||||
Varint.writeSignedVarLong(b.getUniqueId().getMostSignificantBits(), dos);
|
||||
Varint.writeSignedVarLong(b.getUniqueId().getLeastSignificantBits(), dos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player readNode(DataInputStream din) throws IOException {
|
||||
UUID id = new UUID(Varint.readSignedVarLong(din), Varint.readSignedVarLong(din));
|
||||
|
||||
return Bukkit.getPlayer(id);
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ public abstract class RawMatter<T> extends PaletteOrHunk<T> implements MatterSli
|
||||
@Getter
|
||||
private final Class<T> type;
|
||||
|
||||
public RawMatter(int width, int height, int depth, Class<T> type) {
|
||||
super(width, height, depth, false, () -> new MappedHunk<>(width, height, depth));
|
||||
public RawMatter(int width, int height, int depth, Class<T> type, T e) {
|
||||
super(width, height, depth, false, () -> new MappedHunk<>(width, height, depth), e);
|
||||
writers = new KMap<>();
|
||||
readers = new KMap<>();
|
||||
this.type = type;
|
||||
|
||||
@@ -1,33 +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.matter.slices;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
@Sliced
|
||||
public class RegionMatter extends RegistryMatter<IrisRegistrant> {
|
||||
public RegionMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
public RegionMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, IrisRegistrant.class);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,8 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class RegistryMatter<T extends IrisRegistrant> extends RawMatter<T> {
|
||||
public RegistryMatter(int width, int height, int depth, Class<T> c) {
|
||||
super(width, height, depth, c);
|
||||
public RegistryMatter(int width, int height, int depth, Class<T> c, T e) {
|
||||
super(width, height, depth, c, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,6 @@ public class SpawnerMatter extends RegistryMatter<IrisSpawner> {
|
||||
}
|
||||
|
||||
public SpawnerMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, IrisSpawner.class);
|
||||
super(width, height, depth, IrisSpawner.class, new IrisSpawner());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class StringMatter extends RawMatter<String> {
|
||||
}
|
||||
|
||||
public StringMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, String.class);
|
||||
super(width, height, depth, String.class, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class TileMatter extends RawMatter<MatterTile> {
|
||||
public static final MatterTile EMPTY = new MatterTile(new CompoundTag());
|
||||
|
||||
public TileMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
@@ -43,7 +45,7 @@ public class TileMatter extends RawMatter<MatterTile> {
|
||||
}
|
||||
|
||||
public TileMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterTile.class);
|
||||
super(width, height, depth, MatterTile.class, EMPTY);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
|
||||
registerReader(World.class, (w, x, y, z) -> {
|
||||
Location l = new Location(w, x, y, z);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UpdateMatter extends RawMatter<MatterUpdate> {
|
||||
}
|
||||
|
||||
public UpdateMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterUpdate.class);
|
||||
super(width, height, depth, MatterUpdate.class, OFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user