mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-18 22:30:12 +00:00
Idea Nitpick ""Optimizations""
This commit is contained in:
@@ -59,10 +59,7 @@ public class GenLayerBiome extends GenLayer
|
||||
return null;
|
||||
}
|
||||
|
||||
double x = bx;
|
||||
double z = bz;
|
||||
|
||||
return regionGenerator.fitRarity(iris.getDimension().getAllRegions(iris), x, z);
|
||||
return regionGenerator.fitRarity(iris.getDimension().getAllRegions(iris), bx, bz);
|
||||
}
|
||||
|
||||
public IrisBiome generateData(double bx, double bz, int rawX, int rawZ)
|
||||
@@ -127,8 +124,6 @@ public class GenLayerBiome extends GenLayer
|
||||
|
||||
public InferredType getType(double bx, double bz, IrisRegion region)
|
||||
{
|
||||
double x = bx;
|
||||
double z = bz;
|
||||
double c = iris.getDimension().getLandChance();
|
||||
InferredType bridge;
|
||||
|
||||
@@ -142,14 +137,14 @@ public class GenLayerBiome extends GenLayer
|
||||
bridge = InferredType.SEA;
|
||||
}
|
||||
|
||||
bridge = bridgeGenerator.fitDouble(0, 1, x, z) < c ? InferredType.LAND : InferredType.SEA;
|
||||
bridge = bridgeGenerator.fitDouble(0, 1, bx, bz) < c ? InferredType.LAND : InferredType.SEA;
|
||||
|
||||
if(bridge.equals(InferredType.LAND) && region.isLake(lakeRandom, x, z))
|
||||
if(bridge.equals(InferredType.LAND) && region.isLake(lakeRandom, bx, bz))
|
||||
{
|
||||
bridge = InferredType.LAKE;
|
||||
}
|
||||
|
||||
if(bridge.equals(InferredType.LAND) && region.isRiver(riverRandom, x, z))
|
||||
if(bridge.equals(InferredType.LAND) && region.isRiver(riverRandom, bx, bz))
|
||||
{
|
||||
bridge = InferredType.RIVER;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class GenLayerCarve extends GenLayer
|
||||
private static final KList<CarveResult> EMPTY_LIST = new KList<>();
|
||||
|
||||
@Getter
|
||||
private boolean couldCarve;
|
||||
private final boolean couldCarve;
|
||||
|
||||
@Getter
|
||||
private int minimum;
|
||||
@@ -37,12 +37,12 @@ public class GenLayerCarve extends GenLayer
|
||||
}
|
||||
}
|
||||
|
||||
public boolean couldCarve(int x, int y, int z)
|
||||
public boolean couldCarve(int y)
|
||||
{
|
||||
return couldCarve && y >= minimum && y <= maximum;
|
||||
}
|
||||
|
||||
public boolean couldCarveBelow(int x, int y, int z)
|
||||
public boolean couldCarveBelow(int y)
|
||||
{
|
||||
return couldCarve && y <= maximum;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class GenLayerCarve extends GenLayer
|
||||
|
||||
public int getSurfaceCarve(int x, int y, int z)
|
||||
{
|
||||
if(couldCarveBelow(x, y, z))
|
||||
if(couldCarveBelow(y))
|
||||
{
|
||||
int h = y;
|
||||
|
||||
@@ -111,17 +111,14 @@ public class GenLayerCarve extends GenLayer
|
||||
|
||||
public boolean isCarved(int xc, int y, int zc)
|
||||
{
|
||||
if(!couldCarve(xc, y, zc))
|
||||
if(!couldCarve(y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double x = ((double) xc);
|
||||
double z = ((double) zc);
|
||||
|
||||
for(IrisCarveLayer i : iris.getDimension().getCarveLayers())
|
||||
{
|
||||
if(i.isCarved(rng, x, y, z))
|
||||
if(i.isCarved(rng, xc, y, zc))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.function.Function;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||
import com.volmit.iris.gen.TopographicTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||
import com.volmit.iris.noise.FastNoiseDouble;
|
||||
@@ -25,7 +24,7 @@ public class GenLayerCave extends GenLayer
|
||||
public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
private FastNoiseDouble gg;
|
||||
private final FastNoiseDouble gg;
|
||||
|
||||
public GenLayerCave(TopographicTerrainProvider iris, RNG rng)
|
||||
{
|
||||
@@ -76,7 +75,7 @@ public class GenLayerCave extends GenLayer
|
||||
|
||||
return CAVE_AIR;
|
||||
};
|
||||
int surface = (int) Math.round(((IrisTerrainProvider) iris).getTerrainHeight((int) wxx, (int) wzz));
|
||||
int surface = (int) Math.round(iris.getTerrainHeight((int) wxx, (int) wzz));
|
||||
double wx = wxx + layer.getHorizontalSlope().get(rng, wxx, wzz);
|
||||
double wz = wzz + layer.getHorizontalSlope().get(rng, -wzz, -wxx);
|
||||
double baseWidth = (14 * scale);
|
||||
@@ -118,15 +117,15 @@ public class GenLayerCave extends GenLayer
|
||||
|
||||
if(data == null)
|
||||
{
|
||||
ceiling = pu > ceiling ? pu : ceiling;
|
||||
floor = pu < floor ? pu : floor;
|
||||
ceiling = pd > ceiling ? pd : ceiling;
|
||||
floor = pd < floor ? pd : floor;
|
||||
ceiling = Math.max(pu, ceiling);
|
||||
floor = Math.min(pu, floor);
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
ceiling = caveHeight > ceiling ? caveHeight : ceiling;
|
||||
floor = caveHeight < floor ? caveHeight : floor;
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
floor = Math.min(caveHeight, floor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,22 +133,22 @@ public class GenLayerCave extends GenLayer
|
||||
{
|
||||
if(dig(x, pu, z, data, fluid))
|
||||
{
|
||||
ceiling = pu > ceiling ? pu : ceiling;
|
||||
floor = pu < floor ? pu : floor;
|
||||
ceiling = Math.max(pu, ceiling);
|
||||
floor = Math.min(pu, floor);
|
||||
}
|
||||
|
||||
if(dig(x, pd, z, data, fluid))
|
||||
{
|
||||
ceiling = pd > ceiling ? pd : ceiling;
|
||||
floor = pd < floor ? pd : floor;
|
||||
ceiling = Math.max(pd, ceiling);
|
||||
floor = Math.min(pd, floor);
|
||||
}
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
if(dig(x, (int) (caveHeight), z, data, fluid))
|
||||
if(dig(x, caveHeight, z, data, fluid))
|
||||
{
|
||||
ceiling = caveHeight > ceiling ? caveHeight : ceiling;
|
||||
floor = caveHeight < floor ? caveHeight : floor;
|
||||
ceiling = Math.max(caveHeight, ceiling);
|
||||
floor = Math.min(caveHeight, floor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GenLayerRavine extends GenLayer
|
||||
return pos.getBlockData(x, y, z);
|
||||
}
|
||||
|
||||
private BlockData getSurfaceBlock(TerrainChunk pos, BiomeMap map, int n6, int i, RNG rmg)
|
||||
private BlockData getSurfaceBlock(BiomeMap map, int n6, int i, RNG rmg)
|
||||
{
|
||||
return map.getBiome(n6, i).getSurfaceBlock(n6, i, rmg, iris.getData());
|
||||
}
|
||||
@@ -93,15 +93,15 @@ public class GenLayerRavine extends GenLayer
|
||||
}
|
||||
while(n3 < n4)
|
||||
{
|
||||
double d7 = 1.5 + (double) (MathHelper.sin((float) ((float) n3 * 3.1415927f / (float) n4)) * f * 1.0f);
|
||||
double d7 = 1.5 + (double) (MathHelper.sin((float) n3 * 3.1415927f / (float) n4) * f * 1.0f);
|
||||
double d8 = d7 * d4;
|
||||
d7 *= (double) random.nextFloat() * 0.25 + 0.75;
|
||||
d8 *= (double) random.nextFloat() * 0.25 + 0.75;
|
||||
float f7 = MathHelper.cos((float) f3);
|
||||
float f8 = MathHelper.sin((float) f3);
|
||||
sx += (double) (MathHelper.cos((float) f2) * f7);
|
||||
sy += (double) f8;
|
||||
sz += (double) (MathHelper.sin((float) f2) * f7);
|
||||
float f7 = MathHelper.cos(f3);
|
||||
float f8 = MathHelper.sin(f3);
|
||||
sx = sx + (double) (MathHelper.cos(f2) * f7);
|
||||
sy += f8;
|
||||
sz += MathHelper.sin(f2) * f7;
|
||||
f3 *= 0.7f;
|
||||
f3 += f5 * 0.05f;
|
||||
f2 += f4 * 0.05f;
|
||||
@@ -122,12 +122,12 @@ public class GenLayerRavine extends GenLayer
|
||||
if(sx >= x - 16.0 - d7 * 2.0 && sz >= z - 16.0 - d7 * 2.0 && sx <= x + 16.0 + d7 * 2.0 && sz <= z + 16.0 + d7 * 2.0)
|
||||
{
|
||||
int n6;
|
||||
int n7 = MathHelper.floor((double) (sx - d7)) - tx * 16 - 1;
|
||||
int n8 = MathHelper.floor((double) (sx + d7)) - tx * 16 + 1;
|
||||
int n9 = MathHelper.floor((double) (sy - d8)) - 1;
|
||||
int n10 = MathHelper.floor((double) (sy + d8)) + 1;
|
||||
int n11 = MathHelper.floor((double) (sz - d7)) - tz * 16 - 1;
|
||||
int n12 = MathHelper.floor((double) (sz + d7)) - tz * 16 + 1;
|
||||
int n7 = MathHelper.floor(sx - d7) - tx * 16 - 1;
|
||||
int n8 = MathHelper.floor(sx + d7) - tx * 16 + 1;
|
||||
int n9 = MathHelper.floor(sy - d8) - 1;
|
||||
int n10 = MathHelper.floor(sy + d8) + 1;
|
||||
int n11 = MathHelper.floor(sz - d7) - tz * 16 - 1;
|
||||
int n12 = MathHelper.floor(sz + d7) - tz * 16 + 1;
|
||||
if(n7 < 0)
|
||||
{
|
||||
n7 = 0;
|
||||
@@ -221,7 +221,7 @@ public class GenLayerRavine extends GenLayer
|
||||
}
|
||||
|
||||
cSet(bps, n6 + tx * 16, 0, i + tz * 16);
|
||||
set(terrain, n6, j - 1, i, getSurfaceBlock(terrain, biomeMap, n6, i, rng), height, map);
|
||||
set(terrain, n6, j - 1, i, getSurfaceBlock(biomeMap, n6, i, rng), height, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class GenLayerText extends GenLayer
|
||||
{
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
|
||||
private AtomicCache<IrisObject> debug = new AtomicCache<>();
|
||||
private final AtomicCache<IrisObject> debug = new AtomicCache<>();
|
||||
|
||||
public GenLayerText(TopographicTerrainProvider iris, RNG rng)
|
||||
{
|
||||
@@ -30,9 +30,7 @@ public class GenLayerText extends GenLayer
|
||||
public IrisObject getDebug()
|
||||
{
|
||||
return debug.aquire(() ->
|
||||
{
|
||||
return createTextObject("Test", "Impact", 24, B.get("STONE"));
|
||||
});
|
||||
createTextObject("Test", "Impact", 24, B.get("STONE")));
|
||||
}
|
||||
|
||||
public IrisObject createTextObject(String text, String font, int size, BlockData b)
|
||||
|
||||
@@ -32,8 +32,8 @@ import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GenLayerUpdate extends BlockPopulator
|
||||
{
|
||||
private ParallaxTerrainProvider gen;
|
||||
private RNG rng;
|
||||
private final ParallaxTerrainProvider gen;
|
||||
private final RNG rng;
|
||||
|
||||
public GenLayerUpdate(ParallaxTerrainProvider gen)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
generateDepositsWithVanillaSaftey(w, rx, c);
|
||||
}
|
||||
|
||||
updateBlocks(w, rx, c, map);
|
||||
updateBlocks(rx, c, map);
|
||||
spawnInitials(c, rx);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
gen.getMetrics().getDeposits().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void updateBlocks(World w, RNG rx, Chunk c, AtomicSliverMap map)
|
||||
private void updateBlocks(RNG rx, Chunk c, AtomicSliverMap map)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
for(int i = 0; i < 16; i++)
|
||||
@@ -159,7 +159,7 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
IrisRegion region = gen.sampleRegion(rx, rz);
|
||||
IrisBiome biomeSurface = gen.sampleTrueBiome(rx, rz);
|
||||
IrisBiome biomeUnder = gen.sampleTrueBiome(rx, b.getY(), rz);
|
||||
KList<IrisLootTable> tables = new KList<IrisLootTable>();
|
||||
KList<IrisLootTable> tables = new KList<>();
|
||||
IrisStructureResult structure = gen.getStructure(rx, b.getY(), rz);
|
||||
double multiplier = 1D * gen.getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier();
|
||||
injectTables(tables, gen.getDimension().getLoot());
|
||||
@@ -238,7 +238,7 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
addItems(false, m.getInventory(), rng, tables, slot, rx, b.getY(), rz, 15);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
catch(Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user