Revert "OK I'm really guessing at this point"

This reverts commit 0a85521028e1c3bbffd67cbd68fd7bce768eef06.
This commit is contained in:
CocoTheOwner 2021-09-21 20:17:31 +02:00
parent 16795871c3
commit 8070b211ab
3 changed files with 40 additions and 18 deletions

View File

@ -57,6 +57,10 @@ public class WandSVC implements IrisService {
private static ItemStack wand;
private static ItemStack dust;
public static void pasteSchematic(IrisObject s, Location at) {
s.place(at);
}
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*

View File

@ -71,6 +71,7 @@ import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class IrisObject extends IrisRegistrant {
@ -486,11 +487,23 @@ public class IrisObject extends IrisRegistrant {
}
}
public void place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, IrisData rdata) {
place(x, yv, z, placer, config, rng, null, null, rdata);
public int place(int x, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, IrisData rdata) {
return place(x, -1, z, placer, config, rng, rdata);
}
public void place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisData rdata) {
public int place(int x, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, CarveResult c, IrisData rdata) {
return place(x, -1, z, placer, config, rng, null, c, rdata);
}
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, IrisData rdata) {
return place(x, yv, z, placer, config, rng, null, null, rdata);
}
public int place(Location loc, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, IrisData rdata) {
return place(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), placer, config, rng, rdata);
}
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisData rdata) {
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
if (config.isSmartBore()) {
@ -606,25 +619,25 @@ public class IrisObject extends IrisRegistrant {
}
if (bail) {
return;
return -1;
}
if (yv < 0) {
if (!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z)) {
return;
return -1;
}
}
if (c != null && Math.max(0, h + yrand + ty) + 1 >= c.getHeight()) {
return;
return -1;
}
if (config.isUnderwater() && y + rty + ty >= placer.getFluidHeight()) {
return;
return -1;
}
if (!config.getClamp().canPlace(y + rty + ty, y - rty + ty)) {
return;
return -1;
}
if (config.isBore()) {
@ -852,12 +865,7 @@ public class IrisObject extends IrisRegistrant {
}
}
if (config.getRawCommands().isNotEmpty()) {
Location l = new Location(rdata.getEngine().getWorld().realWorld(), x, y, z);
for (IrisCommand rawCommand : config.getRawCommands()) {
rawCommand.run(l);
}
}
return y;
}
public IrisObject rotateCopy(IrisObjectRotation rt) {
@ -884,6 +892,20 @@ public class IrisObject extends IrisRegistrant {
states = dx;
}
public void place(Location at) {
for (BlockVector i : getBlocks().keySet()) {
Block b = at.clone().add(0, getCenter().getY(), 0).add(i).getBlock();
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
if (getStates().containsKey(i)) {
Iris.info(Objects.requireNonNull(states.get(i)).toString());
BlockState st = b.getState();
Objects.requireNonNull(getStates().get(i)).toBukkitTry(st);
st.update();
}
}
}
public void placeCenterY(Location at) {
for (BlockVector i : getBlocks().keySet()) {
Block b = at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock();

View File

@ -126,10 +126,6 @@ public class IrisObjectPlacement {
@Desc("This object / these objects override the following trees when they grow...")
@ArrayType(min = 1, type = IrisTree.class)
private KList<IrisTree> trees = new KList<>();
@Desc("Run raw commands at the location of this object")
@ArrayType(min = 1, type = IrisCommand.class)
private KList<IrisCommand> rawCommands = new KList<>();
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
public IrisObjectPlacement toPlacement(String... place) {