mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 06:41:08 +00:00
+1
-1
@@ -247,7 +247,7 @@ allprojects {
|
|||||||
compileOnly 'it.unimi.dsi:fastutil:8.5.8'
|
compileOnly 'it.unimi.dsi:fastutil:8.5.8'
|
||||||
compileOnly 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
|
compileOnly 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
|
||||||
compileOnly 'org.zeroturnaround:zt-zip:1.14'
|
compileOnly 'org.zeroturnaround:zt-zip:1.14'
|
||||||
compileOnly 'com.google.code.gson:gson:2.9.0'
|
compileOnly 'com.google.code.gson:gson:2.10.1'
|
||||||
compileOnly 'org.ow2.asm:asm:9.2'
|
compileOnly 'org.ow2.asm:asm:9.2'
|
||||||
compileOnly 'com.google.guava:guava:33.0.0-jre'
|
compileOnly 'com.google.guava:guava:33.0.0-jre'
|
||||||
compileOnly 'bsf:bsf:2.4.0'
|
compileOnly 'bsf:bsf:2.4.0'
|
||||||
|
|||||||
@@ -22,15 +22,17 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.math.AxisAlignedBB;
|
import com.volmit.iris.util.math.AxisAlignedBB;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
|
||||||
@Data
|
@Data
|
||||||
public class PlannedPiece {
|
public class PlannedPiece {
|
||||||
private IrisPosition position;
|
private IrisPosition position;
|
||||||
@@ -45,6 +47,12 @@ public class PlannedPiece {
|
|||||||
private AxisAlignedBB box;
|
private AxisAlignedBB box;
|
||||||
@EqualsAndHashCode.Exclude
|
@EqualsAndHashCode.Exclude
|
||||||
private PlannedStructure structure;
|
private PlannedStructure structure;
|
||||||
|
@EqualsAndHashCode.Exclude
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private ParentConnection parent = null;
|
||||||
|
@EqualsAndHashCode.Exclude
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
|
private KMap<IrisJigsawPieceConnector, IrisPosition> realPositions;
|
||||||
|
|
||||||
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece) {
|
public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece) {
|
||||||
this(structure, position, piece, 0, 0, 0);
|
this(structure, position, piece, 0, 0, 0);
|
||||||
@@ -66,6 +74,7 @@ public class PlannedPiece {
|
|||||||
this.object.setLoadKey(piece.getObject());
|
this.object.setLoadKey(piece.getObject());
|
||||||
this.ogObject.setLoadKey(piece.getObject());
|
this.ogObject.setLoadKey(piece.getObject());
|
||||||
this.connected = new KList<>();
|
this.connected = new KList<>();
|
||||||
|
this.realPositions = new KMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,11 +133,21 @@ public class PlannedPiece {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(IrisJigsawPieceConnector c) {
|
public KList<IrisJigsawPieceConnector> getChildConnectors() {
|
||||||
if (piece.getConnectors().contains(c)) {
|
ParentConnection pc = getParent();
|
||||||
return connected.addIfMissing(c);
|
KList<IrisJigsawPieceConnector> c = getConnected().copy();
|
||||||
}
|
if (pc != null) c.removeIf(i -> i.equals(pc.connector));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connect(IrisJigsawPieceConnector c, PlannedPiece p, IrisJigsawPieceConnector pc) {
|
||||||
|
if (piece.getConnectors().contains(c) && p.getPiece().getConnectors().contains(pc)) {
|
||||||
|
if (connected.contains(c) || p.connected.contains(pc)) return false;
|
||||||
|
connected.add(c);
|
||||||
|
p.connected.add(pc);
|
||||||
|
p.parent = new ParentConnection(this, c, p, pc);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,4 +181,27 @@ public class PlannedPiece {
|
|||||||
public boolean isFull() {
|
public boolean isFull() {
|
||||||
return connected.size() >= piece.getConnectors().size();
|
return connected.size() >= piece.getConnectors().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRealPositions(int x, int y, int z, IObjectPlacer placer) {
|
||||||
|
boolean isUnderwater = piece.getPlacementOptions().isUnderwater();
|
||||||
|
for (IrisJigsawPieceConnector c : piece.getConnectors()) {
|
||||||
|
var pos = c.getPosition().add(new IrisPosition(x, 0, z));
|
||||||
|
if (y < 0) {
|
||||||
|
pos.setY(pos.getY() + placer.getHighest(pos.getX(), pos.getZ(), getData(), isUnderwater) + (object.getH() / 2));
|
||||||
|
} else {
|
||||||
|
pos.setY(pos.getY() + y);
|
||||||
|
}
|
||||||
|
realPositions.put(c, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ParentConnection(PlannedPiece parent, IrisJigsawPieceConnector parentConnector, PlannedPiece self, IrisJigsawPieceConnector connector) {
|
||||||
|
public IrisPosition getTargetPosition() {
|
||||||
|
var pos = parent.realPositions.get(parentConnector);
|
||||||
|
if (pos == null) return null;
|
||||||
|
return pos.add(new IrisPosition(parentConnector.getDirection().toVector()))
|
||||||
|
.sub(connector.getPosition())
|
||||||
|
.sub(new IrisPosition(self.object.getCenter()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public class PlannedStructure {
|
|||||||
options = i.getPiece().getPlacementOptions();
|
options = i.getPiece().getPlacementOptions();
|
||||||
options.getRotation().setEnabled(false);
|
options.getRotation().setEnabled(false);
|
||||||
options.setRotateTowardsSlope(false);
|
options.setRotateTowardsSlope(false);
|
||||||
|
options.setWarp(new IrisGeneratorStyle(NoiseStyle.FLAT));
|
||||||
} else {
|
} else {
|
||||||
options.setMode(i.getPiece().getPlaceMode());
|
options.setMode(i.getPiece().getPlaceMode());
|
||||||
}
|
}
|
||||||
@@ -125,6 +126,17 @@ public class PlannedStructure {
|
|||||||
height = i.getStructure().getStructure().getLockY();
|
height = i.getStructure().getStructure().getLockY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlannedPiece.ParentConnection connection = i.getParent();
|
||||||
|
if (connection != null && connection.connector().isLockY()) {
|
||||||
|
var pos = connection.getTargetPosition();
|
||||||
|
if (pos != null) {
|
||||||
|
height = pos.getY();
|
||||||
|
offset = 0;
|
||||||
|
} else {
|
||||||
|
Iris.warn("Failed to get target position for " + v.getLoadKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
height += offset + (v.getH() / 2);
|
height += offset + (v.getH() / 2);
|
||||||
|
|
||||||
if (options.getMode().equals(ObjectPlaceMode.PAINT)) {
|
if (options.getMode().equals(ObjectPlaceMode.PAINT)) {
|
||||||
@@ -133,6 +145,7 @@ public class PlannedStructure {
|
|||||||
|
|
||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
int id = rng.i(0, Integer.MAX_VALUE);
|
||||||
JigsawPieceContainer container = JigsawPieceContainer.toContainer(i.getPiece());
|
JigsawPieceContainer container = JigsawPieceContainer.toContainer(i.getPiece());
|
||||||
|
i.setRealPositions(xx, height, zz, placer);
|
||||||
return v.place(xx, height, zz, placer, options, rng, (b, data) -> {
|
return v.place(xx, height, zz, placer, options, rng, (b, data) -> {
|
||||||
e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id);
|
e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id);
|
||||||
e.set(b.getX(), b.getY(), b.getZ(), container);
|
e.set(b.getX(), b.getY(), b.getZ(), container);
|
||||||
@@ -247,8 +260,7 @@ public class PlannedStructure {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
piece.connect(pieceConnector);
|
piece.connect(pieceConnector, test, testConnector);
|
||||||
test.connect(testConnector);
|
|
||||||
pieces.add(test);
|
pieces.add(test);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ public class IrisJigsawPieceConnector {
|
|||||||
@Required
|
@Required
|
||||||
private IrisDirection direction = IrisDirection.UP_POSITIVE_Y;
|
private IrisDirection direction = IrisDirection.UP_POSITIVE_Y;
|
||||||
|
|
||||||
|
@Desc("Lock the Y position of this connector")
|
||||||
|
private boolean lockY = false;
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return direction.getFace().name() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")";
|
return direction.getFace().name() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ public class IrisObjectRotation {
|
|||||||
i.setPosition(rotate(i.getPosition()));
|
i.setPosition(rotate(i.getPosition()));
|
||||||
i.setDirection(rotate(i.getDirection()));
|
i.setDirection(rotate(i.getDirection()));
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
var translate = piece.getPlacementOptions().getTranslate();
|
||||||
|
var pos = rotate(new IrisPosition(translate.getX(), translate.getY(), translate.getZ()));
|
||||||
|
translate.setX(pos.getX()).setY(pos.getY()).setZ(pos.getZ());
|
||||||
|
} catch (NullPointerException ignored) {}
|
||||||
|
|
||||||
return piece;
|
return piece;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ libraries:
|
|||||||
- commons-io:commons-io:2.13.0
|
- commons-io:commons-io:2.13.0
|
||||||
- io.timeandspace:smoothie-map:2.0.2
|
- io.timeandspace:smoothie-map:2.0.2
|
||||||
- com.google.guava:guava:31.0.1-jre
|
- com.google.guava:guava:31.0.1-jre
|
||||||
- com.google.code.gson:gson:2.8.9
|
- com.google.code.gson:gson:2.10.1
|
||||||
- org.zeroturnaround:zt-zip:1.14
|
- org.zeroturnaround:zt-zip:1.14
|
||||||
- it.unimi.dsi:fastutil:8.5.6
|
- it.unimi.dsi:fastutil:8.5.6
|
||||||
- org.ow2.asm:asm:9.2
|
- org.ow2.asm:asm:9.2
|
||||||
|
|||||||
Reference in New Issue
Block a user