mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +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.object.*;
|
||||||
import com.volmit.iris.scaffold.engine.EngineParallaxManager;
|
import com.volmit.iris.scaffold.engine.EngineParallaxManager;
|
||||||
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
|
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
|
||||||
import com.volmit.iris.util.IObjectPlacer;
|
import com.volmit.iris.util.*;
|
||||||
import com.volmit.iris.util.KList;
|
|
||||||
import com.volmit.iris.util.KMap;
|
|
||||||
import com.volmit.iris.util.RNG;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Axis;
|
import org.bukkit.Axis;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PlannedStructure {
|
public class PlannedStructure {
|
||||||
private KList<PlannedPiece> pieces;
|
private KList<PlannedPiece> pieces;
|
||||||
@ -47,47 +41,47 @@ public class PlannedStructure {
|
|||||||
generateTerminators();
|
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();
|
IrisObjectPlacement options = new IrisObjectPlacement();
|
||||||
|
options.getRotation().setEnabled(false);
|
||||||
int startHeight = pieces.get(0).getPosition().getY();
|
int startHeight = pieces.get(0).getPosition().getY();
|
||||||
|
|
||||||
for(PlannedPiece i : pieces)
|
for(PlannedPiece i : pieces)
|
||||||
{
|
{
|
||||||
if(i.getPiece().getPlaceMode().equals(ObjectPlaceMode.VACUUM))
|
if(i.getPiece().getPlaceMode().equals(ObjectPlaceMode.VACUUM) )
|
||||||
{
|
{
|
||||||
place(i, startHeight, options, placer, e);
|
place(i, startHeight, options, placer, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
after.add(() -> place(i, startHeight, options, placer, e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(PlannedPiece i : pieces)
|
return after;
|
||||||
{
|
|
||||||
if(!i.getPiece().getPlaceMode().equals(ObjectPlaceMode.VACUUM))
|
|
||||||
{
|
|
||||||
place(i, startHeight, options, placer, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement options, IObjectPlacer placer, EngineParallaxManager e)
|
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement options, IObjectPlacer placer, EngineParallaxManager e)
|
||||||
{
|
{
|
||||||
IrisObject v = i.getObject();
|
IrisObject v = i.getObject();
|
||||||
int xx = i.getPosition().getX();
|
int sx = (v.getW()/2);
|
||||||
int zz = i.getPosition().getZ();
|
int sz = (v.getD()/2);
|
||||||
|
int xx = i.getPosition().getX() + sx;
|
||||||
|
int zz = i.getPosition().getZ() + sz;
|
||||||
int offset = i.getPosition().getY() - startHeight;
|
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());
|
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;
|
height = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = rng.i(0, Integer.MAX_VALUE);
|
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 h = v.place(xx, height, zz, placer, options, rng, (b) -> {
|
||||||
int xf = b.getX();
|
int xf = b.getX();
|
||||||
int yf = b.getY();
|
int yf = b.getY();
|
||||||
@ -97,21 +91,22 @@ public class PlannedStructure {
|
|||||||
meta.setObjects(true);
|
meta.setObjects(true);
|
||||||
meta.setMinObject(Math.min(Math.max(meta.getMinObject(), 0), yf));
|
meta.setMinObject(Math.min(Math.max(meta.getMinObject(), 0), yf));
|
||||||
meta.setMaxObject(Math.max(Math.max(meta.getMaxObject(), 0), yf));
|
meta.setMaxObject(Math.max(Math.max(meta.getMaxObject(), 0), yf));
|
||||||
|
|
||||||
}, null, getData());
|
}, null, getData());
|
||||||
|
|
||||||
if(options.isVacuum())
|
if(options.isVacuum())
|
||||||
{
|
{
|
||||||
|
int dx = xx;
|
||||||
|
int dz = zz;
|
||||||
double a = Math.max(v.getW(), v.getD());
|
double a = Math.max(v.getW(), v.getD());
|
||||||
IrisFeature f = new IrisFeature();
|
IrisFeature f = new IrisFeature();
|
||||||
f.setConvergeToHeight(h-(v.getH() >> 1));
|
f.setConvergeToHeight(h - (v.getH() >> 1)-1);
|
||||||
f.setBlockRadius(a);
|
f.setBlockRadius(a);
|
||||||
f.setInterpolationRadius(a/4);
|
f.setInterpolationRadius(a/4);
|
||||||
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
f.setInterpolator(InterpolationMethod.BILINEAR_STARCAST_9);
|
||||||
f.setStrength(1D);
|
f.setStrength(1D);
|
||||||
e.getParallaxAccess().getMetaRW(xx>>4, zz>>4)
|
e.getParallaxAccess().getMetaRW(dx>>4, dz>>4)
|
||||||
.getZones()
|
.getFeatures()
|
||||||
.add(new IrisFeaturePositional(xx, zz, f));
|
.add(new IrisFeaturePositional(dx, dz, f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user