This commit is contained in:
Daniel Mills 2021-08-09 09:59:12 -04:00
parent 831143427d
commit 059ff25d8e
2 changed files with 24 additions and 11 deletions

View File

@ -21,7 +21,9 @@ package com.volmit.iris.core.edit;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.parallax.ParallaxAccess; import com.volmit.iris.engine.framework.PlacedObject;
import com.volmit.iris.engine.mantle.EngineMantle;
import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.BlockPosition; import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@ -34,7 +36,7 @@ import org.bukkit.block.Block;
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
@Data @Data
public class DustRevealer { public class DustRevealer {
private final ParallaxAccess parallax; private final Engine engine;
private final World world; private final World world;
private final BlockPosition block; private final BlockPosition block;
private final String key; private final String key;
@ -45,20 +47,19 @@ public class DustRevealer {
Engine access = IrisToolbelt.access(world).getEngine(); Engine access = IrisToolbelt.access(world).getEngine();
if (access != null) { if (access != null) {
ParallaxAccess a = access.getParallaxAccess(); String a = access.getObjectPlacementKey(block.getX(), block.getY(), block.getZ());
if (a.getObject(block.getX(), block.getY(), block.getZ()) != null) { if (a != null) {
sender.sendMessage("Found object " + a.getObject(block.getX(), block.getY(), block.getZ())); sender.sendMessage("Found object " + a);
Iris.info(sender.getName() + " found object " + a.getObject(block.getX(), block.getY(), block.getZ()));
J.a(() -> { J.a(() -> {
new DustRevealer(a, world, new BlockPosition(block.getX(), block.getY(), block.getZ()), a.getObject(block.getX(), block.getY(), block.getZ()), new KList<>()); new DustRevealer(access, world, new BlockPosition(block.getX(), block.getY(), block.getZ()), a, new KList<>());
}); });
} }
} }
} }
public DustRevealer(ParallaxAccess parallax, World world, BlockPosition block, String key, KList<BlockPosition> hits) { public DustRevealer(Engine engine, World world, BlockPosition block, String key, KList<BlockPosition> hits) {
this.parallax = parallax; this.engine = engine;
this.world = world; this.world = world;
this.block = block; this.block = block;
this.key = key; this.key = key;
@ -103,9 +104,9 @@ public class DustRevealer {
} }
private boolean is(BlockPosition a) { private boolean is(BlockPosition a) {
if (isValidTry(a) && parallax.getObject(a.getX(), a.getY(), a.getZ()) != null && parallax.getObject(a.getX(), a.getY(), a.getZ()).equals(key)) { if (isValidTry(a) && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()) != null && engine.getObjectPlacementKey(a.getX(), a.getY(), a.getZ()).equals(key)) {
hits.add(a); hits.add(a);
new DustRevealer(parallax, world, a, key, hits); new DustRevealer(engine, world, a, key, hits);
return true; return true;
} }

View File

@ -633,6 +633,18 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return getSurfaceBiome(x, z); return getSurfaceBiome(x, z);
} }
default String getObjectPlacementKey(int x, int y, int z)
{
PlacedObject o = getObjectPlacement(x,y,z);
if(o != null && o.getObject() != null)
{
return o.getObject().getLoadKey() + "@" + o.getId();
}
return null;
}
default PlacedObject getObjectPlacement(int x, int y, int z) { default PlacedObject getObjectPlacement(int x, int y, int z) {
String objectAt = getMantle().getMantle().get(x,y,z, String.class); String objectAt = getMantle().getMantle().get(x,y,z, String.class);