Goto Object

This commit is contained in:
Daniel Mills 2020-11-14 21:38:22 -05:00
parent 6b8610b72d
commit d9e18e0f3b
13 changed files with 406 additions and 40 deletions

View File

@ -49,7 +49,6 @@ public class IrisComplex implements DataProvider
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
private ProceduralStream<BlockData> rockStream;
private ProceduralStream<BlockData> fluidStream;
private ProceduralStream<BlockData> glassStream;
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type)
{
@ -76,14 +75,12 @@ public class IrisComplex implements DataProvider
public IrisComplex(Engine engine)
{
int cacheSize = 8192;
BlockData glass = B.get("GLASS");
this.rng = new RNG(engine.getWorld().getSeed());
this.data = engine.getData();
double height = engine.getHeight();
fluidHeight = engine.getDimension().getFluidHeight();
generators = new KList<>();
RNG rng = new RNG(engine.getWorld().getSeed());
glassStream = ProceduralStream.of((x,y,z) -> glass, Interpolated.BLOCK_DATA);
//@builder
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
.getAllBiomes(this).forEach((b) -> b
@ -145,9 +142,11 @@ public class IrisComplex implements DataProvider
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
.convertAware2D(this::implode).cache2D(cacheSize);
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, engine.getWorld().getSeed()))
.roundDouble().cache2D(cacheSize);
slopeStream = heightStream.slope().cache2D(cacheSize);
heightStream = ProceduralStream.of((x, z) -> {
IrisBiome b = baseBiomeStream.get(x, z);
return getHeight(b, x, z, engine.getWorld().getSeed());
}, Interpolated.DOUBLE).cache2D(cacheSize);
slopeStream = heightStream.slope(4).interpolate().bilinear(4, 4).cache2D(cacheSize);
trueBiomeStream = heightStream
.convertAware2D((h, x, z) ->
fixBiomeType(h, baseBiomeStream.get(x, z),

View File

@ -95,10 +95,11 @@ public class IrisEngine extends BlockPopulator implements Engine
() -> getFramework().getRavineModifier().modify(x, z, blocks)
);
MultiBurst.burst.burst(
() -> getFramework().getDecorantActuator().actuate(x, z, blocks),
() -> getFramework().getDepositModifier().modify(x, z, blocks),
() -> getFramework().getPostModifier().modify(x, z, blocks)
() -> getFramework().getPostModifier().modify(x, z, blocks),
() -> getFramework().getDecorantActuator().actuate(x, z, blocks)
);
;
getFramework().getEngineParallax().insertParallax(x, z, blocks);
getFramework().recycle();

View File

@ -121,6 +121,7 @@ public class IrisBoardManager implements BoardProvider, Listener
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName());
v.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2));
}
if(Iris.jobCount() > 0)

View File

@ -1,14 +1,10 @@
package com.volmit.iris.manager;
import java.awt.Color;
import java.util.Iterator;
import com.volmit.iris.Iris;
import com.volmit.iris.manager.edit.DustRevealer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import com.volmit.iris.object.IrisObject;
import com.volmit.iris.util.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -23,12 +19,8 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import com.volmit.iris.Iris;
import com.volmit.iris.object.IrisObject;
import com.volmit.iris.util.C;
import com.volmit.iris.util.Cuboid;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.M;
import java.awt.Color;
import java.util.Iterator;
public class WandManager implements Listener
{
@ -182,7 +174,8 @@ public class WandManager implements Listener
{
e.setCancelled(true);
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f);
DustRevealer.spawn(e.getClickedBlock());
DustRevealer.spawn(e.getClickedBlock(), new MortarSender(e.getPlayer(), Iris.instance.getTag()));
}
}
}

View File

