mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-02 16:07:06 +00:00
better fix for jigsaw loot
This commit is contained in:
parent
ee3e631789
commit
566169cdbf
@ -753,7 +753,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
PlacedObject o = getObjectPlacement(x, y, z);
|
||||
|
||||
if (o != null && o.getObject() != null) {
|
||||
return o.getObject().getLoadKey() + "@" + o.getId();
|
||||
return o.getObject().getLoadKey() + "@" + o.getId() + "#" + (o.getPlacement() != null);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -768,6 +768,14 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
String[] v = objectAt.split("\\Q@\\E");
|
||||
String object = v[0];
|
||||
int id = Integer.parseInt(v[1]);
|
||||
|
||||
|
||||
IrisContext.getOr(this);
|
||||
IrisJigsawPiece piece = getMantle().getMantle().get(x, y, z, IrisJigsawPiece.class);
|
||||
if (piece != null && piece.getObject().equals(object)) {
|
||||
return new PlacedObject(piece.getPlacementOptions(), getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
|
||||
IrisRegion region = getRegion(x, z);
|
||||
|
||||
for (IrisObjectPlacement i : region.getObjects()) {
|
||||
@ -784,55 +792,9 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
}
|
||||
|
||||
KList<String> pieces = new KList<>();
|
||||
KList<String> pools = new KList<>();
|
||||
int r = 2;
|
||||
for (int xX = -r; xX <= r; xX++) {
|
||||
for (int zZ = -r; zZ <= r; zZ++) {
|
||||
IrisJigsawStructure structure = getStructureAt((x >> 4) + xX, (z >> 4) + zZ);
|
||||
if (structure != null) {
|
||||
for (String pieceID : structure.getPieces()) {
|
||||
IrisJigsawPiece result = searchAllPieces(pieceID, object, pieces, pools);
|
||||
if (result != null) {
|
||||
pieces.clear();
|
||||
pools.clear();
|
||||
return new PlacedObject(result.getPlacementOptions(), getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pieces.clear();
|
||||
pools.clear();
|
||||
|
||||
return new PlacedObject(null, getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
|
||||
private IrisJigsawPiece searchAllPieces(String pieceID, String target, KList<String> pieces, KList<String> pools) {
|
||||
IrisJigsawPiece piece = getData().getJigsawPieceLoader().load(pieceID);
|
||||
if (piece.getObject().equals(target))
|
||||
return piece;
|
||||
|
||||
pieces.add(pieceID);
|
||||
for (IrisJigsawPieceConnector connector : piece.getConnectors()) {
|
||||
for (String poolID : connector.getPools()) {
|
||||
if (pools.contains(poolID))
|
||||
continue;
|
||||
pools.add(poolID);
|
||||
|
||||
for (String pieceId : getData().getJigsawPoolLoader().load(poolID).getPieces()) {
|
||||
if (pieces.contains(pieceId))
|
||||
continue;
|
||||
|
||||
IrisJigsawPiece piece1 = searchAllPieces(pieceId, target, pieces, pools);
|
||||
if (piece1 != null)
|
||||
return piece1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int getCacheID();
|
||||
|
||||
default IrisBiome getBiomeOrMantle(Location l) {
|
||||
|
@ -23,6 +23,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
@ -30,6 +31,8 @@ import com.volmit.iris.util.math.RNG;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@Data
|
||||
public class PlannedStructure {
|
||||
@ -70,7 +73,7 @@ public class PlannedStructure {
|
||||
}
|
||||
}
|
||||
|
||||
public void place(IObjectPlacer placer, Mantle e, Engine eng) {
|
||||
public void place(MantleWriter placer, Mantle e, Engine eng) {
|
||||
IrisObjectPlacement options = new IrisObjectPlacement();
|
||||
options.getRotation().setEnabled(false);
|
||||
int startHeight = pieces.get(0).getPosition().getY();
|
||||
@ -80,7 +83,7 @@ public class PlannedStructure {
|
||||
}
|
||||
}
|
||||
|
||||
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e, Engine eng) {
|
||||
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, MantleWriter placer, Mantle e, Engine eng) {
|
||||
IrisObjectPlacement options = o;
|
||||
|
||||
if (i.getPiece().getPlacementOptions() != null) {
|
||||
@ -117,7 +120,69 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
vo.place(xx, height, zz, placer, options, rng, (b, data) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
vo.place(xx, height, zz, new IObjectPlacer() {
|
||||
@Override
|
||||
public int getHighest(int x, int z, IrisData data) {
|
||||
return placer.getHighest(x, z, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
|
||||
return placer.getHighest(x, z, data, ignoreFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockData d) {
|
||||
placer.setData(x, y, z, i.getPiece());
|
||||
placer.set(x, y, z, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData get(int x, int y, int z) {
|
||||
placer.setData(x, y, z, i.getPiece());
|
||||
return placer.get(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventingDecay() {
|
||||
return placer.isPreventingDecay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCarved(int x, int y, int z) {
|
||||
return placer.isCarved(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid(int x, int y, int z) {
|
||||
return placer.isSolid(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return placer.isUnderwater(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidHeight() {
|
||||
return placer.getFluidHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugSmartBore() {
|
||||
return placer.isDebugSmartBore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) {
|
||||
placer.setTile(xx, yy, zz, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Engine getEngine() {
|
||||
return placer.getEngine();
|
||||
}
|
||||
}, options, rng, (b, data) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
}
|
||||
|
||||
public void place(World world) {
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.volmit.iris.util.matter.slices;
|
||||
|
||||
import com.volmit.iris.engine.object.IrisJigsawPiece;
|
||||
import com.volmit.iris.util.matter.Sliced;
|
||||
|
||||
@Sliced
|
||||
public class JigsawPieceMatter extends RegistryMatter<IrisJigsawPiece> {
|
||||
public JigsawPieceMatter() {
|
||||
this(1,1,1);
|
||||
}
|
||||
|
||||
public JigsawPieceMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, IrisJigsawPiece.class, new IrisJigsawPiece());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user