mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Support place modes for objects on plax
This commit is contained in:
parent
518d10fc8f
commit
52f829f5d1
@ -5,17 +5,11 @@ import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.scaffold.engine.EngineParallaxManager;
|
||||
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
|
||||
import com.volmit.iris.util.IObjectPlacer;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.*;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Axis;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Data
|
||||
public class PlannedStructure {
|
||||
private KList<PlannedPiece> pieces;
|
||||
@ -47,47 +41,47 @@ public class PlannedStructure {
|
||||
generateTerminators();
|
||||
}
|
||||
|
||||
public void place(IObjectPlacer placer, EngineParallaxManager e)
|
||||
public KList<Runnable> place(IObjectPlacer placer, EngineParallaxManager e)
|
||||
{
|
||||
KList<Runnable> after = new KList<>();
|
||||
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().getPlaceMode().equals(ObjectPlaceMode.VACUUM) )
|
||||
{
|
||||
place(i, startHeight, options, placer, e);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
after.add(() -> place(i, startHeight, options, placer, e));
|
||||
}
|
||||
}
|
||||
|
||||
for(PlannedPiece i : pieces)
|
||||
{
|
||||
if(!i.getPiece().getPlaceMode().equals(ObjectPlaceMode.VACUUM))
|
||||
{
|
||||
place(i, startHeight, options, placer, e);
|
||||
}
|
||||
}
|
||||
return after;
|
||||
}
|
||||
|
||||
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement options, IObjectPlacer placer, EngineParallaxManager e)
|
||||
{
|
||||
IrisObject v = i.getObject();
|
||||
int xx = i.getPosition().getX();
|
||||
int zz = i.getPosition().getZ();
|
||||
int sx = (v.getW()/2);
|
||||
int sz = (v.getD()/2);
|
||||
int xx = i.getPosition().getX() + sx;
|
||||
int zz = i.getPosition().getZ() + sz;
|
||||
int offset = i.getPosition().getY() - startHeight;
|
||||
int height = placer.getHighest(xx, zz) + offset;
|
||||
int height = placer.getHighest(xx, zz) + offset + (v.getH() / 2);
|
||||
options.setMode(i.getPiece().getPlaceMode());
|
||||
|
||||
if(options.getMode().equals(ObjectPlaceMode.PAINT) || options.getMode().equals(ObjectPlaceMode.VACUUM))
|
||||
if(options.getMode().equals(ObjectPlaceMode.PAINT) || options.isVacuum())
|
||||
{
|
||||
height = -1;
|
||||
}
|
||||
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
int maxf = 10000;
|
||||
AtomicBoolean pl = new AtomicBoolean(false);
|
||||
AtomicInteger max = new AtomicInteger(-1);
|
||||
AtomicInteger min = new AtomicInteger(maxf);
|
||||
|
||||
int h = v.place(xx, height, zz, placer, options, rng, (b) -> {
|
||||
int xf = b.getX();
|
||||
int yf = b.getY();
|
||||
@ -97,21 +91,22 @@ public class PlannedStructure {
|
||||
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());
|
||||
|
||||
if(options.isVacuum())
|
||||
{
|
||||
int dx = xx;
|
||||
int dz = zz;
|
||||
double a = Math.max(v.getW(), v.getD());
|
||||
IrisFeature f = new IrisFeature();
|
||||
f.setConvergeToHeight(h-(v.getH() >> 1));
|
||||
f.setConvergeToHeight(h - (v.getH() >> 1)-1);
|
||||
f.setBlockRadius(a);
|
||||
f.setInterpolationRadius(a/4);
|
||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||
f.setStrength(1D);
|
||||
e.getParallaxAccess().getMetaRW(xx>>4, zz>>4)
|
||||
.getZones()
|
||||
.add(new IrisFeaturePositional(xx, zz, f));
|
||||
e.getParallaxAccess().getMetaRW(dx>>4, dz>>4)
|
||||
.getFeatures()
|
||||
.add(new IrisFeaturePositional(dx, dz, f));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user