mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Use object placement options for jigsaw pieces
This commit is contained in:
parent
2869a2157b
commit
658b0595ff
@ -2,8 +2,10 @@ package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.nms.INMS;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisDimensionIndex;
|
||||
import com.volmit.iris.object.IrisPosition;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineCompound;
|
||||
import com.volmit.iris.scaffold.engine.EngineData;
|
||||
@ -62,6 +64,41 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
engineMetadata = EngineData.load(getEngineMetadataFile());
|
||||
engineMetadata.setDimension(rootDimension.getLoadKey());
|
||||
engineMetadata.setLastVersion(Iris.instance.getDescription().getVersion());
|
||||
|
||||
|
||||
if(engineMetadata.getStrongholdPosition() == null)
|
||||
{
|
||||
if(!(world instanceof FakeWorld && world instanceof HeightedFakeWorld))
|
||||
{
|
||||
Object nmsWorld = new V(world).invoke("getHandle");
|
||||
Object chunkProvider = new V(nmsWorld).invoke("getChunkProvider");
|
||||
Object chunkGenerator = new V(chunkProvider).invoke("getChunkGenerator");
|
||||
try {
|
||||
Class<?> clazz = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".ChunkGenerator");
|
||||
Class<?> clazzSG = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".StructureGenerator");
|
||||
Class<?> clazzBP = Class.forName("net.minecraft.server." + INMS.getNMSTag() + ".BlockPosition");
|
||||
Object bp = clazz.getDeclaredMethod("findNearestMapFeature",
|
||||
nmsWorld.getClass(),
|
||||
clazzSG,
|
||||
clazzBP,
|
||||
int.class,
|
||||
boolean.class
|
||||
).invoke(chunkGenerator,
|
||||
nmsWorld,
|
||||
clazzSG.getDeclaredField("STRONGHOLD").get(null),
|
||||
clazzBP.getDeclaredField("ZERO").get(null),
|
||||
100,
|
||||
false
|
||||
);
|
||||
engineMetadata.setStrongholdPosition(new IrisPosition((int)new V(bp, false).invoke("getX"), (int)new V(bp, false).invoke("getY"), (int)new V(bp, false).invoke("getZ")));
|
||||
} catch (Throwable ignored) {
|
||||
engineMetadata.setStrongholdPosition(new IrisPosition(1337, 32, -1337));
|
||||
Iris.warn("Couldn't properly find the stronghold positon for this world. Is this headless mode?");
|
||||
}
|
||||
Iris.info("Stronghold: " + engineMetadata.getStrongholdPosition().toString());
|
||||
}
|
||||
}
|
||||
|
||||
saveEngineMetadata();
|
||||
populators = new KList<>();
|
||||
|
||||
@ -122,6 +159,11 @@ public class IrisEngineCompound implements EngineCompound {
|
||||
Iris.instance.registerListener(this);
|
||||
}
|
||||
|
||||
public IrisPosition getStrongholdPosition()
|
||||
{
|
||||
return engineMetadata.getStrongholdPosition();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldSaveEvent e)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ public class INMS
|
||||
return binding;
|
||||
}
|
||||
|
||||
private static final String getNMSTag()
|
||||
public static final String getNMSTag()
|
||||
{
|
||||
if(IrisSettings.get().getGeneral().isDisableNMS())
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.scaffold.cache.AtomicCache;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -33,13 +32,9 @@ public class IrisJigsawPiece extends IrisRegistrant
|
||||
@Desc("The connectors this object contains")
|
||||
private KList<IrisJigsawPieceConnector> connectors = new KList<>();
|
||||
|
||||
@Desc("Change how this object places depending on the terrain height map.")
|
||||
@DontObfuscate
|
||||
private ObjectPlaceMode placeMode = ObjectPlaceMode.FAST_MAX_HEIGHT;
|
||||
|
||||
@Desc("Configure everything about the object placement. Please don't define this unless you actually need it as using this option will slow down the jigsaw deign stage. Use this where you need it, just avoid using it everywhere to keep things fast.")
|
||||
@DontObfuscate
|
||||
private IrisObjectPlacement placementOverrides;
|
||||
private IrisObjectPlacement placementOptions = new IrisObjectPlacement().setMode(ObjectPlaceMode.FAST_MAX_HEIGHT);
|
||||
|
||||
private transient AtomicCache<Integer> max2dDim = new AtomicCache<>();
|
||||
private transient AtomicCache<Integer> max3dDim = new AtomicCache<>();
|
||||
@ -88,14 +83,8 @@ public class IrisJigsawPiece extends IrisRegistrant
|
||||
p.setLoader(getLoader());
|
||||
p.setLoadKey(getLoadKey());
|
||||
p.setLoadFile(getLoadFile());
|
||||
p.setPlaceMode(getPlaceMode());
|
||||
p.setConnectors(new KList<>());
|
||||
|
||||
if(getPlacementOverrides() != null)
|
||||
{
|
||||
// God fucking dammit
|
||||
p.setPlacementOverrides(new Gson().fromJson(new Gson().toJson(getPlacementOverrides()), IrisObjectPlacement.class));
|
||||
}
|
||||
p.setPlacementOptions(getPlacementOptions());
|
||||
|
||||
for(IrisJigsawPieceConnector i : getConnectors())
|
||||
{
|
||||
@ -108,4 +97,8 @@ public class IrisJigsawPiece extends IrisRegistrant
|
||||
public boolean isTerminal() {
|
||||
return connectors.size() == 1;
|
||||
}
|
||||
|
||||
public ObjectPlaceMode getPlaceMode() {
|
||||
return getPlacementOptions().getMode();
|
||||
}
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ public class PlannedStructure {
|
||||
{
|
||||
IrisObjectPlacement options = o;
|
||||
|
||||
if(i.getPiece().getPlacementOverrides() != null)
|
||||
if(i.getPiece().getPlacementOptions() != null)
|
||||
{
|
||||
options= i.getPiece().getPlacementOverrides();
|
||||
options= i.getPiece().getPlacementOptions();
|
||||
options.getRotation().setEnabled(false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user