mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 16:26:14 +00:00
Faster block data!
This commit is contained in:
@@ -18,6 +18,8 @@ public class BiomeDataProvider
|
||||
private InferredType type;
|
||||
private CNG generator;
|
||||
private GenLayerBiome layer;
|
||||
private double offx = 0;
|
||||
private double offz = 0;
|
||||
|
||||
public BiomeDataProvider(@NonNull GenLayerBiome layer, @NonNull InferredType type, @NonNull RNG rng)
|
||||
{
|
||||
@@ -31,16 +33,22 @@ public class BiomeDataProvider
|
||||
Iris.error("BIOME STYLE IS NULL FOR " + type);
|
||||
}
|
||||
|
||||
generator = b.create(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
|
||||
generator = b.create(rng.nextParallelRNG((layer.getIris().getDimension().isAggressiveBiomeReshuffle() ? (177 + type.ordinal() + rng.nextParallelRNG(229 - type.ordinal()).nextInt()) : 4645079) + (type.ordinal() * 23845)));
|
||||
|
||||
if(layer.getIris().getDimension().isAggressiveBiomeReshuffle())
|
||||
{
|
||||
offx += generator.fitDouble(-1000, 1000, 10000, -10000);
|
||||
offz += generator.fitDouble(-1000, 1000, -10000, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public IrisBiome generatePureData(ContextualTerrainProvider g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return layer.generateBiomeData(bx, bz, regionData, getGenerator(), regionData.getBiomes(g, getType()), getType(), rawX, rawZ, true);
|
||||
return layer.generateBiomeData(bx + offx, bz + offz, regionData, getGenerator(), regionData.getBiomes(g, getType()), getType(), (int) (rawX + offx), (int) (rawZ + offz), true);
|
||||
}
|
||||
|
||||
public IrisBiome generateData(ContextualTerrainProvider g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return layer.generateBiomeData(bx, bz, regionData, getGenerator(), regionData.getBiomes(g, getType()), getType(), rawX, rawZ, false);
|
||||
return layer.generateBiomeData(bx + offx, bz + offz, regionData, getGenerator(), regionData.getBiomes(g, getType()), getType(), (int) (rawX + offx), (int) (rawZ + offz), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ public class GenLayerBiome extends GenLayer
|
||||
this.iris = iris;
|
||||
riverRandom = iris.getMasterRandom().nextParallelRNG(-324778);
|
||||
lakeRandom = iris.getMasterRandom().nextParallelRNG(-868778);
|
||||
seaProvider = new BiomeDataProvider(this, InferredType.SEA, rng);
|
||||
landProvider = new BiomeDataProvider(this, InferredType.LAND, rng);
|
||||
shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, rng);
|
||||
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
|
||||
riverProvider = new BiomeDataProvider(this, InferredType.RIVER, rng);
|
||||
lakeProvider = new BiomeDataProvider(this, InferredType.LAKE, rng);
|
||||
regionGenerator = iris.getDimension().getRegionStyle().create(rng.nextParallelRNG(1188519)).bake().scale(1D / iris.getDimension().getRegionZoom());
|
||||
bridgeGenerator = iris.getDimension().getContinentalStyle().create(rng.nextParallelRNG(1541462)).bake().scale(1D / iris.getDimension().getContinentZoom());
|
||||
seaProvider = new BiomeDataProvider(this, InferredType.SEA, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG((int) (29866777 * iris.getDimension().getCoordFractureZoom())));
|
||||
landProvider = new BiomeDataProvider(this, InferredType.LAND, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG(-38356777 * iris.getMasterRandom().nextParallelRNG(2344).nextInt()));
|
||||
shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG(29899571 + iris.getMasterRandom().nextParallelRNG(-222344).nextInt()));
|
||||
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG(983564346 * -iris.getMasterRandom().nextParallelRNG(-44).nextInt()));
|
||||
riverProvider = new BiomeDataProvider(this, InferredType.RIVER, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG(-266717 - iris.getMasterRandom().nextParallelRNG(8100044).nextInt()));
|
||||
lakeProvider = new BiomeDataProvider(this, InferredType.LAKE, !iris.getDimension().isAggressiveBiomeReshuffle() ? rng : rng.nextParallelRNG((int) (-298356111 * iris.getTarget().getSeed())));
|
||||
regionGenerator = iris.getDimension().getRegionStyle().create(rng.nextParallelRNG(1188519 + (iris.getDimension().isAggressiveBiomeReshuffle() ? 329395 + (iris.getDimension().getName().hashCode()) : 0))).bake().scale(1D / iris.getDimension().getRegionZoom());
|
||||
bridgeGenerator = iris.getDimension().getContinentalStyle().create(rng.nextParallelRNG(1541462 + (iris.getDimension().isAggressiveBiomeReshuffle() ? 29355 * (iris.getDimension().getRegions().size()) : 0))).bake().scale(1D / iris.getDimension().getContinentZoom());
|
||||
}
|
||||
|
||||
public IrisRegion getRegion(double bx, double bz)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.volmit.iris.gen.layer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.gen.TopographicTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||
@@ -14,6 +13,7 @@ import com.volmit.iris.noise.FastNoiseDouble.NoiseType;
|
||||
import com.volmit.iris.object.IrisCaveLayer;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.CaveResult;
|
||||
import com.volmit.iris.util.FastBlockData;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
@@ -21,8 +21,8 @@ import com.volmit.iris.util.RNG;
|
||||
public class GenLayerCave extends GenLayer
|
||||
{
|
||||
public static boolean bad = false;
|
||||
public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
public static final FastBlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
|
||||
public static final FastBlockData AIR = B.getBlockData("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
private final FastNoiseDouble gg;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GenLayerCave extends GenLayer
|
||||
public void generateCave(KList<CaveResult> result, double wxx, double wzz, int x, int z, AtomicSliver data, IrisCaveLayer layer, int seed)
|
||||
{
|
||||
double scale = layer.getCaveZoom();
|
||||
Function<Integer, BlockData> fluid = (height) ->
|
||||
Function<Integer, FastBlockData> fluid = (height) ->
|
||||
{
|
||||
if(!layer.getFluid().hasFluid(iris.getData()))
|
||||
{
|
||||
@@ -161,15 +161,15 @@ public class GenLayerCave extends GenLayer
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dig(int x, int y, int z, AtomicSliver data, Function<Integer, BlockData> caveFluid)
|
||||
public boolean dig(int x, int y, int z, AtomicSliver data, Function<Integer, FastBlockData> caveFluid)
|
||||
{
|
||||
Material a = data.getTypeSafe(y);
|
||||
Material c = data.getTypeSafe(y + 1);
|
||||
Material d = data.getTypeSafe(y + 2);
|
||||
Material e = data.getTypeSafe(y + 3);
|
||||
Material f = data.getTypeSafe(y - 1);
|
||||
BlockData b = caveFluid.apply(y);
|
||||
BlockData b2 = caveFluid.apply(y + 1);
|
||||
FastBlockData b = caveFluid.apply(y);
|
||||
FastBlockData b2 = caveFluid.apply(y + 1);
|
||||
|
||||
if(can(a) && canAir(c, b) && canAir(f, b) && canWater(d) && canWater(e))
|
||||
{
|
||||
@@ -181,9 +181,9 @@ public class GenLayerCave extends GenLayer
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canAir(Material m, BlockData caveFluid)
|
||||
public boolean canAir(Material m, FastBlockData caveFluid)
|
||||
{
|
||||
return (B.isSolid(m) || (B.isDecorant(m)) || m.equals(Material.AIR) || m.equals(caveFluid.getMaterial()) || m.equals(B.mat("CAVE_AIR"))) && !m.equals(Material.BEDROCK);
|
||||
return (B.isSolid(m) || (B.isDecorant(FastBlockData.of(m))) || m.equals(Material.AIR) || m.equals(caveFluid.getMaterial()) || m.equals(B.mat("CAVE_AIR").getMaterial())) && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
public boolean canWater(Material m)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.volmit.iris.gen.layer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.gen.TopographicTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||
@@ -12,6 +11,7 @@ import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BiomeMap;
|
||||
import com.volmit.iris.util.BlockPosition;
|
||||
import com.volmit.iris.util.ChunkPosition;
|
||||
import com.volmit.iris.util.FastBlockData;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.HeightMap;
|
||||
import com.volmit.iris.util.MathHelper;
|
||||
@@ -24,8 +24,8 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GenLayerRavine extends GenLayer
|
||||
{
|
||||
private static final BlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
private static final BlockData LAVA = B.get("LAVA");
|
||||
private static final FastBlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||
private static final FastBlockData LAVA = B.get("LAVA");
|
||||
private CNG cng;
|
||||
|
||||
public GenLayerRavine(TopographicTerrainProvider iris, RNG rng)
|
||||
@@ -40,9 +40,9 @@ public class GenLayerRavine extends GenLayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void set(TerrainChunk pos, int x, int y, int z, BlockData b, HeightMap h, AtomicSliverMap map)
|
||||
private void set(TerrainChunk pos, int x, int y, int z, FastBlockData b, HeightMap h, AtomicSliverMap map)
|
||||
{
|
||||
pos.setBlock(x, y, z, b);
|
||||
pos.setBlock(x, y, z, b.getBlockData());
|
||||
map.getSliver(x, z).set(y, b);
|
||||
|
||||
if(h.getHeight(x, z) > y)
|
||||
@@ -51,12 +51,12 @@ public class GenLayerRavine extends GenLayer
|
||||
}
|
||||
}
|
||||
|
||||
private BlockData get(TerrainChunk pos, int x, int y, int z)
|
||||
private FastBlockData get(TerrainChunk pos, int x, int y, int z)
|
||||
{
|
||||
return pos.getBlockData(x, y, z);
|
||||
return FastBlockData.of(pos.getBlockData(x, y, z));
|
||||
}
|
||||
|
||||
private BlockData getSurfaceBlock(BiomeMap map, int n6, int i, RNG rmg)
|
||||
private FastBlockData getSurfaceBlock(BiomeMap map, int n6, int i, RNG rmg)
|
||||
{
|
||||
return map.getBiome(n6, i).getSurfaceBlock(n6, i, rmg, iris.getData());
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class GenLayerRavine extends GenLayer
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData bb = get(terrain, i, j, n6);
|
||||
FastBlockData bb = get(terrain, i, j, n6);
|
||||
|
||||
if(B.isWater(bb))
|
||||
{
|
||||
@@ -201,7 +201,7 @@ public class GenLayerRavine extends GenLayer
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData blockData = get(terrain, n6, j, i);
|
||||
FastBlockData blockData = get(terrain, n6, j, i);
|
||||
|
||||
if(isSurface(blockData))
|
||||
{
|
||||
@@ -243,7 +243,7 @@ public class GenLayerRavine extends GenLayer
|
||||
return bb;
|
||||
}
|
||||
|
||||
private boolean isDirt(BlockData d)
|
||||
private boolean isDirt(FastBlockData d)
|
||||
{
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
@@ -253,7 +253,7 @@ public class GenLayerRavine extends GenLayer
|
||||
//@done
|
||||
}
|
||||
|
||||
private boolean isSurface(BlockData d)
|
||||
private boolean isSurface(FastBlockData d)
|
||||
{
|
||||
//@builder
|
||||
Material m = d.getMaterial();
|
||||
|
||||
@@ -5,20 +5,19 @@ import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.TopographicTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.object.IrisMaterialPalette;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.FastBlockData;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GenLayerText extends GenLayer
|
||||
{
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
public static final FastBlockData AIR = B.getBlockData("AIR");
|
||||
|
||||
private final AtomicCache<IrisObject> debug = new AtomicCache<>();
|
||||
|
||||
@@ -29,11 +28,10 @@ public class GenLayerText extends GenLayer
|
||||
|
||||
public IrisObject getDebug()
|
||||
{
|
||||
return debug.aquire(() ->
|
||||
createTextObject("Test", "Impact", 24, B.get("STONE")));
|
||||
return debug.aquire(() -> createTextObject("Test", "Impact", 24, B.get("STONE")));
|
||||
}
|
||||
|
||||
public IrisObject createTextObject(String text, String font, int size, BlockData b)
|
||||
public IrisObject createTextObject(String text, String font, int size, FastBlockData b)
|
||||
{
|
||||
Font f = new Font(font, Font.PLAIN, size);
|
||||
int w = ((Graphics2D) new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).getGraphics()).getFontMetrics(f).stringWidth(text);
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
@@ -25,6 +24,7 @@ import com.volmit.iris.object.IrisLootTable;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.object.LootMode;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.FastBlockData;
|
||||
import com.volmit.iris.util.IrisStructureResult;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
@@ -62,7 +62,7 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
((IrisTerrainProvider) gen).spawnInitials(c, rx);
|
||||
p.end();
|
||||
@@ -129,14 +129,14 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
public void update(Chunk c, int x, int y, int z, int rx, int rz, RNG rng)
|
||||
{
|
||||
Block b = c.getBlock(x, y, z);
|
||||
BlockData d = b.getBlockData();
|
||||
FastBlockData d = FastBlockData.of(b.getBlockData());
|
||||
|
||||
if(B.isLit(d.getMaterial()))
|
||||
if(B.isLit(d))
|
||||
{
|
||||
updateLight(b, d);
|
||||
}
|
||||
|
||||
else if(B.isStorage(d.getMaterial()))
|
||||
else if(B.isStorage(d))
|
||||
{
|
||||
updateStorage(b, d, rx, rz, rng);
|
||||
}
|
||||
@@ -219,11 +219,11 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
scramble(inv, rng);
|
||||
}
|
||||
|
||||
public void updateStorage(Block b, BlockData data, int rx, int rz, RNG rng)
|
||||
public void updateStorage(Block b, FastBlockData data, int rx, int rz, RNG rng)
|
||||
{
|
||||
InventorySlotType slot = null;
|
||||
|
||||
if(B.isStorageChest(data.getMaterial()))
|
||||
if(B.isStorageChest(data))
|
||||
{
|
||||
slot = InventorySlotType.STORAGE;
|
||||
}
|
||||
@@ -307,9 +307,9 @@ public class GenLayerUpdate extends BlockPopulator
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLight(Block b, BlockData data)
|
||||
public void updateLight(Block b, FastBlockData data)
|
||||
{
|
||||
b.setType(Material.AIR, false);
|
||||
b.setBlockData(data, false);
|
||||
b.setBlockData(data.getBlockData(), false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user