mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-10 09:46:03 +00:00
Strange solutions to rotating matter objects
This commit is contained in:
@@ -18,7 +18,9 @@
|
||||
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
|
||||
import java.io.*;
|
||||
@@ -177,6 +179,28 @@ public interface Matter {
|
||||
return (MatterSlice<T>) getSlice(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
getSlice(i).rotateSliceInto(n, x, y, z);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a slice exists for a given type
|
||||
*
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.hunk.storage.MappedHunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -147,4 +148,9 @@ public interface MatterSlice<T> extends Hunk<T> {
|
||||
setRaw(pos[0], pos[1], pos[2], palette.readNode(din));
|
||||
}
|
||||
}
|
||||
|
||||
default void rotateSliceInto(Matter n, double x, double y, double z)
|
||||
{
|
||||
rotate(x,y,z, (_x, _y, _z) -> n.slice(getType()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user