@ -3,6 +3,7 @@ package com.volmit.iris.manager.command;
import com.volmit.iris.Iris;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisObject;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.IrisAccess;
@ -16,7 +17,7 @@ public class CommandIrisStudioGoto extends MortarCommand
public CommandIrisStudioGoto()
{
super("goto", "find", "g", "tp");
setDescription("Find any biome or a biome border");
setDescription("Find any region, biome or placed object");
requiresPermission(Iris.perm.studio);
setCategory("World");
}
@ -26,6 +27,8 @@ public class CommandIrisStudioGoto extends MortarCommand
if(args.length == 0 && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld()))
{
list.add(IrisWorlds.access(sender.player().getWorld()).getData().getBiomeLoader().getPossibleKeys());
list.add(IrisWorlds.access(sender.player().getWorld()).getData().getRegionLoader().getPossibleKeys());
list.add(IrisWorlds.access(sender.player().getWorld()).getData().getObjectLoader().getPossibleKeys());
}
}
@ -54,6 +57,7 @@ public class CommandIrisStudioGoto extends MortarCommand
IrisAccess g = IrisWorlds.access(world);
IrisBiome b = IrisDataManager.loadAnyBiome(args[0]);
IrisRegion r = IrisDataManager.loadAnyRegion(args[0]);
IrisObject o = IrisDataManager.loadAnyObject(args[0]);
if(b != null)
{
@ -91,9 +95,27 @@ public class CommandIrisStudioGoto extends MortarCommand
});
}
else if(o != null)
{
J.a(() -> {
Location l = g.lookForObject(o, 60000, (v) -> sender.sendMessage(C.BOLD +""+ C.WHITE + o.getLoadKey() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Objects"));
if(l == null)
{
sender.sendMessage("Couldn't find " + o.getLoadKey() + ".");
}
else
{
sender.sendMessage("Found " + o.getLoadKey() + "!");
J.s(() -> sender.player().teleport(l));
}
});
}
else
{
sender.sendMessage(args[0] + " is not a biome or region in this dimension.");
sender.sendMessage(args[0] + " is not a biome,region or object in this dimension.");
}
return true;

View File

@ -1,9 +1,6 @@
package com.volmit.iris.manager.edit;
import com.volmit.iris.util.BlockPosition;
import com.volmit.iris.util.J;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
import com.volmit.iris.util.*;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.scaffold.parallax.ParallaxAccess;
import lombok.Data;
@ -18,7 +15,7 @@ public class DustRevealer {
private final String key;
private final KList<BlockPosition> hits;
public static void spawn(Block block)
public static void spawn(Block block, MortarSender sender)
{
World world = block.getWorld();
@ -28,6 +25,7 @@ public class DustRevealer {
if(a.getObject(block.getX(), block.getY(), block.getZ()) != null)
{
sender.sendMessage("Found object " + a.getObject(block.getX(), block.getY(), block.getZ()));
J.a(() -> {
new DustRevealer(a, world, new BlockPosition(block.getX(), block.getY(), block.getZ()), a.getObject(block.getX(), block.getY(), block.getZ()), new KList<>());
});

View File

@ -49,7 +49,7 @@ public class IrisWorlds
{
for(Player j : world.getPlayers())
{
new MortarSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world due to a close request.");
new MortarSender(j, Iris.instance.getTag()).sendMessage("You have been evacuated from this world.");
j.teleport(i.getSpawnLocation());
}

View File

@ -134,6 +134,19 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
generateStructures(rng, x>>4, z>>4, region, biome);
}
default KList<PlacedObject> generateParallaxLayerObjects(int x, int z)
{
KList<PlacedObject> placedObjects = new KList<>();
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
IrisRegion region = getComplex().getRegionStream().get(x+8, z+8);
IrisBiome biome = getComplex().getTrueBiomeStream().get(x+8, z+8);
generateParallaxSurface(rng, x, z, biome, placedObjects);
generateParallaxMutations(rng, x, z, placedObjects);
generateStructures(rng, x>>4, z>>4, region, biome, placedObjects);
return placedObjects;
}
default void generateStructures(RNG rng, int x, int z, IrisRegion region, IrisBiome biome)
{
int g = 30265;
@ -158,6 +171,30 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
}
}
default void generateStructures(RNG rng, int x, int z, IrisRegion region, IrisBiome biome, KList<PlacedObject> objects)
{
int g = 30265;
for(IrisStructurePlacement k : region.getStructures())
{
if(k == null)
{
continue;
}
getStructureManager().placeStructure(k, rng.nextParallelRNG(2228 * 2 * g++), x, z, objects);
}
for(IrisStructurePlacement k : biome.getStructures())
{
if(k == null)
{
continue;
}
getStructureManager().placeStructure(k, rng.nextParallelRNG(-22228 * 4 * g++), x, z, objects);
}
}
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome) {
for (IrisObjectPlacement i : biome.getSurfaceObjects())
{
@ -168,6 +205,16 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
}
}
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome, KList<PlacedObject> objects) {
for (IrisObjectPlacement i : biome.getSurfaceObjects())
{
if(rng.chance(i.getChance()))
{
place(rng, x, z, i, objects);
}
}
}
default void generateParallaxMutations(RNG rng, int x, int z) {
if(getEngine().getDimension().getMutations().isEmpty())
{
@ -199,11 +246,59 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
}
}
default void generateParallaxMutations(RNG rng, int x, int z, KList<PlacedObject> o) {
if(getEngine().getDimension().getMutations().isEmpty())
{
return;
}
searching: for(IrisBiomeMutation k : getEngine().getDimension().getMutations())
{
for(int l = 0; l < k.getChecks(); l++)
{
IrisBiome sa = getComplex().getTrueBiomeStream().get(((x * 16) + rng.nextInt(16)) + rng.i(-k.getRadius(), k.getRadius()), ((z * 16) + rng.nextInt(16)) + rng.i(-k.getRadius(), k.getRadius()));
IrisBiome sb = getComplex().getTrueBiomeStream().get(((x * 16) + rng.nextInt(16)) + rng.i(-k.getRadius(), k.getRadius()), ((z * 16) + rng.nextInt(16)) + rng.i(-k.getRadius(), k.getRadius()));
if(sa.getLoadKey().equals(sb.getLoadKey()))
{
continue;
}
if(k.getRealSideA(this).contains(sa.getLoadKey()) && k.getRealSideB(this).contains(sb.getLoadKey()))
{
for(IrisObjectPlacement m : k.getObjects())
{
place(rng.nextParallelRNG((34 * ((x * 30) + (z * 30)) * x * z) + x - z + 1569962), x, z, m, o);
}
continue searching;
}
}
}
}
default void place(RNG rng, int x, int z, IrisObjectPlacement objectPlacement)
{
place(rng, x,-1, z, objectPlacement);
}
default void place(RNG rng, int x, int z, IrisObjectPlacement objectPlacement, KList<PlacedObject> objects)
{
place(rng, x,-1, z, objectPlacement, objects);
}
default void place(RNG rng, int x, int forceY, int z, IrisObjectPlacement objectPlacement, KList<PlacedObject> objects)
{
for(int i = 0; i < objectPlacement.getDensity(); i++)
{
IrisObject v = objectPlacement.getSchematic(getComplex(), rng);
int xx = rng.i(x, x+16);
int zz = rng.i(z, z+16);
int id = rng.i(0, Integer.MAX_VALUE);
objects.add(new PlacedObject(objectPlacement, v, id, xx, zz));
}
}
default void place(RNG rng, int x, int forceY, int z, IrisObjectPlacement objectPlacement)
{
for(int i = 0; i < objectPlacement.getDensity(); i++)

View File

@ -4,10 +4,11 @@ import com.volmit.iris.object.IrisObject;
import com.volmit.iris.object.IrisRareObject;
import com.volmit.iris.object.IrisStructurePlacement;
import com.volmit.iris.object.TileResult;
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
import com.volmit.iris.util.ChunkPosition;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KSet;
import com.volmit.iris.util.RNG;
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
public interface EngineStructureManager extends EngineComponent
{
@ -56,6 +57,51 @@ public interface EngineStructureManager extends EngineComponent
}
}
default void placeStructure(IrisStructurePlacement structure, RNG rngno, int cx, int cz, KList<PlacedObject> objects)
{
RNG rng = new RNG(getEngine().getWorld().getSeed()).nextParallelRNG(-88738456 + rngno.nextInt());
RNG rnp = rng.nextParallelRNG(cx - (cz * cz << 3) + rngno.nextInt());
int s = structure.gridSize(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0);
int sh = structure.gridHeight(getEngine()) - (structure.getStructure(getEngine()).isMergeEdges() ? 1 : 0);
KSet<ChunkPosition> m = new KSet<>();
for(int i = cx << 4; i <= (cx << 4) + 15; i += 1)
{
if(Math.floorDiv(i, s) * s >> 4 < cx)
{
continue;
}
for(int j = cz << 4; j <= (cz << 4) + 15; j += 1)
{
if(Math.floorDiv(j, s) * s >> 4 < cz)
{
continue;
}
ChunkPosition p = new ChunkPosition(Math.floorDiv(i, s) * s, Math.floorDiv(j, s) * s);
if(m.contains(p))
{
continue;
}
m.add(p);
if(structure.getStructure(getEngine()).getMaxLayers() <= 1)
{
placeLayer(structure, rng, rnp, i, 0, j, s, sh, objects);
continue;
}
for(int k = 0; k < s * structure.getStructure(getEngine()).getMaxLayers(); k += Math.max(sh, 1))
{
placeLayer(structure, rng, rnp, i, k, j, s, sh, objects);
}
}
}
}
default void placeLayer(IrisStructurePlacement structure, RNG rng, RNG rnp, int i, int k, int j, int s, int sh)
{
if(!hasStructure(structure, rng, i, k, j))
@ -102,6 +148,35 @@ public interface EngineStructureManager extends EngineComponent
}
}
default void placeLayer(IrisStructurePlacement structure, RNG rng, RNG rnp, int i, int k, int j, int s, int sh, KList<PlacedObject> objects)
{
if(!hasStructure(structure, rng, i, k, j))
{
return;
}
int h = (structure.getHeight() == -1 ? 0 : structure.getHeight()) + (Math.floorDiv(k, sh) * sh);
TileResult t = structure.getStructure(getEngine()).getTile(rng, Math.floorDiv(i, s) * s, h, Math.floorDiv(j, s) * s);
if(t != null)
{
IrisObject o = null;
for(IrisRareObject l : t.getTile().getRareObjects())
{
if(rnp.i(1, l.getRarity()) == 1)
{
o = structure.load(getEngine(), l.getObject());
break;
}
}
o = o != null ? o : structure.load(getEngine(), t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size())));
int id = rng.i(0, Integer.MAX_VALUE);
objects.add(new PlacedObject(null, o, id, Math.floorDiv(i, s) * s, Math.floorDiv(j, s) * s));
}
}
default boolean hasStructure(IrisStructurePlacement structure, RNG random, double x, double y, double z)
{
if(structure.getChanceGenerator(new RNG(getEngine().getWorld().getSeed())).getIndex(x / structure.getZoom(), y / structure.getZoom(), z / structure.getZoom(), structure.getRarity()) == structure.getRarity() / 2)

View File

@ -48,7 +48,7 @@ public interface GeneratorAccess extends DataProvider
{
if(i.getPlace().contains(object))
{
return new PlacedObject(i, getData().getObjectLoader().load(object), id);
return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z);
}
}
@ -58,10 +58,10 @@ public interface GeneratorAccess extends DataProvider
{
if(i.getPlace().contains(object))
{
return new PlacedObject(i, getData().getObjectLoader().load(object), id);
return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z);
}
}
return new PlacedObject(null, getData().getObjectLoader().load(object), id);
return new PlacedObject(null, getData().getObjectLoader().load(object), id, x, z);
}
}

