From 832bad1fee5062f6b399c37741796c5597208b94 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Mon, 9 Aug 2021 09:07:22 -0400 Subject: [PATCH] Planned Structure support mantle --- .../iris/engine/jigsaw/PlannedStructure.java | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index 2ba155748..ac52e8a35 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -36,6 +36,7 @@ import com.volmit.iris.engine.object.objects.*; import com.volmit.iris.engine.parallax.ParallaxChunkMeta; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.interpolation.InterpolationMethod; +import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.math.RNG; import lombok.Data; import org.bukkit.Axis; @@ -43,6 +44,8 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; +import java.util.function.Consumer; + @Data public class PlannedStructure { private KList pieces; @@ -80,24 +83,21 @@ public class PlannedStructure { } } - public KList place(IObjectPlacer placer, EngineParallaxManager e) { - KList after = new KList<>(); + public void place(IObjectPlacer placer, Mantle e, Consumer post) { IrisObjectPlacement options = new IrisObjectPlacement(); options.getRotation().setEnabled(false); int startHeight = pieces.get(0).getPosition().getY(); for (PlannedPiece i : pieces) { - if (i.getPiece().getPlaceMode().equals(ObjectPlaceMode.VACUUM)) { + if (i.getPiece().getPlacementOptions().usesFeatures()) { place(i, startHeight, options, placer, e); } else { - after.add(() -> place(i, startHeight, options, placer, e)); + post.accept(() -> place(i, startHeight, options, placer, e)); } } - - return after; } - public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, EngineParallaxManager e) { + public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e) { IrisObjectPlacement options = o; if (i.getPiece().getPlacementOptions() != null) { @@ -121,17 +121,8 @@ public class PlannedStructure { } int id = rng.i(0, Integer.MAX_VALUE); - - int h = vo.place(xx, height, zz, placer, options, rng, (b) -> { - int xf = b.getX(); - int yf = b.getY(); - int zf = b.getZ(); - e.getParallaxAccess().setObject(xf, yf, zf, v.getLoadKey() + "@" + id); - ParallaxChunkMeta meta = e.getParallaxAccess().getMetaRW(xf >> 4, zf >> 4); - meta.setObjects(true); - meta.setMinObject(Math.min(Math.max(meta.getMinObject(), 0), yf)); - meta.setMaxObject(Math.max(Math.max(meta.getMaxObject(), 0), yf)); - }, null, getData()); + int h = vo.place(xx, height, zz, placer, options, rng, (b) + -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData()); for (IrisJigsawPieceConnector j : i.getAvailableConnectors()) { @@ -149,13 +140,10 @@ public class PlannedStructure { } else { p.setY(height); } - for (int k = 0; k < j.getEntityCount(); k++) { - e.getParallaxAccess().setEntity(p.getX(), p.getY(), p.getZ(), j.getSpawnEntity()); - } } } - if (options.isVacuum()) { + if (options.usesFeatures()) { double a = Math.max(v.getW(), v.getD()); IrisFeature f = new IrisFeature(); f.setConvergeToHeight(h - (v.getH() >> 1) - 1); @@ -163,9 +151,7 @@ public class PlannedStructure { f.setInterpolationRadius(a / 4); f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9); f.setStrength(1D); - e.getParallaxAccess().getMetaRW(xx >> 4, zz >> 4) - .getFeatures() - .add(new IrisFeaturePositional(xx, zz, f)); + e.set(xx, 0, zz, new IrisFeaturePositional(xx, zz, f)); } }