9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 18:49:06 +00:00

Starcast is 60+% faster

This commit is contained in:
cyberpwn
2021-09-18 04:42:23 -04:00
parent 9caa89b733
commit a7aea8d1ed
17 changed files with 842 additions and 2044 deletions

View File

@@ -38,8 +38,7 @@ public class CommandFind implements DecreeExecutor {
) {
Engine e = engine();
if(e == null)
{
if (e == null) {
sender().sendMessage(C.GOLD + "Not in an Iris World!");
return;
}
@@ -54,8 +53,7 @@ public class CommandFind implements DecreeExecutor {
) {
Engine e = engine();
if(e == null)
{
if (e == null) {
sender().sendMessage(C.GOLD + "Not in an Iris World!");
return;
}
@@ -70,8 +68,7 @@ public class CommandFind implements DecreeExecutor {
) {
Engine e = engine();
if(e == null)
{
if (e == null) {
sender().sendMessage(C.GOLD + "Not in an Iris World!");
return;
}
@@ -86,8 +83,7 @@ public class CommandFind implements DecreeExecutor {
) {
Engine e = engine();
if(e == null)
{
if (e == null) {
sender().sendMessage(C.GOLD + "Not in an Iris World!");
return;
}

View File

@@ -34,7 +34,6 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
@@ -291,14 +290,12 @@ public class IrisComplex implements DataProvider {
return biome;
}
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet<IrisGenerator> generators, double x, double z, long seed)
{
if(generators.isEmpty())
{
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet<IrisGenerator> generators, double x, double z, long seed) {
if (generators.isEmpty()) {
return 0;
}
double hi = interpolator.interpolate(x, z, (xx,zz) -> {
double hi = interpolator.interpolate(x, z, (xx, zz) -> {
try {
IrisBiome bx = baseBiomeStream.get(xx, zz);
double b = 0;
@@ -317,7 +314,7 @@ public class IrisComplex implements DataProvider {
return 0;
});
double lo = interpolator.interpolate(x, z, (xx,zz) -> {
double lo = interpolator.interpolate(x, z, (xx, zz) -> {
try {
IrisBiome bx = baseBiomeStream.get(xx, zz);
double b = 0;
@@ -338,8 +335,7 @@ public class IrisComplex implements DataProvider {
double d = 0;
for(IrisGenerator i : generators)
{
for (IrisGenerator i : generators) {
d += M.lerp(lo, hi, i.getHeight(x, z, seed + 239945));
}

View File

@@ -199,7 +199,7 @@ public class IrisEngine implements Engine {
var bodies = new IrisBodyModifier(this);
var perfection = new IrisPerfectionModifier(this);
registerStage((x, z, k, p, m) -> warmupChunk(x>>4, z>>4));
registerStage((x, z, k, p, m) -> warmupChunk(x >> 4, z >> 4));
registerStage((x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m));
registerStage((x, z, k, p, m) -> terrain.actuate(x, z, k, m));
registerStage((x, z, k, p, m) -> biome.actuate(x, z, p, m));
@@ -228,14 +228,12 @@ public class IrisEngine implements Engine {
}
private void warmupChunk(int x, int z) {
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
{
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
int xx = x + (i << 4);
int zz = z + (z << 4);
getComplex().getTrueBiomeStream().get(xx,zz);
getComplex().getHeightStream().get(xx,zz);
getComplex().getTrueBiomeStream().get(xx, zz);
getComplex().getHeightStream().get(xx, zz);
}
}
}

View File

@@ -118,8 +118,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
if (getEngine().getWorld().hasRealWorld()) {
if(getEngine().getWorld().getPlayers().isEmpty())
{
if (getEngine().getWorld().getPlayers().isEmpty()) {
return 5000;
}
@@ -303,7 +302,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
IrisSpawner s = new KList<>(spawners).getRandom();
spawn(block, s, false);
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
() -> spawn(block, s, true)));
() -> spawn(block, s, true)));
});
if (v != null && v.getReferenceSpawner() != null) {
@@ -492,22 +491,19 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
Map<IrisPosition, KSet<IrisSpawner>> p = new KMap<>();
Set<IrisPosition> b = new KSet<>();
getMantle().iterateChunk(c.getX(), c.getZ(), MatterMarker.class, (x, y, z, t) -> {
if(t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling"))
{
if (t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling")) {
return;
}
IrisMarker mark = getData().getMarkerLoader().load(t.getTag());
IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z);
if(mark.isEmptyAbove())
{
if (mark.isEmptyAbove()) {
AtomicBoolean remove = new AtomicBoolean(false);
try {
J.sfut(() -> {
if(c.getBlock(x, y+1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y+2, z).getBlockData().getMaterial().isSolid())
{
if (c.getBlock(x, y + 1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y + 2, z).getBlockData().getMaterial().isSolid()) {
remove.set(true);
}
}).get();
@@ -515,8 +511,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
e.printStackTrace();
}
if(remove.get())
{
if (remove.get()) {
b.add(pos);
return;
}
@@ -534,8 +529,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
}
});
for(IrisPosition i : b)
{
for (IrisPosition i : b) {
getEngine().getMantle().getMantle().remove(i.getX(), i.getY(), i.getZ(), MatterMarker.class);
}
@@ -550,8 +544,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class);
if (marker != null) {
if(marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling"))
{
if (marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling")) {
return;
}

View File

@@ -78,14 +78,14 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
int finalI = i;
burst.queue(() -> {
int height;
int realX = (int) Math.round(x + finalI);
int realX = Math.round(x + finalI);
int realZ;
IrisBiome biome, cave;
for (int j = 0; j < output.getDepth(); j++) {
boolean solid;
int emptyFor = 0;
int lastSolid = 0;
realZ = (int) Math.round(z + j);
realZ = Math.round(z + j);
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ));
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null;
@@ -96,8 +96,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
if (height < getDimension().getFluidHeight()) {
getSeaSurfaceDecorator().decorate(finalI, j,
realX, (int) Math.round( + finalI + 1), (int) Math.round(x + finalI - 1),
realZ, (int) Math.round(z + j + 1), (int) Math.round(z + j - 1),
realX, Math.round(+finalI + 1), Math.round(x + finalI - 1),
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
getSeaFloorDecorator().decorate(finalI, j,
realX, realZ, output, biome, height + 1,
@@ -106,8 +106,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
if (height == getDimension().getFluidHeight()) {
getShoreLineDecorator().decorate(finalI, j,
realX, (int) Math.round(x + finalI + 1), (int) Math.round(x + finalI - 1),
realZ, (int) Math.round(z + j + 1), (int) Math.round(z + j - 1),
realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1),
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
output, biome, height, getEngine().getHeight());
}

View File

@@ -80,8 +80,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
IrisBiome biome;
for (zf = 0; zf < h.getDepth(); zf++) {
realX = (int) xf + x;
realZ = (int) zf + z;
realX = xf + x;
realZ = zf + z;
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));

View File

@@ -286,33 +286,19 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return;
}
boolean u = false;
if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData()))
{
if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) {
u = true;
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) {
u = true;
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) {
u = true;
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) {
u = true;
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) {
u = true;
}
else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData()))
{
u = true;
}
else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData()))
{
u = true;
}
else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData()))
{
u = true;
}
else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData()))
{
u = true;
}
if(u)
{
if (u) {
updates.compute(Cache.key(x & 15, z & 15), (k, vv) -> {
if (vv != null) {
return Math.max(vv, y);
@@ -785,8 +771,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
return getBiomeOrMantle(l.getBlockX(), l.getBlockY(), l.getBlockZ());
}
default void gotoBiome(IrisBiome biome, Player player)
{
default void gotoBiome(IrisBiome biome, Player player) {
Set<String> regionKeys = getDimension()
.getAllRegions(this).stream()
.filter((i) -> i.getAllBiomes(this).contains(biome))
@@ -794,31 +779,22 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
.collect(Collectors.toSet());
Locator<IrisBiome> lb = Locator.surfaceBiome(biome.getLoadKey());
Locator<IrisBiome> locator = (engine, chunk)
-> regionKeys.contains(getRegion((chunk.getX()<< 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())
-> regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())
&& lb.matches(engine, chunk);
if(!regionKeys.isEmpty())
{
if (!regionKeys.isEmpty()) {
locator.find(player);
}
else
{
} else {
player.sendMessage(C.RED + biome.getName() + " is not in any defined regions!");
}
}
default void gotoJigsaw(IrisJigsawStructure s, Player player)
{
if(getDimension().getJigsawStructures().stream()
default void gotoJigsaw(IrisJigsawStructure s, Player player) {
if (getDimension().getJigsawStructures().stream()
.map(IrisJigsawStructurePlacement::getStructure)
.collect(Collectors.toSet()).contains(s.getLoadKey()))
{
.collect(Collectors.toSet()).contains(s.getLoadKey())) {
Locator.jigsawStructure(s.getLoadKey()).find(player);
}
else
{
} else {
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
.filter((i) -> i.getJigsawStructures()
.stream()
@@ -835,33 +811,24 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
Locator<IrisJigsawStructure> sl = Locator.jigsawStructure(s.getLoadKey());
Locator<IrisBiome> locator = (engine, chunk) -> {
if(biomeKeys.contains(getSurfaceBiome((chunk.getX()<< 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()))
{
if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
return sl.matches(engine, chunk);
}
else if(regionKeys.contains(getRegion((chunk.getX()<< 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()))
{
} else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
return sl.matches(engine, chunk);
}
return false;
};
if(!regionKeys.isEmpty())
{
if (!regionKeys.isEmpty()) {
locator.find(player);
}
else
{
} else {
player.sendMessage(C.RED + s.getLoadKey() + " is not in any defined regions, biomes or dimensions!");
}
}
}
default void gotoObject(String s, Player player)
{
default void gotoObject(String s, Player player) {
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
.filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
.map(IrisRegistrant::getLoadKey)
@@ -874,34 +841,24 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
Locator<IrisObject> sl = Locator.object(s);
Locator<IrisBiome> locator = (engine, chunk) -> {
if(biomeKeys.contains(getSurfaceBiome((chunk.getX()<< 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()))
{
if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
return sl.matches(engine, chunk);
}
else if(regionKeys.contains(getRegion((chunk.getX()<< 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey()))
{
} else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
return sl.matches(engine, chunk);
}
return false;
};
if(!regionKeys.isEmpty())
{
if (!regionKeys.isEmpty()) {
locator.find(player);
}
else
{
} else {
player.sendMessage(C.RED + s + " is not in any defined regions or biomes!");
}
}
default void gotoRegion(IrisRegion r, Player player)
{
if(!getDimension().getAllRegions(this).contains(r))
{
default void gotoRegion(IrisRegion r, Player player) {
if (!getDimension().getAllRegions(this).contains(r)) {
player.sendMessage(C.RED + r.getName() + " is not defined in the dimension!");
return;
}

View File

@@ -50,30 +50,25 @@ import java.util.function.Consumer;
public interface Locator<T> {
boolean matches(Engine engine, Position2 chunk);
static void cancelSearch()
{
if(LocatorCanceller.cancel != null)
{
static void cancelSearch() {
if (LocatorCanceller.cancel != null) {
LocatorCanceller.cancel.run();
LocatorCanceller.cancel = null;
}
}
default void find(Player player)
{
default void find(Player player) {
find(player, 30_000);
}
default void find(Player player, long timeout)
{
default void find(Player player, long timeout) {
AtomicLong checks = new AtomicLong();
long ms = M.ms();
new SingleJob("Searching", () -> {
try {
Position2 at = find(IrisToolbelt.access(player.getWorld()).getEngine(), new Position2(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4), timeout, checks::set).get();
if(at != null)
{
if (at != null) {
J.s(() -> player.teleport(new Location(player.getWorld(), (at.getX() << 4) + 8,
IrisToolbelt.access(player.getWorld()).getEngine().getHeight(
(at.getX() << 4) + 8,
@@ -83,7 +78,7 @@ public interface Locator<T> {
} catch (WrongEngineBroException | InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}){
}) {
@Override
public String getName() {
return "Searched " + Form.f(checks.get()) + " Chunks";
@@ -96,14 +91,13 @@ public interface Locator<T> {
@Override
public int getWorkCompleted() {
return (int) Math.min(M.ms() - ms, timeout-1);
return (int) Math.min(M.ms() - ms, timeout - 1);
}
}.execute(new VolmitSender(player));
}
default Future<Position2> find(Engine engine, Position2 pos, long timeout, Consumer<Integer> checks) throws WrongEngineBroException {
if(engine.isClosed())
{
if (engine.isClosed()) {
throw new WrongEngineBroException();
}
@@ -123,19 +117,15 @@ public interface Locator<T> {
Spiraler s = new Spiraler(100000, 100000, (x, z) -> next.set(new Position2(x, z)));
s.setOffset(cursor.getX(), cursor.getZ());
s.next();
while(!found.get() && !stop.get() && px.getMilliseconds() < timeout)
{
while (!found.get() && !stop.get() && px.getMilliseconds() < timeout) {
BurstExecutor e = burst.burst(tc);
for(int i = 0; i < tc; i++)
{
for (int i = 0; i < tc; i++) {
Position2 p = next.get();
s.next();
e.queue(() -> {
if(matches(engine, p))
{
if(foundPos.get() == null)
{
if (matches(engine, p)) {
if (foundPos.get() == null) {
foundPos.set(p);
}
@@ -151,8 +141,7 @@ public interface Locator<T> {
LocatorCanceller.cancel = null;
if(found.get() && foundPos.get() != null)
{
if (found.get() && foundPos.get() != null) {
return foundPos.get();
}
@@ -160,47 +149,39 @@ public interface Locator<T> {
});
}
static Locator<IrisRegion> region(String loadKey)
{
static Locator<IrisRegion> region(String loadKey) {
return (e, c) -> e.getRegion((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisJigsawStructure> jigsawStructure(String loadKey)
{
static Locator<IrisJigsawStructure> jigsawStructure(String loadKey) {
return (e, c) -> {
IrisJigsawStructure s = e.getStructureAt(c.getX(), c.getZ());
return s != null && s.getLoadKey().equals(loadKey);
};
}
static Locator<IrisObject> object(String loadKey)
{
static Locator<IrisObject> object(String loadKey) {
return (e, c) -> e.getObjectsAt(c.getX(), c.getZ()).contains(loadKey);
}
static Locator<IrisBiome> surfaceBiome(String loadKey)
{
static Locator<IrisBiome> surfaceBiome(String loadKey) {
return (e, c) -> e.getSurfaceBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisBiome> caveBiome(String loadKey)
{
static Locator<IrisBiome> caveBiome(String loadKey) {
return (e, c) -> e.getCaveBiome((c.getX() << 4) + 8, (c.getZ() << 4) + 8).getLoadKey().equals(loadKey);
}
static Locator<IrisBiome> caveOrMantleBiome(String loadKey)
{
static Locator<IrisBiome> caveOrMantleBiome(String loadKey) {
return (e, c) -> {
AtomicBoolean found = new AtomicBoolean(false);
e.generateMatter(c.getX(), c.getZ(), true);
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x,y,z,t) ->{
if(found.get())
{
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> {
if (found.get()) {
return;
}
if(t != null && t.getCustomBiome().equals(loadKey))
{
if (t != null && t.getCustomBiome().equals(loadKey)) {
found.set(true);
}
});

View File

@@ -243,8 +243,7 @@ public class PlannedPiece {
@Override
public Engine getEngine() {
if(IrisToolbelt.isIrisWorld(world))
{
if (IrisToolbelt.isIrisWorld(world)) {
return IrisToolbelt.access(world).getEngine();
}

View File

@@ -260,5 +260,6 @@ public interface EngineMantle extends IObjectPlacer {
}
MantleJigsawComponent getJigsawComponent();
MantleObjectComponent getObjectComponent();
}

View File

@@ -113,8 +113,7 @@ public class IrisEntitySpawn implements IRare {
World world = gen.getWorld().realWorld();
if (spawns > 0) {
if(referenceMarker != null)
{
if (referenceMarker != null) {
gen.getMantle().getMantle().remove(c.getX(), c.getY(), c.getZ(), MatterMarker.class);
}
@@ -158,7 +157,7 @@ public class IrisEntitySpawn implements IRare {
return spawn100(g, at, false);
}
private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) {
private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) {
try {
IrisEntity irisEntity = getRealEntity(g);

View File

@@ -53,8 +53,7 @@ public class IrisMarker extends IrisRegistrant {
@Desc("If this marker is used, what is the chance it removes itself. For example 25% (0.25) would mean that on average 4 uses will remove a specific marker. Set this below 0 (-1) to never exhaust & set this to 1 or higher to always exhaust on first use.")
private double exhaustionChance = 0.33;
public boolean shouldExhaust()
{
public boolean shouldExhaust() {
return RNG.r.chance(exhaustionChance);
}

View File

@@ -658,32 +658,26 @@ public class IrisObject extends IrisRegistrant {
KMap<BlockVector, String> markers = null;
try {
if(config.getMarkers().isNotEmpty() && placer.getEngine() != null)
{
if (config.getMarkers().isNotEmpty() && placer.getEngine() != null) {
markers = new KMap<>();
for(IrisObjectMarker j : config.getMarkers())
{
for (IrisObjectMarker j : config.getMarkers()) {
IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker());
if(marker == null)
{
if (marker == null) {
continue;
}
int max = j.getMaximumMarkers();
for(BlockVector i : getBlocks().k().shuffle())
{
if(max <= 0)
{
for (BlockVector i : getBlocks().k().shuffle()) {
if (max <= 0) {
break;
}
BlockData data = getBlocks().get(i);
for (BlockData k : j.getMark(rdata)) {
if(max <= 0)
{
if (max <= 0) {
break;
}
@@ -691,8 +685,7 @@ public class IrisObject extends IrisRegistrant {
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
if((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove())
{
if ((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove()) {
markers.put(i, j.getMarker());
max--;
}
@@ -787,9 +780,8 @@ public class IrisObject extends IrisRegistrant {
listener.accept(new BlockPosition(xx, yy, zz));
}
if(markers != null && markers.containsKey(g))
{
placer.getEngine().getMantle().getMantle().set(xx,yy,zz,new MatterMarker(markers.get(g)));
if (markers != null && markers.containsKey(g)) {
placer.getEngine().getMantle().getMantle().set(xx, yy, zz, new MatterMarker(markers.get(g)));
}
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {

View File

@@ -82,7 +82,7 @@ public class IrisObjectPlacement {
@MinNumber(0)
@Desc("When bore is enabled, expand max-y of the cuboid it removes")
private int boreExtendMaxY = 0;
@ArrayType(min = 1,type = IrisObjectMarker.class)
@ArrayType(min = 1, type = IrisObjectMarker.class)
@Desc("Add markers to blocks in this object")
private KList<IrisObjectMarker> markers = new KList<>();
@MaxNumber(64)

View File

@@ -19,17 +19,14 @@
package com.volmit.iris.util.interpolation;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.Consumer2;
import com.volmit.iris.util.function.Function2;
import com.volmit.iris.util.function.NoiseProvider;
import com.volmit.iris.util.function.NoiseProvider3;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.noise.SimplexNoise;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.math.BigDecimal;
@@ -307,12 +304,10 @@ public class IrisInterpolation {
//@done
}
public static void test(String m, Consumer2<Integer, Integer> f)
{
public static void test(String m, Consumer2<Integer, Integer> f) {
PrecisionStopwatch p = PrecisionStopwatch.start();
for(int i = 0; i < 8192; i++)
{
for (int i = 0; i < 8192; i++) {
f.accept(i, -i * 234);
}
@@ -322,46 +317,59 @@ public class IrisInterpolation {
}
public static void main(String[] args) {
CNG cng = new CNG(new RNG());
NoiseProvider n = cng::noise;
System.out.println(generateOptimizedStarcast(3));
System.out.println(generateOptimizedStarcast(5));
System.out.println(generateOptimizedStarcast(6));
System.out.println(generateOptimizedStarcast(7));
System.out.println(generateOptimizedStarcast(9));
System.out.println(generateOptimizedStarcast(12));
System.out.println(generateOptimizedStarcast(24));
System.out.println(generateOptimizedStarcast(32));
System.out.println(generateOptimizedStarcast(48));
System.out.println(generateOptimizedStarcast(64));
System.out.println(generateOptimizedStarcast(72));
System.out.println(generateOptimizedStarcast(96));
System.out.println(generateOptimizedStarcast(128));
System.out.println(generateOptimizedStarcast(186));
System.out.println(generateOptimizedStarcast(256));
printOptimizedSrc(false);
}
public static String generateOptimizedStarcast(double checks) {
public static void printOptimizedSrc(boolean arrays) {
System.out.println(generateOptimizedStarcast(3, arrays));
System.out.println(generateOptimizedStarcast(5, arrays));
System.out.println(generateOptimizedStarcast(6, arrays));
System.out.println(generateOptimizedStarcast(7, arrays));
System.out.println(generateOptimizedStarcast(9, arrays));
System.out.println(generateOptimizedStarcast(12, arrays));
System.out.println(generateOptimizedStarcast(24, arrays));
System.out.println(generateOptimizedStarcast(32, arrays));
System.out.println(generateOptimizedStarcast(48, arrays));
System.out.println(generateOptimizedStarcast(64, arrays));
}
public static String generateOptimizedStarcast(double checks, boolean array) {
double m = (360 / checks);
int ig = 0;
int igx = 0;
StringBuilder fb = new StringBuilder();
StringBuilder sb = new StringBuilder();
fb.append("private static final double[] F"+(int)checks+"A = {");
sb.append("private static double sc"+(int)checks+"(int x, int z, double r, NoiseProvider n) {\n return (");
if (array) {
fb.append("private static final double[] F" + (int) checks + "A = {");
}
sb.append("private static double sc" + (int) checks + "(int x, int z, double r, NoiseProvider n) {\n return (");
for (int i = 0; i < 360; i += m) {
double sin = Math.sin(Math.toRadians(i));
double cos = Math.cos(Math.toRadians(i));
String cof = new BigDecimal(cos).toPlainString();
String sif = new BigDecimal(sin).toPlainString();
String cc = "F"+(int)checks+"A["+(igx++)+"]";
String ss = "F"+(int)checks+"A["+(igx++)+"]";
fb.append((ig > 0 ? (ig % 3 == 0 ? ",\n" : ",") : "") + cof + "," + sif);
sb.append( (ig > 0 ? "\n +" : "") + "n.noise(x + ((r * "+ cc +") - (r * "+ss+")), z + ((r * "+ss+") + (r * "+cc+")))");
String cc = array ? "F" + (int) checks + "A[" + (igx++) + "]" : "F" + (int) checks + "C" + ig;
String ss = array ? "F" + (int) checks + "A[" + (igx++) + "]" : "F" + (int) checks + "S" + ig;
if (array) {
fb.append((ig > 0 ? (ig % 6 == 0 ? ",\n" : ",") : "") + cof + "," + sif);
} else {
fb.append("private static final double " + cc + " = " + cof + ";\n");
fb.append("private static final double " + ss + " = " + sif + ";\n");
}
sb.append((ig > 0 ? "\n +" : "") + "n.noise(x + ((r * " + cc + ") - (r * " + ss + ")), z + ((r * " + ss + ") + (r * " + cc + ")))");
ig++;
}
fb.append("};");
sb.append(")/"+checks+"D;\n}");
if (array) {
fb.append("};");
}
sb.append(")/" + checks + "D;\n}");
return fb + "\n" + sb;
}

File diff suppressed because it is too large Load Diff

View File

@@ -60,8 +60,7 @@ public class Spiral implements Iterable<Position2> {
return p;
}
public static Spiral from(Position2 p, long iterations)
{
public static Spiral from(Position2 p, long iterations) {
return new Spiral(p, iterations);
}