mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Jigsaw structures max dimension allowed
This commit is contained in:
parent
2afb468ae4
commit
ee6e9b059a
@ -1,11 +1,15 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.scaffold.cache.AtomicCache;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ -32,6 +36,35 @@ public class IrisJigsawPiece extends IrisRegistrant
|
|||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
private ObjectPlaceMode placeMode;
|
private ObjectPlaceMode placeMode;
|
||||||
|
|
||||||
|
AtomicCache<Integer> max2dDim = new AtomicCache<>();
|
||||||
|
AtomicCache<Integer> max3dDim = new AtomicCache<>();
|
||||||
|
|
||||||
|
public int getMax2dDimension() {
|
||||||
|
return max2dDim.aquire(() -> {
|
||||||
|
try {
|
||||||
|
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
|
||||||
|
return Math.max(v.getBlockX(), v.getBlockZ());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMax3dDimension() {
|
||||||
|
return max2dDim.aquire(() -> {
|
||||||
|
try {
|
||||||
|
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
|
||||||
|
return Math.max(Math.max(v.getBlockX(), v.getBlockZ()), v.getBlockY());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) {
|
public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) {
|
||||||
for(IrisJigsawPieceConnector i : connectors)
|
for(IrisJigsawPieceConnector i : connectors)
|
||||||
{
|
{
|
||||||
|
@ -35,4 +35,53 @@ public class IrisJigsawStructure extends IrisRegistrant
|
|||||||
private boolean terminate = true;
|
private boolean terminate = true;
|
||||||
|
|
||||||
private AtomicCache<Integer> maxDimension = new AtomicCache<>();
|
private AtomicCache<Integer> maxDimension = new AtomicCache<>();
|
||||||
|
|
||||||
|
private void loadPool(String p, KList<String> pools, KList<String> pieces)
|
||||||
|
{
|
||||||
|
IrisJigsawPool pool = getLoader().getJigsawPoolLoader().load(p);
|
||||||
|
|
||||||
|
for(String i : pool.getPieces())
|
||||||
|
{
|
||||||
|
if(pieces.addIfMissing(i))
|
||||||
|
{
|
||||||
|
loadPiece(i, pools, pieces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadPiece(String p, KList<String> pools, KList<String> pieces)
|
||||||
|
{
|
||||||
|
IrisJigsawPiece piece = getLoader().getJigsawPieceLoader().load(p);
|
||||||
|
for(IrisJigsawPieceConnector i : piece.getConnectors())
|
||||||
|
{
|
||||||
|
for(String j : i.getPools())
|
||||||
|
{
|
||||||
|
if(pools.addIfMissing(j))
|
||||||
|
{
|
||||||
|
loadPool(p, pools, pieces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxDimension()
|
||||||
|
{
|
||||||
|
return maxDimension.aquire(() -> {
|
||||||
|
int max = 0;
|
||||||
|
KList<String> pools = new KList<>();
|
||||||
|
KList<String> pieces = new KList<>();
|
||||||
|
|
||||||
|
for(String i : getPieces())
|
||||||
|
{
|
||||||
|
loadPiece(i, pools, pieces);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String i : pieces)
|
||||||
|
{
|
||||||
|
max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension());
|
||||||
|
}
|
||||||
|
|
||||||
|
return max;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
24
src/main/java/com/volmit/iris/object/IrisPosition2D.java
Normal file
24
src/main/java/com/volmit/iris/object/IrisPosition2D.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.Desc;
|
||||||
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Desc("Represents a position")
|
||||||
|
@Data
|
||||||
|
public class IrisPosition2D
|
||||||
|
{
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The x position")
|
||||||
|
private int x = 0;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The z position")
|
||||||
|
private int z = 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user