mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Remove object finding for now
This commit is contained in:
parent
675c7f8572
commit
6b77bba46d
@ -60,177 +60,6 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
public boolean isStudio();
|
public boolean isStudio();
|
||||||
|
|
||||||
public default Location lookForObject(IrisObject object, long timeout, Consumer<Integer> triesc)
|
|
||||||
{
|
|
||||||
ChronoLatch cl = new ChronoLatch(250, false);
|
|
||||||
long s = M.ms();
|
|
||||||
int cpus = 2+(Runtime.getRuntime().availableProcessors()/2);
|
|
||||||
KList<Engine> engines = new KList<>();
|
|
||||||
String key = object.getLoadKey();
|
|
||||||
|
|
||||||
looking: for(int i = 0; i < getCompound().getSize(); i++)
|
|
||||||
{
|
|
||||||
Engine e = getCompound().getEngine(i);
|
|
||||||
|
|
||||||
for(IrisBiome j : e.getDimension().getAllBiomes(e))
|
|
||||||
{
|
|
||||||
for(IrisObjectPlacement k : j.getObjects())
|
|
||||||
{
|
|
||||||
if(k.getPlace().contains(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IrisStructurePlacement k : j.getStructures())
|
|
||||||
{
|
|
||||||
for(IrisStructureTile l : k.getStructure(this).getTiles())
|
|
||||||
{
|
|
||||||
for(IrisRareObject m : l.getRareObjects())
|
|
||||||
{
|
|
||||||
if(m.getObject().equals(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l.getObjects().contains(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IrisRegion j : e.getDimension().getAllRegions(e))
|
|
||||||
{
|
|
||||||
for(IrisObjectPlacement k : j.getObjects())
|
|
||||||
{
|
|
||||||
if(k.getPlace().contains(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IrisStructurePlacement k : j.getStructures())
|
|
||||||
{
|
|
||||||
for(IrisStructureTile l : k.getStructure(this).getTiles())
|
|
||||||
{
|
|
||||||
for(IrisRareObject m : l.getRareObjects())
|
|
||||||
{
|
|
||||||
if(m.getObject().equals(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l.getObjects().contains(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(IrisBiomeMutation k : e.getDimension().getMutations())
|
|
||||||
{
|
|
||||||
for(IrisObjectPlacement l : k.getObjects())
|
|
||||||
{
|
|
||||||
if(l.getPlace().contains(key))
|
|
||||||
{
|
|
||||||
engines.add(e);
|
|
||||||
continue looking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(engines.isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicInteger tries = new AtomicInteger(0);
|
|
||||||
AtomicBoolean found = new AtomicBoolean(false);
|
|
||||||
AtomicReference<Location> location = new AtomicReference<>();
|
|
||||||
|
|
||||||
for(int i = 0; i < cpus; i++)
|
|
||||||
{
|
|
||||||
J.a(() -> {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Engine e;
|
|
||||||
IrisBiome b;
|
|
||||||
int x,y,z;
|
|
||||||
String sf;
|
|
||||||
|
|
||||||
while(!found.get())
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
synchronized (engines) {
|
|
||||||
e = engines.getRandom();
|
|
||||||
}
|
|
||||||
|
|
||||||
tries.getAndIncrement();
|
|
||||||
x = RNG.r.i(-29999970, 29999970);
|
|
||||||
y = RNG.r.i(0, e.getHeight()-1);
|
|
||||||
z = RNG.r.i(-29999970, 29999970);
|
|
||||||
KList<PlacedObject> p = e.getFramework().getEngineParallax().generateParallaxLayerObjects(Math.floorDiv(x, 16), Math.floorDiv(z, 16));
|
|
||||||
|
|
||||||
if(p == null || p.isEmpty())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(PlacedObject j : p)
|
|
||||||
{
|
|
||||||
if(j.getObject().getLoadKey().equals(object.getLoadKey()))
|
|
||||||
{
|
|
||||||
found.lazySet(true);
|
|
||||||
location.lazySet(new Location(e.getWorld(), j.getXx(), e.getMinHeight() + e.getHeight(j.getXx(), j.getZz()), j.getZz(), 0f, -90f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable ex)
|
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!found.get() || location.get() == null)
|
|
||||||
{
|
|
||||||
J.sleep(50);
|
|
||||||
|
|
||||||
if(cl.flip())
|
|
||||||
{
|
|
||||||
triesc.accept(tries.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(M.ms() - s > timeout)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return location.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc)
|
public default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc)
|
||||||
{
|
{
|
||||||
ChronoLatch cl = new ChronoLatch(250, false);
|
ChronoLatch cl = new ChronoLatch(250, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user