mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Goto Object
This commit is contained in:
parent
6b8610b72d
commit
d9e18e0f3b
@ -49,7 +49,6 @@ public class IrisComplex implements DataProvider
|
|||||||
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
|
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
|
||||||
private ProceduralStream<BlockData> rockStream;
|
private ProceduralStream<BlockData> rockStream;
|
||||||
private ProceduralStream<BlockData> fluidStream;
|
private ProceduralStream<BlockData> fluidStream;
|
||||||
private ProceduralStream<BlockData> glassStream;
|
|
||||||
|
|
||||||
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type)
|
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type)
|
||||||
{
|
{
|
||||||
@ -76,14 +75,12 @@ public class IrisComplex implements DataProvider
|
|||||||
public IrisComplex(Engine engine)
|
public IrisComplex(Engine engine)
|
||||||
{
|
{
|
||||||
int cacheSize = 8192;
|
int cacheSize = 8192;
|
||||||
BlockData glass = B.get("GLASS");
|
|
||||||
this.rng = new RNG(engine.getWorld().getSeed());
|
this.rng = new RNG(engine.getWorld().getSeed());
|
||||||
this.data = engine.getData();
|
this.data = engine.getData();
|
||||||
double height = engine.getHeight();
|
double height = engine.getHeight();
|
||||||
fluidHeight = engine.getDimension().getFluidHeight();
|
fluidHeight = engine.getDimension().getFluidHeight();
|
||||||
generators = new KList<>();
|
generators = new KList<>();
|
||||||
RNG rng = new RNG(engine.getWorld().getSeed());
|
RNG rng = new RNG(engine.getWorld().getSeed());
|
||||||
glassStream = ProceduralStream.of((x,y,z) -> glass, Interpolated.BLOCK_DATA);
|
|
||||||
//@builder
|
//@builder
|
||||||
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
||||||
.getAllBiomes(this).forEach((b) -> b
|
.getAllBiomes(this).forEach((b) -> b
|
||||||
@ -145,9 +142,11 @@ public class IrisComplex implements DataProvider
|
|||||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||||
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
||||||
.convertAware2D(this::implode).cache2D(cacheSize);
|
.convertAware2D(this::implode).cache2D(cacheSize);
|
||||||
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, engine.getWorld().getSeed()))
|
heightStream = ProceduralStream.of((x, z) -> {
|
||||||
.roundDouble().cache2D(cacheSize);
|
IrisBiome b = baseBiomeStream.get(x, z);
|
||||||
slopeStream = heightStream.slope().cache2D(cacheSize);
|
return getHeight(b, x, z, engine.getWorld().getSeed());
|
||||||
|
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
||||||
|
slopeStream = heightStream.slope(4).interpolate().bilinear(4, 4).cache2D(cacheSize);
|
||||||
trueBiomeStream = heightStream
|
trueBiomeStream = heightStream
|
||||||
.convertAware2D((h, x, z) ->
|
.convertAware2D((h, x, z) ->
|
||||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||||
|
@ -95,10 +95,11 @@ public class IrisEngine extends BlockPopulator implements Engine
|
|||||||
() -> getFramework().getRavineModifier().modify(x, z, blocks)
|
() -> getFramework().getRavineModifier().modify(x, z, blocks)
|
||||||
);
|
);
|
||||||
MultiBurst.burst.burst(
|
MultiBurst.burst.burst(
|
||||||
() -> getFramework().getDecorantActuator().actuate(x, z, blocks),
|
|
||||||
() -> getFramework().getDepositModifier().modify(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().getEngineParallax().insertParallax(x, z, blocks);
|
||||||
getFramework().recycle();
|
getFramework().recycle();
|
||||||
|
@ -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 + "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 + "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 + "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)
|
if(Iris.jobCount() > 0)
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package com.volmit.iris.manager;
|
package com.volmit.iris.manager;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.volmit.iris.Iris;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import com.volmit.iris.manager.edit.DustRevealer;
|
import com.volmit.iris.manager.edit.DustRevealer;
|
||||||
import org.bukkit.Bukkit;
|
import com.volmit.iris.object.IrisObject;
|
||||||
import org.bukkit.Location;
|
import com.volmit.iris.util.*;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -23,12 +19,8 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import java.awt.Color;
|
||||||
import com.volmit.iris.object.IrisObject;
|
import java.util.Iterator;
|
||||||
import com.volmit.iris.util.C;
|
|
||||||
import com.volmit.iris.util.Cuboid;
|
|
||||||
import com.volmit.iris.util.KList;
|
|
||||||
import com.volmit.iris.util.M;
|
|
||||||
|
|
||||||
public class WandManager implements Listener
|
public class WandManager implements Listener
|
||||||
{
|
{
|
||||||
@ -182,7 +174,8 @@ public class WandManager implements Listener
|
|||||||
{
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.ENTITY_ENDER_EYE_DEATH, 2f, 1.97f);
|
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()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.volmit.iris.manager.command;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.manager.IrisDataManager;
|
import com.volmit.iris.manager.IrisDataManager;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
|
import com.volmit.iris.object.IrisObject;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
import com.volmit.iris.scaffold.IrisWorlds;
|
import com.volmit.iris.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.scaffold.engine.IrisAccess;
|
import com.volmit.iris.scaffold.engine.IrisAccess;
|
||||||
@ -16,7 +17,7 @@ public class CommandIrisStudioGoto extends MortarCommand
|
|||||||
public CommandIrisStudioGoto()
|
public CommandIrisStudioGoto()
|
||||||
{
|
{
|
||||||
super("goto", "find", "g", "tp");
|
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);
|
requiresPermission(Iris.perm.studio);
|
||||||
setCategory("World");
|
setCategory("World");
|
||||||
}
|
}
|
||||||
@ -26,6 +27,8 @@ public class CommandIrisStudioGoto extends MortarCommand
|
|||||||
if(args.length == 0 && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld()))
|
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().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);
|
IrisAccess g = IrisWorlds.access(world);
|
||||||
IrisBiome b = IrisDataManager.loadAnyBiome(args[0]);
|
IrisBiome b = IrisDataManager.loadAnyBiome(args[0]);
|
||||||
IrisRegion r = IrisDataManager.loadAnyRegion(args[0]);
|
IrisRegion r = IrisDataManager.loadAnyRegion(args[0]);
|
||||||
|
IrisObject o = IrisDataManager.loadAnyObject(args[0]);
|
||||||
|
|
||||||
if(b != null)
|
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
|
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;
|
return true;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.volmit.iris.manager.edit;
|
package com.volmit.iris.manager.edit;
|
||||||
|
|
||||||
import com.volmit.iris.util.BlockPosition;
|
import com.volmit.iris.util.*;
|
||||||
import com.volmit.iris.util.J;
|
|
||||||
import com.volmit.iris.util.KList;
|
|
||||||
import com.volmit.iris.util.RNG;
|
|
||||||
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
|
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
|
||||||
import com.volmit.iris.scaffold.parallax.ParallaxAccess;
|
import com.volmit.iris.scaffold.parallax.ParallaxAccess;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -18,7 +15,7 @@ public class DustRevealer {
|
|||||||
private final String key;
|
private final String key;
|
||||||
private final KList<BlockPosition> hits;
|
private final KList<BlockPosition> hits;
|
||||||
|
|
||||||
public static void spawn(Block block)
|
public static void spawn(Block block, MortarSender sender)
|
||||||
{
|
{
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
|
|
||||||
@ -28,6 +25,7 @@ public class DustRevealer {
|
|||||||
|
|
||||||
if(a.getObject(block.getX(), block.getY(), block.getZ()) != null)
|
if(a.getObject(block.getX(), block.getY(), block.getZ()) != null)
|
||||||
{
|
{
|
||||||
|
sender.sendMessage("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(a, world, new BlockPosition(block.getX(), block.getY(), block.getZ()), a.getObject(block.getX(), block.getY(), block.getZ()), new KList<>());
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@ public class IrisWorlds
|
|||||||
{
|
{
|
||||||
for(Player j : world.getPlayers())
|
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());
|
j.teleport(i.getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +134,19 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer
|
|||||||
generateStructures(rng, x>>4, z>>4, region, biome);
|
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)
|
default void generateStructures(RNG rng, int x, int z, IrisRegion region, IrisBiome biome)
|
||||||
{
|
{
|
||||||
int g = 30265;
|
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) {
|
default void generateParallaxSurface(RNG rng, int x, int z, IrisBiome biome) {
|
||||||
for (IrisObjectPlacement i : biome.getSurfaceObjects())
|
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) {
|
default void generateParallaxMutations(RNG rng, int x, int z) {
|
||||||
if(getEngine().getDimension().getMutations().isEmpty())
|
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)
|
default void place(RNG rng, int x, int z, IrisObjectPlacement objectPlacement)
|
||||||
{
|
{
|
||||||
place(rng, x,-1, z, 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)
|
default void place(RNG rng, int x, int forceY, int z, IrisObjectPlacement objectPlacement)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < objectPlacement.getDensity(); i++)
|
for(int i = 0; i < objectPlacement.getDensity(); i++)
|
||||||
|
@ -4,10 +4,11 @@ import com.volmit.iris.object.IrisObject;
|
|||||||
import com.volmit.iris.object.IrisRareObject;
|
import com.volmit.iris.object.IrisRareObject;
|
||||||
import com.volmit.iris.object.IrisStructurePlacement;
|
import com.volmit.iris.object.IrisStructurePlacement;
|
||||||
import com.volmit.iris.object.TileResult;
|
import com.volmit.iris.object.TileResult;
|
||||||
|
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
|
||||||
import com.volmit.iris.util.ChunkPosition;
|
import com.volmit.iris.util.ChunkPosition;
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
import com.volmit.iris.util.KSet;
|
import com.volmit.iris.util.KSet;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
import com.volmit.iris.scaffold.parallax.ParallaxChunkMeta;
|
|
||||||
|
|
||||||
public interface EngineStructureManager extends EngineComponent
|
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)
|
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))
|
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)
|
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)
|
if(structure.getChanceGenerator(new RNG(getEngine().getWorld().getSeed())).getIndex(x / structure.getZoom(), y / structure.getZoom(), z / structure.getZoom(), structure.getRarity()) == structure.getRarity() / 2)
|
||||||
|
@ -48,7 +48,7 @@ public interface GeneratorAccess extends DataProvider
|
|||||||
{
|
{
|
||||||
if(i.getPlace().contains(object))
|
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))
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.volmit.iris.scaffold.engine;
|
package com.volmit.iris.scaffold.engine;
|
||||||
|
|
||||||
import com.volmit.iris.manager.IrisDataManager;
|
import com.volmit.iris.manager.IrisDataManager;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.*;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
|
||||||
import com.volmit.iris.scaffold.data.DataProvider;
|
import com.volmit.iris.scaffold.data.DataProvider;
|
||||||
import com.volmit.iris.util.*;
|
import com.volmit.iris.util.*;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -48,6 +47,177 @@ 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);
|
||||||
@ -150,6 +320,11 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(engines.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
AtomicInteger tries = new AtomicInteger(0);
|
AtomicInteger tries = new AtomicInteger(0);
|
||||||
AtomicBoolean found = new AtomicBoolean(false);
|
AtomicBoolean found = new AtomicBoolean(false);
|
||||||
AtomicReference<Location> location = new AtomicReference<>();
|
AtomicReference<Location> location = new AtomicReference<>();
|
||||||
@ -169,7 +344,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
z = RNG.r.i(-29999970, 29999970);
|
z = RNG.r.i(-29999970, 29999970);
|
||||||
b = e.getRegion(x, z);
|
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);
|
found.lazySet(true);
|
||||||
location.lazySet(new Location(e.getWorld(), x, e.getHeight(x, z) + e.getMinHeight() ,z));
|
location.lazySet(new Location(e.getWorld(), x, e.getHeight(x, z) + e.getMinHeight() ,z));
|
||||||
|
@ -15,4 +15,6 @@ public class PlacedObject {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private IrisObject object;
|
private IrisObject object;
|
||||||
private int id;
|
private int id;
|
||||||
|
private int xx;
|
||||||
|
private int zz;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -416,7 +416,12 @@ public class B
|
|||||||
{
|
{
|
||||||
Material mm = m.getMaterial();
|
Material mm = m.getMaterial();
|
||||||
Boolean f = decorantCache.get(mm);
|
Boolean f = decorantCache.get(mm);
|
||||||
|
|
||||||
|
if(f != null)
|
||||||
|
{
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
f = mm.equals(Material.GRASS)
|
f = mm.equals(Material.GRASS)
|
||||||
|| mm.equals(Material.TALL_GRASS)
|
|| mm.equals(Material.TALL_GRASS)
|
||||||
|| mm.equals(B.getMaterial("CORNFLOWER"))
|
|| mm.equals(B.getMaterial("CORNFLOWER"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user