mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-08 00:36:19 +00:00
Fixes
This commit is contained in:
@@ -22,8 +22,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class IrisMatter implements Matter {
|
||||
private static final KMap<Class<?>, MatterSlice<?>> slicers = buildSlicers();
|
||||
|
||||
@@ -40,7 +38,7 @@ public class IrisMatter implements Matter {
|
||||
private final int depth;
|
||||
|
||||
@Getter
|
||||
private KMap<Class<?>, MatterSlice<?>> sliceMap;
|
||||
private final KMap<Class<?>, MatterSlice<?>> sliceMap;
|
||||
|
||||
public IrisMatter(int width, int height, int depth) {
|
||||
this.width = width;
|
||||
|
||||
@@ -181,20 +181,19 @@ public interface Matter {
|
||||
|
||||
/**
|
||||
* Rotate a matter object into a new object
|
||||
*
|
||||
* @param x the x rotation (degrees)
|
||||
* @param y the y rotation (degrees)
|
||||
* @param z the z rotation (degrees)
|
||||
* @return the new rotated matter object
|
||||
*/
|
||||
default Matter rotate(double x, double y, double z)
|
||||
{
|
||||
default Matter rotate(double x, double y, double z) {
|
||||
IrisPosition rs = Hunk.rotatedBounding(getWidth(), getHeight(), getDepth(), x, y, z);
|
||||
Matter n = new IrisMatter(rs.getX(), rs.getY(), rs.getZ());
|
||||
n.getHeader().setAuthor(getHeader().getAuthor());
|
||||
n.getHeader().setCreatedAt(getHeader().getCreatedAt());
|
||||
|
||||
for(Class<?> i : getSliceTypes())
|
||||
{
|
||||
for (Class<?> i : getSliceTypes()) {
|
||||
getSlice(i).rotateSliceInto(n, x, y, z);
|
||||
}
|
||||
|
||||
@@ -234,8 +233,7 @@ public interface Matter {
|
||||
*/
|
||||
Map<Class<?>, MatterSlice<?>> getSliceMap();
|
||||
|
||||
default void write(File f) throws IOException
|
||||
{
|
||||
default void write(File f) throws IOException {
|
||||
FileOutputStream out = new FileOutputStream(f);
|
||||
GZIPOutputStream gzo = new GZIPOutputStream(out);
|
||||
write(gzo);
|
||||
@@ -265,8 +263,7 @@ public interface Matter {
|
||||
dos.flush();
|
||||
}
|
||||
|
||||
static Matter read(File f) throws IOException, ClassNotFoundException
|
||||
{
|
||||
static Matter read(File f) throws IOException, ClassNotFoundException {
|
||||
FileInputStream in = new FileInputStream(f);
|
||||
GZIPInputStream gzi = new GZIPInputStream(in);
|
||||
Matter m = read(gzi);
|
||||
@@ -274,8 +271,7 @@ public interface Matter {
|
||||
return m;
|
||||
}
|
||||
|
||||
static Matter read(InputStream in) throws IOException, ClassNotFoundException
|
||||
{
|
||||
static Matter read(InputStream in) throws IOException, ClassNotFoundException {
|
||||
return read(in, (b) -> new IrisMatter(b.getX(), b.getY(), b.getZ()));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.volmit.iris.util.hunk.storage.MappedHunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -42,39 +41,30 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
|
||||
<W> MatterReader<W, T> readFrom(Class<W> mediumType);
|
||||
|
||||
default Class<?> getClass(Object w)
|
||||
{
|
||||
default Class<?> getClass(Object w) {
|
||||
Class<?> c = w.getClass();
|
||||
|
||||
if(w instanceof World)
|
||||
{
|
||||
if (w instanceof World) {
|
||||
c = World.class;
|
||||
}else if(w instanceof BlockData)
|
||||
{
|
||||
} else if (w instanceof BlockData) {
|
||||
c = BlockData.class;
|
||||
}else if(w instanceof Entity)
|
||||
{
|
||||
} else if (w instanceof Entity) {
|
||||
c = Entity.class;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
default <W> boolean writeInto(W w, int x, int y, int z)
|
||||
{
|
||||
default <W> boolean writeInto(W w, int x, int y, int z) {
|
||||
MatterWriter<W, T> injector = (MatterWriter<W, T>) writeInto(getClass(w));
|
||||
|
||||
if(injector == null)
|
||||
{
|
||||
if (injector == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = x; i < x + getWidth(); i++)
|
||||
{
|
||||
for(int j = y; j < y + getHeight(); j++)
|
||||
{
|
||||
for(int k = z; k < z + getDepth(); k++)
|
||||
{
|
||||
for (int i = x; i < x + getWidth(); i++) {
|
||||
for (int j = y; j < y + getHeight(); j++) {
|
||||
for (int k = z; k < z + getDepth(); k++) {
|
||||
injector.writeMatter(w, get(i - x, j - y, k - z), i, j, k);
|
||||
}
|
||||
}
|
||||
@@ -83,21 +73,16 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
return true;
|
||||
}
|
||||
|
||||
default <W> boolean readFrom(W w, int x, int y, int z)
|
||||
{
|
||||
default <W> boolean readFrom(W w, int x, int y, int z) {
|
||||
MatterReader<W, T> ejector = (MatterReader<W, T>) readFrom(getClass(w));
|
||||
|
||||
if(ejector == null)
|
||||
{
|
||||
if (ejector == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = x; i < x + getWidth(); i++)
|
||||
{
|
||||
for(int j = y; j < y + getHeight(); j++)
|
||||
{
|
||||
for(int k = z; k < z + getDepth(); k++)
|
||||
{
|
||||
for (int i = x; i < x + getWidth(); i++) {
|
||||
for (int j = y; j < y + getHeight(); j++) {
|
||||
for (int k = z; k < z + getDepth(); k++) {
|
||||
set(i - x, j - y, k - z, ejector.readMatter(w, i, j, k));
|
||||
}
|
||||
}
|
||||
@@ -110,18 +95,15 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
// RawMatter<T> ex MappedHunk<T>
|
||||
// IMatterSlice<T> ex Hunk<T>
|
||||
|
||||
default int getCount()
|
||||
{
|
||||
return ((MappedHunk<?>)this).getEntryCount();
|
||||
default int getCount() {
|
||||
return ((MappedHunk<?>) this).getEntryCount();
|
||||
}
|
||||
|
||||
default boolean canWrite(Class<?> mediumType)
|
||||
{
|
||||
default boolean canWrite(Class<?> mediumType) {
|
||||
return writeInto(mediumType) != null;
|
||||
}
|
||||
|
||||
default boolean canRead(Class<?> mediumType)
|
||||
{
|
||||
default boolean canRead(Class<?> mediumType) {
|
||||
return readFrom(mediumType) != null;
|
||||
}
|
||||
|
||||
@@ -153,8 +135,7 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
}
|
||||
}
|
||||
|
||||
default void rotateSliceInto(Matter n, double x, double y, double z)
|
||||
{
|
||||
rotate(x,y,z, (_x, _y, _z) -> n.slice(getType()));
|
||||
default void rotateSliceInto(Matter n, double x, double y, double z) {
|
||||
rotate(x, y, z, (_x, _y, _z) -> n.slice(getType()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,9 @@
|
||||
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class BiomeMatter extends RegistryMatter<IrisBiome> {
|
||||
public BiomeMatter() {
|
||||
|
||||
@@ -22,9 +22,6 @@ import com.volmit.iris.engine.parallax.ParallaxAccess;
|
||||
import com.volmit.iris.engine.parallax.ParallaxWorld;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||
import com.volmit.iris.util.nbt.mca.NBTWorld;
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@@ -40,9 +37,9 @@ public class BlockMatter extends RawMatter<BlockData> {
|
||||
|
||||
public BlockMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, BlockData.class);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x,y,z).setBlockData(d)));
|
||||
registerWriter(ParallaxWorld.class, (w, d, x, y, z) -> w.setBlock(x,y,z,d));
|
||||
registerReader(World.class, (w, x, y, z) -> w.getBlockAt(x,y,z).getBlockData());
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> w.getBlockAt(x, y, z).setBlockData(d)));
|
||||
registerWriter(ParallaxWorld.class, (w, d, x, y, z) -> w.setBlock(x, y, z, d));
|
||||
registerReader(World.class, (w, x, y, z) -> w.getBlockAt(x, y, z).getBlockData());
|
||||
registerReader(ParallaxWorld.class, ParallaxAccess::getBlock);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ package com.volmit.iris.util.matter.slices;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.hunk.storage.MappedHunk;
|
||||
import com.volmit.iris.util.matter.MatterReader;
|
||||
import com.volmit.iris.util.matter.MatterWriter;
|
||||
import com.volmit.iris.util.matter.MatterSlice;
|
||||
import com.volmit.iris.util.matter.MatterWriter;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
@@ -42,25 +42,21 @@ public abstract class RawMatter<T> extends MappedHunk<T> implements MatterSlice<
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected <W> void registerWriter(Class<W> mediumType, MatterWriter<W, T> injector)
|
||||
{
|
||||
protected <W> void registerWriter(Class<W> mediumType, MatterWriter<W, T> injector) {
|
||||
injectors.put(mediumType, injector);
|
||||
}
|
||||
|
||||
protected <W> void registerReader(Class<W> mediumType, MatterReader<W, T> injector)
|
||||
{
|
||||
protected <W> void registerReader(Class<W> mediumType, MatterReader<W, T> injector) {
|
||||
ejectors.put(mediumType, injector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <W> MatterWriter<W, T> writeInto(Class<W> mediumType)
|
||||
{
|
||||
public <W> MatterWriter<W, T> writeInto(Class<W> mediumType) {
|
||||
return (MatterWriter<W, T>) injectors.get(mediumType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <W> MatterReader<W, T> readFrom(Class<W> mediumType)
|
||||
{
|
||||
public <W> MatterReader<W, T> readFrom(Class<W> mediumType) {
|
||||
return (MatterReader<W, T>) ejectors.get(mediumType);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
@Sliced
|
||||
@@ -27,6 +26,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.nbt.io.NBTUtil;
|
||||
import com.volmit.iris.util.nbt.tag.Tag;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.spawners.IrisSpawner;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
@@ -27,6 +26,7 @@ public class SpawnerMatter extends RegistryMatter<IrisSpawner> {
|
||||
public SpawnerMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
public SpawnerMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, IrisSpawner.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.parallax.ParallaxAccess;
|
||||
import com.volmit.iris.engine.parallax.ParallaxWorld;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class TileMatter extends RawMatter<TileState> {
|
||||
public TileMatter() {
|
||||
this(1, 1, 1);
|
||||
}
|
||||
|
||||
public TileMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, TileState.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNode(TileState b, DataOutputStream dos) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileState readNode(DataInputStream din) throws IOException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user