Piece support twists

This commit is contained in:
Daniel Mills 2021-01-09 02:01:23 -05:00
parent f7bd48cc9a
commit b81765adda

View File

@ -5,6 +5,9 @@ import com.volmit.iris.object.*;
import com.volmit.iris.util.AxisAlignedBB;
import com.volmit.iris.util.KList;
import lombok.Data;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.BlockVector;
@Data
public class PlannedPiece {
@ -13,8 +16,8 @@ public class PlannedPiece {
private IrisJigsawPiece piece;
private IrisObjectRotation rotation;
private IrisDataManager data;
private AxisAlignedBB box;
private KList<IrisPosition> connected;
private int rotationKey;
public PlannedPiece(IrisPosition position, IrisJigsawPiece piece)
{
@ -24,14 +27,27 @@ public class PlannedPiece {
public PlannedPiece(IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz)
{
this.position = position;
rotationKey = (rz * 100) + (rx * 10) + ry;
this.data = piece.getLoader();
this.rotation = IrisObjectRotation.of(rx*90, ry*90, rz*90);
this.rotation = IrisObjectRotation.of(rx*90D, ry*90D, rz*90D);
this.object = rotation.rotateCopy(data.getObjectLoader().load(piece.getObject()));
this.piece = rotation.rotateCopy(piece);
this.box = object.getAABB();
this.piece.setLoadKey(piece.getLoadKey());
this.object.setLoadKey(object.getLoadKey());
this.connected = new KList<>();
}
public String toString()
{
return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotationKey + "]";
}
public AxisAlignedBB getBox()
{
BlockVector v = getObject().getCenter();
return object.getAABB().shifted(position.add(new IrisPosition(object.getCenter())));
}
public boolean contains(IrisPosition p)
{
return getBox().contains(p);
@ -89,10 +105,14 @@ public class PlannedPiece {
public IrisPosition getWorldPosition(IrisPosition position)
{
return this.position.add(position);
return this.position.add(position).add(new IrisPosition(object.getCenter()));
}
public boolean isFull() {
return connected.size() >= piece.getConnectors().size();
}
public void place(World world) {
getObject().placeCenterY(new Location(world, position.getX(), position.getY(), position.getZ()));
}
}