View File

@ -1,8 +1,7 @@
package com.volmit.iris.scaffold.engine;
import com.volmit.iris.manager.IrisDataManager;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.object.*;
import com.volmit.iris.scaffold.data.DataProvider;
import com.volmit.iris.util.*;
import org.bukkit.Location;
@ -48,6 +47,177 @@ public interface IrisAccess extends Hotloadable, DataProvider {
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)
{
ChronoLatch cl = new ChronoLatch(250, false);
@ -150,6 +320,11 @@ public interface IrisAccess extends Hotloadable, DataProvider {
}
}
if(engines.isEmpty())
{
return null;
}
AtomicInteger tries = new AtomicInteger(0);
AtomicBoolean found = new AtomicBoolean(false);
AtomicReference<Location> location = new AtomicReference<>();
@ -169,7 +344,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
z = RNG.r.i(-29999970, 29999970);
b = e.getRegion(x, z);
if(b != null && b.getLoadKey().equals(reg.getLoadKey()))
if(b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey()))
{
found.lazySet(true);
location.lazySet(new Location(e.getWorld(), x, e.getHeight(x, z) + e.getMinHeight() ,z));

View File

@ -15,4 +15,6 @@ public class PlacedObject {
@Nullable
private IrisObject object;
private int id;
private int xx;
private int zz;
}

View File

@ -378,7 +378,7 @@ public class B
}
}
if(onto.equals(Material.AIR) || onto.equals(B.getMaterial("CAVE_AIR")))
if(onto.equals(Material.AIR) || onto.equals(B.getMaterial("CAVE_AIR")) || onto.equals(B.getMaterial("VOID_AIR")))
{
return false;
}
@ -416,7 +416,12 @@ public class B
{
Material mm = m.getMaterial();
Boolean f = decorantCache.get(mm);
if(f != null)
{
return f;
}
f = mm.equals(Material.GRASS)
|| mm.equals(Material.TALL_GRASS)
|| mm.equals(B.getMaterial("CORNFLOWER"))