mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
lol dual universe
This commit is contained in:
parent
ae5d0b282c
commit
30dc6e865f
@ -31,7 +31,6 @@ import org.bukkit.util.Vector;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisChunkGenerator;
|
||||
import ninja.bytecode.iris.legacy.GenObject;
|
||||
import ninja.bytecode.iris.object.IrisBiome;
|
||||
import ninja.bytecode.iris.object.IrisDimension;
|
||||
import ninja.bytecode.iris.object.IrisObject;
|
||||
@ -53,8 +52,6 @@ import ninja.bytecode.iris.wand.WandController;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
import ninja.bytecode.shuriken.collections.KMap;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
||||
import ninja.bytecode.shuriken.format.Form;
|
||||
import ninja.bytecode.shuriken.json.JSONException;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
@ -219,52 +216,6 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
|
||||
if(args.length >= 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("convert") && args.length == 1)
|
||||
{
|
||||
File folder = new File(getDataFolder(), "convert");
|
||||
|
||||
if(folder.exists() && folder.isDirectory())
|
||||
{
|
||||
KList<File> objects = new KList<>();
|
||||
lookForObjects(folder, objects);
|
||||
TaskExecutor tx = new TaskExecutor(32, Thread.MIN_PRIORITY, "Iris Converter");
|
||||
TaskGroup g = tx.startWork();
|
||||
info("Converting " + Form.f(objects.size()) + " Objects");
|
||||
O<Integer> max = new O<Integer>().set(objects.size());
|
||||
O<Integer> at = new O<Integer>().set(0);
|
||||
for(File i : objects)
|
||||
{
|
||||
g.queue(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
IrisObject o = GenObject.loadAsModern(i);
|
||||
File ff = new File(i.getParentFile(), o.getLoadKey() + ".iob");
|
||||
|
||||
o.write(new File(i.getParentFile(), o.getLoadKey() + ".iob"));
|
||||
|
||||
Iris.info("Converting [" + at.get() + " of " + max.get() + "]: " + i.getName() + " to " + ff.getName());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
error("Failed to convert " + i.getName());
|
||||
}
|
||||
|
||||
i.delete();
|
||||
at.set(at.get() + 1);
|
||||
});
|
||||
}
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
g.execute();
|
||||
Iris.info("Done!");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("goto") && args.length == 2)
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
@ -567,7 +518,6 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
imsg(sender, "/iris wand l1 - Set wand pos 1 where looking");
|
||||
imsg(sender, "/iris wand l2 - Set wand pos 2 where looking");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("save") && args.length >= 2)
|
||||
@ -578,6 +528,7 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
{
|
||||
o.write(new File(getDataFolder(), "objects/" + args[1] + ".iob"));
|
||||
imsg(sender, "Saved " + "objects/" + args[1] + ".iob");
|
||||
((Player) sender).getWorld().playSound(((Player) sender).getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
@ -613,6 +564,8 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
{
|
||||
o.read(new File(getDataFolder(), "objects/" + args[1] + ".iob"));
|
||||
imsg(sender, "Loaded " + "objects/" + args[1] + ".iob");
|
||||
|
||||
((Player) sender).getWorld().playSound(((Player) sender).getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
Location block = ((Player) sender).getTargetBlock((Set<Material>) null, 256).getLocation().clone().add(0, 1, 0);
|
||||
|
||||
if(intoWand && WandController.isWand(wand))
|
||||
@ -716,25 +669,6 @@ public class Iris extends JavaPlugin implements BoardProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
private void lookForObjects(File folder, KList<File> objects)
|
||||
{
|
||||
if(folder.isDirectory())
|
||||
{
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
if(i.isDirectory())
|
||||
{
|
||||
lookForObjects(i, objects);
|
||||
}
|
||||
|
||||
if(i.getName().endsWith(".ish"))
|
||||
{
|
||||
objects.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void imsg(CommandSender s, String msg)
|
||||
{
|
||||
s.sendMessage(ChatColor.GREEN + "[" + ChatColor.DARK_GRAY + "Iris" + ChatColor.GREEN + "]" + ChatColor.GRAY + ": " + msg);
|
||||
|
@ -11,6 +11,7 @@ import ninja.bytecode.iris.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.object.InferredType;
|
||||
import ninja.bytecode.iris.object.IrisBiome;
|
||||
import ninja.bytecode.iris.object.IrisBiomeGeneratorLink;
|
||||
import ninja.bytecode.iris.object.IrisDimension;
|
||||
import ninja.bytecode.iris.object.IrisGenerator;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
@ -28,18 +29,22 @@ import ninja.bytecode.shuriken.math.M;
|
||||
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
{
|
||||
protected ReentrantLock regLock;
|
||||
protected KMap<String, IrisGenerator> generators;
|
||||
private KMap<String, IrisGenerator> generators;
|
||||
private KMap<String, IrisGenerator> ceilingGenerators;
|
||||
protected GenLayerBiome glBiome;
|
||||
protected CNG masterFracture;
|
||||
protected KMap<ChunkPosition, BiomeResult> biomeHitCache;
|
||||
private KMap<ChunkPosition, BiomeResult> biomeHitCache;
|
||||
private KMap<ChunkPosition, BiomeResult> ceilingBiomeHitCache;
|
||||
protected ChronoLatch cwarn = new ChronoLatch(1000);
|
||||
|
||||
public BiomeChunkGenerator(String dimensionName)
|
||||
{
|
||||
super(dimensionName);
|
||||
generators = new KMap<>();
|
||||
ceilingGenerators = new KMap<>();
|
||||
regLock = new ReentrantLock();
|
||||
biomeHitCache = new KMap<>();
|
||||
ceilingBiomeHitCache = new KMap<>();
|
||||
}
|
||||
|
||||
public void onInit(World world, RNG rng)
|
||||
@ -49,15 +54,24 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
|
||||
}
|
||||
|
||||
public KMap<ChunkPosition, BiomeResult> getBiomeHitCache()
|
||||
{
|
||||
return getDimension().isInverted() ? ceilingBiomeHitCache : biomeHitCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHotloaded()
|
||||
{
|
||||
super.onHotloaded();
|
||||
biomeHitCache = new KMap<>();
|
||||
generators.clear();
|
||||
ceilingBiomeHitCache = new KMap<>();
|
||||
loadGenerators();
|
||||
}
|
||||
|
||||
public void registerGenerator(IrisGenerator g)
|
||||
public void registerGenerator(IrisGenerator g, IrisDimension dim)
|
||||
{
|
||||
KMap<String, IrisGenerator> generators = dim.isInverted() ? ceilingGenerators : this.generators;
|
||||
|
||||
regLock.lock();
|
||||
if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey()))
|
||||
{
|
||||
@ -69,11 +83,16 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
generators.put(g.getLoadKey(), g);
|
||||
}
|
||||
|
||||
protected KMap<String, IrisGenerator> getGenerators()
|
||||
{
|
||||
return getDimension().isInverted() ? ceilingGenerators : generators;
|
||||
}
|
||||
|
||||
protected double getBiomeHeight(double rx, double rz)
|
||||
{
|
||||
double h = 0;
|
||||
|
||||
for(IrisGenerator i : generators.values())
|
||||
for(IrisGenerator i : getGenerators().values())
|
||||
{
|
||||
h += interpolateGenerator(rx, rz, i);
|
||||
}
|
||||
@ -118,10 +137,23 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
|
||||
protected void loadGenerators()
|
||||
{
|
||||
generators.clear();
|
||||
ceilingGenerators.clear();
|
||||
loadGenerators(((CeilingChunkGenerator) this).getFloorDimension());
|
||||
loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension());
|
||||
}
|
||||
|
||||
protected void loadGenerators(IrisDimension dim)
|
||||
{
|
||||
if(dim == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
KList<String> touch = new KList<>();
|
||||
KList<String> loadQueue = new KList<>();
|
||||
|
||||
for(String i : getDimension().getRegions())
|
||||
for(String i : dim.getRegions())
|
||||
{
|
||||
IrisRegion r = Iris.data.getRegionLoader().load(i);
|
||||
|
||||
@ -141,7 +173,7 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
{
|
||||
touch.add(next);
|
||||
IrisBiome biome = Iris.data.getBiomeLoader().load(next);
|
||||
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator()));
|
||||
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator(), dim));
|
||||
loadQueue.addAll(biome.getChildren());
|
||||
}
|
||||
}
|
||||
@ -188,16 +220,16 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
|
||||
ChunkPosition pos = new ChunkPosition(x, z);
|
||||
|
||||
if(biomeHitCache.containsKey(pos))
|
||||
if(getBiomeHitCache().containsKey(pos))
|
||||
{
|
||||
return biomeHitCache.get(pos);
|
||||
return getBiomeHitCache().get(pos);
|
||||
}
|
||||
|
||||
double wx = getModifiedX(x, z);
|
||||
double wz = getModifiedZ(x, z);
|
||||
IrisRegion region = glBiome.getRegion(wx, wz);
|
||||
BiomeResult res = glBiome.generateRegionData(wx, wz, x, z, region);
|
||||
biomeHitCache.put(pos, res);
|
||||
getBiomeHitCache().put(pos, res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.object.IrisDimension;
|
||||
import ninja.bytecode.iris.util.InvertedBiomeGrid;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
public abstract class CeilingChunkGenerator extends ParallaxChunkGenerator
|
||||
{
|
||||
protected boolean generatingCeiling = false;
|
||||
|
||||
public CeilingChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||
{
|
||||
targetFloor();
|
||||
generate(random, x, z, data, grid);
|
||||
|
||||
if(getFloorDimension().isMirrorCeiling())
|
||||
{
|
||||
writeInverted(copy(data), data);
|
||||
}
|
||||
|
||||
else if(getCeilingDimension() != null)
|
||||
{
|
||||
ChunkData ceiling = createChunkData(world);
|
||||
InvertedBiomeGrid ceilingGrid = new InvertedBiomeGrid(grid);
|
||||
targetCeiling();
|
||||
generate(random, x, z, ceiling, ceilingGrid);
|
||||
writeInverted(ceiling, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void targetFloor()
|
||||
{
|
||||
generatingCeiling = false;
|
||||
}
|
||||
|
||||
private void targetCeiling()
|
||||
{
|
||||
generatingCeiling = true;
|
||||
}
|
||||
|
||||
private void generate(RNG random, int x, int z, ChunkData ceiling, BiomeGrid grid)
|
||||
{
|
||||
super.onGenerate(random, x, z, ceiling, grid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisDimension getDimension()
|
||||
{
|
||||
return generatingCeiling ? getCeilingDimension() : getFloorDimension();
|
||||
}
|
||||
|
||||
public IrisDimension getFloorDimension()
|
||||
{
|
||||
return super.getDimension();
|
||||
}
|
||||
|
||||
public IrisDimension getCeilingDimension()
|
||||
{
|
||||
if(getFloorDimension().getCeiling().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IrisDimension c = Iris.data.getDimensionLoader().load(getFloorDimension().getCeiling());
|
||||
|
||||
if(c != null)
|
||||
{
|
||||
c.setInverted(true);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public void writeInverted(ChunkData data, ChunkData into)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < data.getMaxHeight(); j++)
|
||||
{
|
||||
for(int k = 0; k < 16; k++)
|
||||
{
|
||||
BlockData b = data.getBlockData(i, j, k);
|
||||
|
||||
if(b == null || b.getMaterial().equals(Material.AIR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
into.setBlock(i, data.getMaxHeight() - j, k, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkData copy(ChunkData d)
|
||||
{
|
||||
ChunkData copy = createChunkData(world);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < d.getMaxHeight(); j++)
|
||||
{
|
||||
for(int k = 0; k < 16; k++)
|
||||
{
|
||||
BlockData b = d.getBlockData(i, j, k);
|
||||
|
||||
if(b == null || b.getMaterial().equals(Material.AIR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
copy.setBlock(i, j, k, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import ninja.bytecode.iris.util.BiomeResult;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisChunkGenerator extends ParallaxChunkGenerator implements IrisContext
|
||||
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext
|
||||
{
|
||||
private Method initLighting;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -9,7 +10,9 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.object.IrisBiome;
|
||||
import ninja.bytecode.iris.object.IrisDepositGenerator;
|
||||
import ninja.bytecode.iris.object.IrisObjectPlacement;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliver;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliverMap;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicWorldData;
|
||||
@ -27,13 +30,17 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
{
|
||||
private KMap<ChunkPosition, AtomicSliver> sliverCache;
|
||||
protected AtomicWorldData parallaxMap;
|
||||
private KMap<ChunkPosition, AtomicSliver> ceilingSliverCache;
|
||||
protected AtomicWorldData ceilingParallaxMap;
|
||||
private MasterLock masterLock;
|
||||
private ReentrantLock lock = new ReentrantLock();
|
||||
private int sliverBuffer;
|
||||
|
||||
public ParallaxChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
sliverCache = new KMap<>();
|
||||
ceilingSliverCache = new KMap<>();
|
||||
sliverBuffer = 0;
|
||||
masterLock = new MasterLock();
|
||||
}
|
||||
@ -41,7 +48,13 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
parallaxMap = new AtomicWorldData(world);
|
||||
parallaxMap = new AtomicWorldData(world, "floor");
|
||||
ceilingParallaxMap = new AtomicWorldData(world, "ceiling");
|
||||
}
|
||||
|
||||
protected KMap<ChunkPosition, AtomicSliver> getSliverCache()
|
||||
{
|
||||
return getDimension().isInverted() ? ceilingSliverCache : sliverCache;
|
||||
}
|
||||
|
||||
protected void onClose()
|
||||
@ -51,6 +64,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
try
|
||||
{
|
||||
parallaxMap.unloadAll(true);
|
||||
ceilingParallaxMap.unloadAll(true);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
@ -65,6 +79,11 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
return sampleSliver(x, z).getHighestBlock();
|
||||
}
|
||||
|
||||
public int getHighestGround(int x, int z)
|
||||
{
|
||||
return sampleSliver(x, z).getHighestGround();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockData d)
|
||||
{
|
||||
@ -102,6 +121,11 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
return getParallaxChunk(x, z).isWorldGenerated();
|
||||
}
|
||||
|
||||
public AtomicWorldData getParallaxMap()
|
||||
{
|
||||
return getDimension().isInverted() ? ceilingParallaxMap : parallaxMap;
|
||||
}
|
||||
|
||||
public AtomicSliverMap getParallaxChunk(int x, int z)
|
||||
{
|
||||
try
|
||||
@ -121,7 +145,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
super.onPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
biomeHitCache.clear();
|
||||
getBiomeHitCache().clear();
|
||||
|
||||
if(getDimension().isPlaceObjects())
|
||||
{
|
||||
@ -133,6 +157,8 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
getSliverCache().clear();
|
||||
getMasterLock().clear();
|
||||
}
|
||||
|
||||
super.onPostParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
}
|
||||
|
||||
protected void onGenerateParallax(RNG random, int x, int z)
|
||||
@ -161,12 +187,39 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
getTx().queue(key, () ->
|
||||
{
|
||||
IrisBiome b = sampleTrueBiome((i * 16) + 7, (j * 16) + 7).getBiome();
|
||||
IrisRegion r = sampleRegion((i * 16) + 7, (j * 16) + 7);
|
||||
RNG ro = random.nextParallelRNG(496888 + i + j);
|
||||
|
||||
int g = 1;
|
||||
|
||||
for(IrisObjectPlacement k : b.getObjects())
|
||||
{
|
||||
placeObject(k, i, j, random.nextParallelRNG((34 * ((i * 30) + (j * 30) + g++) * i * j) + i - j + 3569222));
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
k.generate((x * 16) + ro.nextInt(16), (z * 16) + ro.nextInt(16), ro, this);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : r.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
k.generate((x * 16) + ro.nextInt(16), (z * 16) + ro.nextInt(16), ro, this);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : b.getDeposits())
|
||||
{
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++)
|
||||
{
|
||||
k.generate((x * 16) + ro.nextInt(16), (z * 16) + ro.nextInt(16), ro, this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getParallaxChunk(ii, jj).setParallaxGenerated(true);
|
||||
@ -176,7 +229,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
getTx().waitFor(key);
|
||||
}
|
||||
|
||||
protected void placeObject(IrisObjectPlacement o, int x, int z, RNG rng)
|
||||
public void placeObject(IrisObjectPlacement o, int x, int z, RNG rng)
|
||||
{
|
||||
for(int i = 0; i < o.getTriesForChunk(rng); i++)
|
||||
{
|
||||
@ -189,15 +242,21 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
{
|
||||
ChunkPosition key = new ChunkPosition(x, z);
|
||||
|
||||
if(sliverCache.containsKey(key))
|
||||
if(getSliverCache().containsKey(key))
|
||||
{
|
||||
return sliverCache.get(key);
|
||||
return getSliverCache().get(key);
|
||||
}
|
||||
|
||||
AtomicSliver s = new AtomicSliver(x & 15, z & 15);
|
||||
onGenerateColumn(x >> 4, z >> 4, x, z, x & 15, z & 15, s, null);
|
||||
sliverCache.put(key, s);
|
||||
getSliverCache().put(key, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventingDecay()
|
||||
{
|
||||
return getDimension().isPreventLeafDecay();
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,12 @@ import ninja.bytecode.shuriken.math.M;
|
||||
public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
protected static final BlockData AIR = Material.AIR.createBlockData();
|
||||
protected static final BlockData STONE = Material.STONE.createBlockData();
|
||||
protected static final BlockData WATER = Material.WATER.createBlockData();
|
||||
private KList<BlockPosition> updateBlocks = new KList<>();
|
||||
private ReentrantLock relightLock = new ReentrantLock();
|
||||
private long lastUpdateRequest = M.ms();
|
||||
private long lastChunkLoad = M.ms();
|
||||
private GenLayerCave glCaves;
|
||||
private GenLayerCave glCave;
|
||||
private RNG rockRandom;
|
||||
|
||||
public TerrainChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
@ -45,7 +44,8 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
glCaves = new GenLayerCave(this, rng);
|
||||
rockRandom = getMasterRandom().nextParallelRNG(2858678);
|
||||
glCave = new GenLayerCave(this, rng.nextParallelRNG(238948));
|
||||
}
|
||||
|
||||
public void queueUpdate(int x, int y, int z)
|
||||
@ -130,7 +130,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
else if(!getDimension().isInverted())
|
||||
{
|
||||
if(biomeMap != null)
|
||||
{
|
||||
@ -151,12 +151,12 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
if(underwater)
|
||||
{
|
||||
block = seaLayers.hasIndex(fluidHeight - k) ? layers.get(depth) : WATER;
|
||||
block = seaLayers.hasIndex(fluidHeight - k) ? layers.get(depth) : getDimension().getFluid(rockRandom, wx, k, wz);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
block = layers.hasIndex(depth) ? layers.get(depth) : STONE;
|
||||
block = layers.hasIndex(depth) ? layers.get(depth) : getDimension().getRock(rockRandom, wx, k, wz);
|
||||
depth++;
|
||||
}
|
||||
|
||||
@ -247,12 +247,22 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
@Override
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
onPreParallaxPostGenerate(random, x, z, data, grid, height, biomeMap);
|
||||
}
|
||||
|
||||
protected void onPreParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
glCaves.genCaves((x << 4) + i, (z << 4) + j, i, j, data, height);
|
||||
glCave.genCaves((x << 4) + i, (z << 4) + j, i, j, data, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,547 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.Ladder;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Stairs;
|
||||
import org.bukkit.material.Vine;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.object.IrisObject;
|
||||
import ninja.bytecode.iris.util.Direction;
|
||||
import ninja.bytecode.iris.util.VectorMath;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
import ninja.bytecode.shuriken.collections.KMap;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
|
||||
public class GenObject
|
||||
{
|
||||
public static IDLibrary lib = new IDLibrary();
|
||||
private boolean centeredHeight;
|
||||
private int w;
|
||||
private int h;
|
||||
private int d;
|
||||
private int failures;
|
||||
private int successes;
|
||||
private boolean gravity;
|
||||
private String name = "?";
|
||||
private KMap<SBlockVector, BlockData> s;
|
||||
private KMap<SChunkVectorShort, SBlockVector> slopeCache;
|
||||
private KMap<SChunkVectorShort, SBlockVector> gravityCache;
|
||||
private BlockVector mount;
|
||||
private int maxslope;
|
||||
private int baseslope;
|
||||
private boolean hydrophilic;
|
||||
private boolean submerged;
|
||||
private int mountHeight;
|
||||
private BlockVector shift;
|
||||
|
||||
public GenObject(int w, int h, int d)
|
||||
{
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.d = d;
|
||||
shift = new BlockVector();
|
||||
s = new KMap<>();
|
||||
centeredHeight = false;
|
||||
gravity = false;
|
||||
maxslope = -1;
|
||||
baseslope = 0;
|
||||
hydrophilic = false;
|
||||
submerged = false;
|
||||
}
|
||||
|
||||
public void recalculateMountShift()
|
||||
{
|
||||
int ly = Integer.MAX_VALUE;
|
||||
|
||||
for(SBlockVector i : s.keySet())
|
||||
{
|
||||
if(i.getY() < ly)
|
||||
{
|
||||
ly = (int) i.getY();
|
||||
}
|
||||
}
|
||||
|
||||
KList<SBlockVector> fmount = new KList<>();
|
||||
|
||||
for(SBlockVector i : s.keySet())
|
||||
{
|
||||
if(i.getY() == ly)
|
||||
{
|
||||
fmount.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
double avx[] = new double[fmount.size()];
|
||||
double avy[] = new double[fmount.size()];
|
||||
double avz[] = new double[fmount.size()];
|
||||
int c = 0;
|
||||
|
||||
for(SBlockVector i : fmount)
|
||||
{
|
||||
avx[c] = i.getX();
|
||||
avy[c] = i.getY();
|
||||
avz[c] = i.getZ();
|
||||
c++;
|
||||
}
|
||||
|
||||
mountHeight = avg(avy);
|
||||
mount = new BlockVector(0, 0, 0);
|
||||
}
|
||||
|
||||
private KMap<SChunkVectorShort, SBlockVector> getSlopeCache()
|
||||
{
|
||||
if(slopeCache == null)
|
||||
{
|
||||
computeSlopeCache();
|
||||
}
|
||||
|
||||
return slopeCache;
|
||||
}
|
||||
|
||||
private KMap<SChunkVectorShort, SBlockVector> getGravityCache()
|
||||
{
|
||||
if(gravityCache == null)
|
||||
{
|
||||
computeGravityCache();
|
||||
}
|
||||
|
||||
return gravityCache;
|
||||
}
|
||||
|
||||
private void computeGravityCache()
|
||||
{
|
||||
gravityCache = new KMap<>();
|
||||
|
||||
for(SBlockVector i : s.keySet())
|
||||
{
|
||||
SChunkVectorShort v = new SChunkVectorShort(i.getX(), i.getZ());
|
||||
|
||||
if(!gravityCache.containsKey(v) || gravityCache.get(v).getY() > i.getY())
|
||||
{
|
||||
gravityCache.put(v, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void computeSlopeCache()
|
||||
{
|
||||
slopeCache = new KMap<>();
|
||||
int low = Integer.MAX_VALUE;
|
||||
|
||||
for(SBlockVector i : s.keySet())
|
||||
{
|
||||
SChunkVectorShort v = new SChunkVectorShort(i.getX(), i.getZ());
|
||||
|
||||
if(!slopeCache.containsKey(v) || slopeCache.get(v).getY() > i.getY())
|
||||
{
|
||||
slopeCache.put(v, i);
|
||||
}
|
||||
}
|
||||
|
||||
for(SChunkVectorShort i : slopeCache.keySet())
|
||||
{
|
||||
int f = (int) slopeCache.get(i).getY();
|
||||
|
||||
if(f < low)
|
||||
{
|
||||
low = f;
|
||||
}
|
||||
}
|
||||
|
||||
for(SChunkVectorShort i : slopeCache.k())
|
||||
{
|
||||
int f = (int) slopeCache.get(i).getY();
|
||||
|
||||
if(f > low - baseslope)
|
||||
{
|
||||
slopeCache.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int avg(double[] v)
|
||||
{
|
||||
double g = 0;
|
||||
|
||||
for(int i = 0; i < v.length; i++)
|
||||
{
|
||||
g += v[i];
|
||||
}
|
||||
|
||||
return (int) Math.round(g / (double) v.length);
|
||||
}
|
||||
|
||||
public void setCenteredHeight()
|
||||
{
|
||||
this.centeredHeight = true;
|
||||
}
|
||||
|
||||
public int getW()
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
public int getH()
|
||||
{
|
||||
return h;
|
||||
}
|
||||
|
||||
public int getD()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
public KMap<SBlockVector, BlockData> getSchematic()
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
public int getDepth()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
public void read(InputStream in, boolean gzip) throws IOException
|
||||
{
|
||||
@SuppressWarnings("resource")
|
||||
GZIPInputStream gzi = gzip ? new GZIPInputStream(in) : null;
|
||||
DataInputStream din = new DataInputStream(gzip ? gzi : in);
|
||||
readDirect(din);
|
||||
din.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void readDirect(DataInputStream din) throws IOException
|
||||
{
|
||||
w = din.readInt();
|
||||
h = din.readInt();
|
||||
d = din.readInt();
|
||||
int l = din.readInt();
|
||||
clear();
|
||||
|
||||
for(int i = 0; i < l; i++)
|
||||
{
|
||||
SBlockVector v = new SBlockVector(din.readInt(), din.readInt(), din.readInt());
|
||||
int id = din.readInt();
|
||||
byte dat = (byte) din.readInt();
|
||||
Material mat = IDLibrary.getMaterial(id);
|
||||
BlockData data = Bukkit.getUnsafe().fromLegacy(Bukkit.getUnsafe().toLegacy(mat), dat);
|
||||
|
||||
if(data != null)
|
||||
{
|
||||
s.put(v, data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
throw new RuntimeException("Failed to convert");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockData get(int x, int y, int z)
|
||||
{
|
||||
return s.get(new SBlockVector(x, y, z));
|
||||
}
|
||||
|
||||
public boolean has(int x, int y, int z)
|
||||
{
|
||||
return s.containsKey(new SBlockVector(x, y, z));
|
||||
}
|
||||
|
||||
public void put(int x, int y, int z, BlockData mb)
|
||||
{
|
||||
s.put(new SBlockVector(x, y, z), mb);
|
||||
}
|
||||
|
||||
public GenObject copy()
|
||||
{
|
||||
GenObject s = new GenObject(w, h, d);
|
||||
s.fill(this.s);
|
||||
s.centeredHeight = centeredHeight;
|
||||
s.name = name;
|
||||
return s;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
s.clear();
|
||||
}
|
||||
|
||||
public void fill(KMap<SBlockVector, BlockData> b)
|
||||
{
|
||||
clear();
|
||||
s.putAll(b);
|
||||
}
|
||||
|
||||
public int sh(int g)
|
||||
{
|
||||
int m = (g / 2);
|
||||
return g % 2 == 0 ? m : m + 1;
|
||||
}
|
||||
|
||||
public static GenObject load(InputStream in) throws IOException
|
||||
{
|
||||
GenObject s = new GenObject(1, 1, 1);
|
||||
s.read(in, true);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static IrisObject loadAsModern(File f) throws IOException
|
||||
{
|
||||
GenObject legacy = new GenObject(1, 1, 1);
|
||||
legacy.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
legacy.read(fin, true);
|
||||
|
||||
IrisObject object = new IrisObject(legacy.w, legacy.h, legacy.d);
|
||||
object.setLoadKey(legacy.name);
|
||||
|
||||
for(SBlockVector i : legacy.s.k())
|
||||
{
|
||||
object.getBlocks().put(new BlockVector(i.getX(), i.getY(), i.getZ()), legacy.s.get(i));
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public static GenObject load(File f) throws IOException
|
||||
{
|
||||
GenObject s = new GenObject(1, 1, 1);
|
||||
s.name = f.getName().replaceAll("\\Q.ish\\E", "");
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
s.read(fin, true);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private byte toGlazedTCDir(BlockFace b)
|
||||
{
|
||||
switch(b)
|
||||
{
|
||||
case NORTH:
|
||||
return 0;
|
||||
case EAST:
|
||||
return 1;
|
||||
case SOUTH:
|
||||
return 2;
|
||||
case WEST:
|
||||
return 3;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private BlockFace getGlazedTCDir(byte d2)
|
||||
{
|
||||
switch(d2)
|
||||
{
|
||||
case 0:
|
||||
return BlockFace.NORTH;
|
||||
case 1:
|
||||
return BlockFace.EAST;
|
||||
case 2:
|
||||
return BlockFace.SOUTH;
|
||||
case 3:
|
||||
return BlockFace.WEST;
|
||||
}
|
||||
|
||||
return BlockFace.NORTH;
|
||||
}
|
||||
|
||||
private BlockFace rotate(Direction from, Direction to, BlockFace face)
|
||||
{
|
||||
return Direction.getDirection(from.angle(Direction.getDirection(face).toVector(), to)).getFace();
|
||||
}
|
||||
|
||||
public double getSuccess()
|
||||
{
|
||||
return (double) successes / ((double) successes + (double) failures);
|
||||
}
|
||||
|
||||
public int getFailures()
|
||||
{
|
||||
return failures;
|
||||
}
|
||||
|
||||
public int getSuccesses()
|
||||
{
|
||||
return successes;
|
||||
}
|
||||
|
||||
public int getPlaces()
|
||||
{
|
||||
return successes + failures;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
s.clear();
|
||||
}
|
||||
|
||||
public void setGravity(boolean gravity)
|
||||
{
|
||||
this.gravity = gravity;
|
||||
}
|
||||
|
||||
public void setShift(int x, int y, int z)
|
||||
{
|
||||
shift = new BlockVector(x, y, z);
|
||||
}
|
||||
|
||||
public boolean isCenteredHeight()
|
||||
{
|
||||
return centeredHeight;
|
||||
}
|
||||
|
||||
public boolean isGravity()
|
||||
{
|
||||
return gravity;
|
||||
}
|
||||
|
||||
public BlockVector getMount()
|
||||
{
|
||||
return mount;
|
||||
}
|
||||
|
||||
public int getMaxslope()
|
||||
{
|
||||
return maxslope;
|
||||
}
|
||||
|
||||
public int getBaseslope()
|
||||
{
|
||||
return baseslope;
|
||||
}
|
||||
|
||||
public boolean isHydrophilic()
|
||||
{
|
||||
return hydrophilic;
|
||||
}
|
||||
|
||||
public boolean isSubmerged()
|
||||
{
|
||||
return submerged;
|
||||
}
|
||||
|
||||
public int getMountHeight()
|
||||
{
|
||||
return mountHeight;
|
||||
}
|
||||
|
||||
public BlockVector getShift()
|
||||
{
|
||||
return shift;
|
||||
}
|
||||
|
||||
public void setCenteredHeight(boolean centeredHeight)
|
||||
{
|
||||
this.centeredHeight = centeredHeight;
|
||||
}
|
||||
|
||||
public void setW(int w)
|
||||
{
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public void setH(int h)
|
||||
{
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public void setD(int d)
|
||||
{
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
public void setFailures(int failures)
|
||||
{
|
||||
this.failures = failures;
|
||||
}
|
||||
|
||||
public void setSuccesses(int successes)
|
||||
{
|
||||
this.successes = successes;
|
||||
}
|
||||
|
||||
public void setSlopeCache(KMap<SChunkVectorShort, SBlockVector> slopeCache)
|
||||
{
|
||||
this.slopeCache = slopeCache;
|
||||
}
|
||||
|
||||
public void setGravityCache(KMap<SChunkVectorShort, SBlockVector> gravityCache)
|
||||
{
|
||||
this.gravityCache = gravityCache;
|
||||
}
|
||||
|
||||
public void setMount(BlockVector mount)
|
||||
{
|
||||
this.mount = mount;
|
||||
}
|
||||
|
||||
public void setMaxslope(int maxslope)
|
||||
{
|
||||
this.maxslope = maxslope;
|
||||
}
|
||||
|
||||
public void setBaseslope(int baseslope)
|
||||
{
|
||||
this.baseslope = baseslope;
|
||||
}
|
||||
|
||||
public void setHydrophilic(boolean hydrophilic)
|
||||
{
|
||||
this.hydrophilic = hydrophilic;
|
||||
}
|
||||
|
||||
public void setSubmerged(boolean submerged)
|
||||
{
|
||||
this.submerged = submerged;
|
||||
}
|
||||
|
||||
public void setMountHeight(int mountHeight)
|
||||
{
|
||||
this.mountHeight = mountHeight;
|
||||
}
|
||||
|
||||
public void setShift(BlockVector shift)
|
||||
{
|
||||
this.shift = shift;
|
||||
}
|
||||
}
|
@ -1,276 +0,0 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class IDLibrary
|
||||
{
|
||||
public static final String SEPARATOR = ":";
|
||||
private static final String Spawn_Egg_Id = "383";
|
||||
private static final int Spawn_Egg_Id_I = Integer.parseInt("383");
|
||||
private static final IDList List = new IDList();
|
||||
|
||||
public static boolean isInt(final String ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
Integer.parseInt(ID);
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLegacy()
|
||||
{
|
||||
try
|
||||
{
|
||||
Material.valueOf("CONDUIT");
|
||||
return false;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static Material getMaterial(String ID)
|
||||
{
|
||||
if(isLegacy())
|
||||
{
|
||||
final ItemStack IS = getItemStack(ID);
|
||||
return (IS == null) ? null : IS.getType();
|
||||
}
|
||||
ID = ID.replace(" ", "").toUpperCase();
|
||||
Material t = List.getMaterial(ID.contains(":") ? ID : (String.valueOf(ID) + ":" + "0"));
|
||||
if(t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
try
|
||||
{
|
||||
t = Material.valueOf(ID);
|
||||
if(List.getIDData(t) != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
if(ID.startsWith("383"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if(!ID.contains(":") && !isInt(ID))
|
||||
{
|
||||
try
|
||||
{
|
||||
t = Material.valueOf(ID);
|
||||
if(t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
catch(Exception ex2)
|
||||
{
|
||||
}
|
||||
}
|
||||
if(ID.contains(":"))
|
||||
{
|
||||
final String[] IDs = ID.split(":");
|
||||
try
|
||||
{
|
||||
return getMaterial(Integer.parseInt(IDs[0]), Byte.parseByte(IDs[1]));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
final Material m = Material.getMaterial("LEGACY_" + IDs[0], false);
|
||||
try
|
||||
{
|
||||
return (m == null) ? m : getMaterial(m.getId(), Byte.parseByte(IDs[1]));
|
||||
}
|
||||
catch(Exception e2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
return getMaterial(Integer.parseInt(ID));
|
||||
}
|
||||
catch(Exception e3)
|
||||
{
|
||||
final Material i = Material.getMaterial("LEGACY_" + ID, false);
|
||||
return (i == null) ? i : getMaterial(i.getId(), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static Material getMaterial(final int ID)
|
||||
{
|
||||
return getMaterial(ID, (byte) 0);
|
||||
}
|
||||
|
||||
public static Material getMaterial(final int ID, final byte Data)
|
||||
{
|
||||
for(final Material i : EnumSet.allOf(Material.class))
|
||||
{
|
||||
try
|
||||
{
|
||||
if(i.getId() == ID)
|
||||
{
|
||||
final Material m = Bukkit.getUnsafe().fromLegacy(new MaterialData(i, Data));
|
||||
return ((m == Material.AIR && (ID != 0 || Data != 0)) || (Data != 0 && m == Bukkit.getUnsafe().fromLegacy(new MaterialData(i, (byte) 0)))) ? List.getMaterial(String.valueOf(ID) + ":" + Data) : m;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
catch(IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(String ID)
|
||||
{
|
||||
if(isLegacy())
|
||||
{
|
||||
final ItemStack IS = null;
|
||||
ID = ID.replace(" ", "").toUpperCase();
|
||||
if(!ID.contains(":"))
|
||||
{
|
||||
ID = String.valueOf(ID) + ":" + "0";
|
||||
}
|
||||
final String[] I = ID.split(":");
|
||||
int id = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(I[0]);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
try
|
||||
{
|
||||
id = Material.valueOf(I[0]).getId();
|
||||
}
|
||||
catch(IllegalArgumentException e2)
|
||||
{
|
||||
return IS;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
for(final Material i : EnumSet.allOf(Material.class))
|
||||
{
|
||||
if(i.getId() == id)
|
||||
{
|
||||
return new ItemStack(i, 1, (short) Integer.parseInt(I[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
return IS;
|
||||
}
|
||||
final Material M = getMaterial(ID);
|
||||
return (M == null) ? null : new ItemStack(getMaterial(ID), 1);
|
||||
}
|
||||
|
||||
public static String getIDData(final Material M)
|
||||
{
|
||||
final byte d = getData(M);
|
||||
return String.valueOf(getID(M)) + ((d == 0) ? "" : (":" + d));
|
||||
}
|
||||
|
||||
public static int getID(final Material M)
|
||||
{
|
||||
if(isLegacy())
|
||||
{
|
||||
M.getId();
|
||||
}
|
||||
final int d = List.getID(M);
|
||||
if(d != -1)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
final int i = Bukkit.getUnsafe().toLegacy(M).getId();
|
||||
return (i != Spawn_Egg_Id_I && (i != 0 || (i == 0 && M == Material.AIR))) ? i : 0;
|
||||
}
|
||||
|
||||
public static byte getData(final Material M)
|
||||
{
|
||||
if(isLegacy())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final byte d = List.getData(M);
|
||||
if(d != -1)
|
||||
{
|
||||
return d;
|
||||
}
|
||||
final int i = Bukkit.getUnsafe().toLegacy(M).getId();
|
||||
return (byte) ((i != Spawn_Egg_Id_I && (i != 0 || (i == 0 && M == Material.AIR))) ? getData(M, i, Bukkit.getUnsafe().toLegacy(M)) : 0);
|
||||
}
|
||||
|
||||
private static byte getData(final Material M, final int ID, final Material O)
|
||||
{
|
||||
for(final Material i : EnumSet.allOf(Material.class))
|
||||
{
|
||||
try
|
||||
{
|
||||
if(i.getId() != ID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for(byte i2 = 0; i2 <= 15; ++i2)
|
||||
{
|
||||
if(M.equals((Object) Bukkit.getUnsafe().fromLegacy(new MaterialData(i, i2))))
|
||||
{
|
||||
return i2;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String getIDData(final ItemStack IS)
|
||||
{
|
||||
final byte d = getData(IS);
|
||||
return String.valueOf(getID(IS)) + ((d == 0) ? "" : (":" + d));
|
||||
}
|
||||
|
||||
public static int getID(final ItemStack IS)
|
||||
{
|
||||
if(!isLegacy())
|
||||
{
|
||||
return getID(IS.getType());
|
||||
}
|
||||
return IS.getType().getId();
|
||||
}
|
||||
|
||||
public static byte getData(final ItemStack IS)
|
||||
{
|
||||
if(!isLegacy())
|
||||
{
|
||||
return getData(IS.getType());
|
||||
}
|
||||
return IS.getData().getData();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,103 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class MB
|
||||
{
|
||||
public final Material material;
|
||||
public final byte data;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static MB of(String dat)
|
||||
{
|
||||
String material = dat;
|
||||
byte data = 0;
|
||||
|
||||
if(dat.contains(":"))
|
||||
{
|
||||
material = dat.split("\\Q:\\E")[0];
|
||||
data = Integer.valueOf(dat.split("\\Q:\\E")[1]).byteValue();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new MB(Material.getMaterial("LEGACY_" + Integer.valueOf(material)), data);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new MB(Material.getMaterial(material), data);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if(data == 0)
|
||||
{
|
||||
return material.name();
|
||||
}
|
||||
|
||||
return material.name() + ":" + data;
|
||||
}
|
||||
|
||||
public MB(Material material, int data)
|
||||
{
|
||||
this.material = material;
|
||||
this.data = (byte) data;
|
||||
}
|
||||
|
||||
public MB(Material material)
|
||||
{
|
||||
this(material, 0);
|
||||
}
|
||||
|
||||
public static MB of(Material f)
|
||||
{
|
||||
return new MB(f);
|
||||
}
|
||||
|
||||
public static MB of(Material f, int a)
|
||||
{
|
||||
return new MB(f, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + data;
|
||||
result = prime * result + ((material == null) ? 0 : material.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
MB other = (MB) obj;
|
||||
if(data != other.data)
|
||||
return false;
|
||||
if(material != other.material)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* A vector with a hash function that floors the X, Y, Z components, a la
|
||||
* BlockVector in WorldEdit. BlockVectors can be used in hash sets and hash
|
||||
* maps. Be aware that BlockVectors are mutable, but it is important that
|
||||
* BlockVectors are never changed once put into a hash set or hash map.
|
||||
*/
|
||||
@SerializableAs("BlockVector")
|
||||
public class SBlockVector
|
||||
{
|
||||
private short x;
|
||||
private short y;
|
||||
private short z;
|
||||
|
||||
/**
|
||||
* Construct the vector with all components as 0.
|
||||
*/
|
||||
public SBlockVector()
|
||||
{
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.z = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the vector with another vector.
|
||||
*
|
||||
* @param vec
|
||||
* The other vector.
|
||||
*/
|
||||
public SBlockVector(Vector vec)
|
||||
{
|
||||
this.x = (short) vec.getX();
|
||||
this.y = (short) vec.getY();
|
||||
this.z = (short) vec.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the vector with provided integer components.
|
||||
*
|
||||
* @param x
|
||||
* X component
|
||||
* @param y
|
||||
* Y component
|
||||
* @param z
|
||||
* Z component
|
||||
*/
|
||||
public SBlockVector(int x, int y, int z)
|
||||
{
|
||||
this.x = (short) x;
|
||||
this.y = (short) y;
|
||||
this.z = (short) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the vector with provided double components.
|
||||
*
|
||||
* @param x
|
||||
* X component
|
||||
* @param y
|
||||
* Y component
|
||||
* @param z
|
||||
* Z component
|
||||
*/
|
||||
public SBlockVector(double x, double y, double z)
|
||||
{
|
||||
this.x = (short) x;
|
||||
this.y = (short) y;
|
||||
this.z = (short) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the vector with provided float components.
|
||||
*
|
||||
* @param x
|
||||
* X component
|
||||
* @param y
|
||||
* Y component
|
||||
* @param z
|
||||
* Z component
|
||||
*/
|
||||
public SBlockVector(float x, float y, float z)
|
||||
{
|
||||
this.x = (short) x;
|
||||
this.y = (short) y;
|
||||
this.z = (short) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new block vector.
|
||||
*
|
||||
* @return vector
|
||||
*/
|
||||
@Override
|
||||
public SBlockVector clone()
|
||||
{
|
||||
return new SBlockVector(x, y, z);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x)
|
||||
{
|
||||
this.x = (short) x;
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y)
|
||||
{
|
||||
this.y = (short) y;
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z)
|
||||
{
|
||||
this.z = (short) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
SBlockVector other = (SBlockVector) obj;
|
||||
if(x != other.x)
|
||||
return false;
|
||||
if(y != other.y)
|
||||
return false;
|
||||
if(z != other.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockVector toBlockVector()
|
||||
{
|
||||
return new BlockVector(x, y, z);
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
public class SChunkVector
|
||||
{
|
||||
private byte x;
|
||||
private byte z;
|
||||
|
||||
public SChunkVector(int x, int z)
|
||||
{
|
||||
this.x = (byte) (x);
|
||||
this.z = (byte) (z);
|
||||
}
|
||||
|
||||
public SChunkVector(byte x, byte z)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public SChunkVector(double x, double z)
|
||||
{
|
||||
this((int) Math.round(x), (int) Math.round(z));
|
||||
}
|
||||
|
||||
public SChunkVector()
|
||||
{
|
||||
this((byte) 0, (byte) 0);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = (byte) x;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = (byte) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
SChunkVector other = (SChunkVector) obj;
|
||||
if(x != other.x)
|
||||
return false;
|
||||
if(z != other.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SChunkVectorShort
|
||||
{
|
||||
private short x;
|
||||
private short z;
|
||||
|
||||
public SChunkVectorShort(int x, int z)
|
||||
{
|
||||
this.x = (short) (x);
|
||||
this.z = (short) (z);
|
||||
}
|
||||
|
||||
public SChunkVectorShort(short x, short z)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public SChunkVectorShort(double x, double z)
|
||||
{
|
||||
this((int) Math.round(x), (int) Math.round(z));
|
||||
}
|
||||
|
||||
public SChunkVectorShort()
|
||||
{
|
||||
this((short) 0, (short) 0);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = (short) x;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = (short) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!(obj instanceof SChunkVectorShort))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SChunkVectorShort other = (SChunkVectorShort) obj;
|
||||
return x == other.x && z == other.z;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SMCAVector
|
||||
{
|
||||
private int x;
|
||||
private int z;
|
||||
|
||||
public SMCAVector(int x, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public SMCAVector()
|
||||
{
|
||||
this(0, 0);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!(obj instanceof SMCAVector))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SMCAVector other = (SMCAVector) obj;
|
||||
return x == other.x && z == other.z;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package ninja.bytecode.iris.legacy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SuperUnsafe
|
||||
{
|
||||
public static Material getMaterial(String material, byte d)
|
||||
{
|
||||
return Bukkit.getUnsafe().getMaterial(material, d);
|
||||
}
|
||||
|
||||
public static BlockData getBlockData(String material, byte d)
|
||||
{
|
||||
return Bukkit.getUnsafe().fromLegacy(Bukkit.getUnsafe().toLegacy(getMaterial(material, d)), d);
|
||||
}
|
||||
}
|
8
src/main/java/ninja/bytecode/iris/object/Envelope.java
Normal file
8
src/main/java/ninja/bytecode/iris/object/Envelope.java
Normal file
@ -0,0 +1,8 @@
|
||||
package ninja.bytecode.iris.object;
|
||||
|
||||
public enum Envelope
|
||||
{
|
||||
EVERYWHERE,
|
||||
CELLS,
|
||||
VEINS,
|
||||
}
|
@ -58,6 +58,9 @@ public class IrisBiome extends IrisRegistrant
|
||||
@Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.")
|
||||
private KList<IrisBiomeGeneratorLink> generators = new KList<IrisBiomeGeneratorLink>().qadd(new IrisBiomeGeneratorLink());
|
||||
|
||||
@Desc("Define biome deposit generators that add onto the existing regional and global deposit generators")
|
||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
private transient CellGenerator childrenCell;
|
||||
private transient InferredType inferredType;
|
||||
|
@ -31,9 +31,9 @@ public class IrisBiomePaletteLayer
|
||||
private KList<String> palette = new KList<String>().qadd("GRASS_BLOCK");
|
||||
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
private transient KList<BlockData> blockData;
|
||||
private transient CNG layerGenerator;
|
||||
private transient CNG heightGenerator;
|
||||
private transient KList<BlockData> blockData;
|
||||
|
||||
public CNG getHeightGenerator(RNG rng)
|
||||
{
|
||||
|
@ -0,0 +1,152 @@
|
||||
package ninja.bytecode.iris.object;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import lombok.Data;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.ParallaxChunkGenerator;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.Desc;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
|
||||
@Data
|
||||
public class IrisDepositGenerator
|
||||
{
|
||||
@Desc("The minimum height this deposit can generate at")
|
||||
private int minHeight = 7;
|
||||
|
||||
@Desc("The maximum height this deposit can generate at")
|
||||
private int maxHeight = 55;
|
||||
|
||||
@Desc("The minimum amount of deposit blocks per clump")
|
||||
private int minSize = 3;
|
||||
|
||||
@Desc("The maximum amount of deposit blocks per clump")
|
||||
private int maxSize = 5;
|
||||
|
||||
@Desc("The maximum amount of clumps per chunk")
|
||||
private int maxPerChunk = 3;
|
||||
|
||||
@Desc("The minimum amount of clumps per chunk")
|
||||
private int minPerChunk = 1;
|
||||
|
||||
@Desc("The palette of blocks to be used in this deposit generator")
|
||||
private KList<String> palette = new KList<String>();
|
||||
|
||||
@Desc("Ore varience is how many different objects clumps iris will create")
|
||||
private int varience = 8;
|
||||
|
||||
private transient IrisObjectPlacement config = createDepositConfig();
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
private transient KList<IrisObject> objects;
|
||||
private transient KList<BlockData> blockData;
|
||||
|
||||
public IrisObject getClump(RNG rng)
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(objects == null)
|
||||
{
|
||||
RNG rngv = rng.nextParallelRNG(3957778);
|
||||
objects = new KList<>();
|
||||
|
||||
for(int i = 0; i < varience; i++)
|
||||
{
|
||||
objects.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598)));
|
||||
Iris.info("Generated Object: " + "plugins\\Iris\\virtual-pack\\deposit-" + rng.i(10000, 50000) + "-" + (i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return objects.get(rng.i(0, objects.size() - 1));
|
||||
}
|
||||
|
||||
private IrisObjectPlacement createDepositConfig()
|
||||
{
|
||||
IrisObjectPlacement p = new IrisObjectPlacement();
|
||||
IrisObjectRotation rot = new IrisObjectRotation();
|
||||
rot.setEnabled(true);
|
||||
IrisAxisRotationClamp xc = new IrisAxisRotationClamp();
|
||||
IrisAxisRotationClamp yc = new IrisAxisRotationClamp();
|
||||
IrisAxisRotationClamp zc = new IrisAxisRotationClamp();
|
||||
xc.setEnabled(true);
|
||||
xc.setInterval(45);
|
||||
yc.setEnabled(true);
|
||||
yc.setInterval(45);
|
||||
zc.setEnabled(true);
|
||||
zc.setInterval(45);
|
||||
rot.setXAxis(xc);
|
||||
rot.setYAxis(yc);
|
||||
rot.setZAxis(zc);
|
||||
p.setRotation(rot);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private IrisObject generateClumpObject(RNG rngv)
|
||||
{
|
||||
int s = rngv.i(minSize, maxSize);
|
||||
int dim = (int) Math.round(Math.pow(s, 1D / 3D));
|
||||
int w = dim / 2;
|
||||
IrisObject o = new IrisObject(dim, dim, dim);
|
||||
|
||||
if(s == 1)
|
||||
{
|
||||
o.getBlocks().put(o.getCenter(), nextBlock(rngv));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
while(s > 0)
|
||||
{
|
||||
s--;
|
||||
BlockVector ang = new BlockVector(rngv.i(-w, w), rngv.i(-w, w), rngv.i(-w, w));
|
||||
BlockVector pos = o.getCenter().clone().add(ang).toBlockVector();
|
||||
o.getBlocks().put(pos, nextBlock(rngv));
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
private BlockData nextBlock(RNG rngv)
|
||||
{
|
||||
return getBlockData().get(rngv.i(0, getBlockData().size() - 1));
|
||||
}
|
||||
|
||||
public KList<BlockData> getBlockData()
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
if(blockData == null)
|
||||
{
|
||||
blockData = new KList<>();
|
||||
|
||||
for(String ix : palette)
|
||||
{
|
||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||
|
||||
if(bx != null)
|
||||
{
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
return blockData;
|
||||
}
|
||||
|
||||
public void generate(int x, int z, RNG rng, ParallaxChunkGenerator g)
|
||||
{
|
||||
IrisObject clump = getClump(rng);
|
||||
int height = (int) (g.getHighestGround(x, z) - (clump.getH() * 1.5));
|
||||
int h = rng.i(Math.max(0, minHeight), Math.min(height, Math.min(256, maxHeight)));
|
||||
clump.place(x, h, z, g, config, rng);
|
||||
}
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
package ninja.bytecode.iris.object;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.Desc;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
@ -23,11 +27,24 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("The interpolation distance scale. Increase = more smooth, less detail")
|
||||
private double interpolationScale = 63;
|
||||
|
||||
@Desc("The Thickness scale of cave veins")
|
||||
private double caveThickness = 1D;
|
||||
|
||||
@Desc("The cave web scale. Smaller values means scaled up vein networks.")
|
||||
private double caveScale = 1D;
|
||||
|
||||
@Desc("Shift the Y value of the cave networks up or down.")
|
||||
private double caveShift = 0D;
|
||||
|
||||
@Desc("Generate caves or not.")
|
||||
private boolean caves = true;
|
||||
|
||||
@Desc("The ceiling dimension. Leave blank for normal sky.")
|
||||
private String ceiling = "";
|
||||
|
||||
@Desc("Mirrors the generator floor into the ceiling. Think nether but worse...")
|
||||
private boolean mirrorCeiling = false;
|
||||
|
||||
@Desc("The world environment")
|
||||
private Environment environment = Environment.NORMAL;
|
||||
|
||||
@ -79,10 +96,35 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("Disable this to stop placing schematics in biomes")
|
||||
private boolean placeObjects = true;
|
||||
|
||||
@Desc("Prevent Leaf decay as if placed in creative mode")
|
||||
private boolean preventLeafDecay = false;
|
||||
|
||||
@Desc("Define global deposit generators")
|
||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||
|
||||
@Desc("The dispersion of materials for the rock palette")
|
||||
private Dispersion dispersion = Dispersion.SCATTER;
|
||||
|
||||
@Desc("The rock zoom mostly for zooming in on a wispy palette")
|
||||
private double rockZoom = 5;
|
||||
|
||||
@Desc("The palette of blocks for 'stone'")
|
||||
private KList<String> rockPalette = new KList<String>().qadd("STONE");
|
||||
|
||||
@Desc("The palette of blocks for 'water'")
|
||||
private KList<String> fluidPalette = new KList<String>().qadd("WATER");
|
||||
|
||||
private transient ReentrantLock rockLock = new ReentrantLock();
|
||||
private transient ReentrantLock fluidLock = new ReentrantLock();
|
||||
private transient KList<BlockData> rockData;
|
||||
private transient KList<BlockData> fluidData;
|
||||
private transient CNG rockLayerGenerator;
|
||||
private transient CNG fluidLayerGenerator;
|
||||
private transient CNG coordFracture;
|
||||
private transient Double sinr;
|
||||
private transient Double cosr;
|
||||
private transient Double rad;
|
||||
private transient boolean inverted;
|
||||
|
||||
public CNG getCoordFracture(RNG rng, int signature)
|
||||
{
|
||||
@ -95,6 +137,126 @@ public class IrisDimension extends IrisRegistrant
|
||||
return coordFracture;
|
||||
}
|
||||
|
||||
public BlockData getRock(RNG rng, double x, double y, double z)
|
||||
{
|
||||
if(rockLayerGenerator == null)
|
||||
{
|
||||
cacheRockGenerator(rng);
|
||||
}
|
||||
|
||||
if(rockLayerGenerator != null)
|
||||
{
|
||||
if(dispersion.equals(Dispersion.SCATTER))
|
||||
{
|
||||
return getRockData().get(rockLayerGenerator.fit(0, 30000000, x, y, z) % getRockData().size());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return getRockData().get(rockLayerGenerator.fit(0, getRockData().size() - 1, x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
return getRockData().get(0);
|
||||
}
|
||||
|
||||
public void cacheRockGenerator(RNG rng)
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(getRockData().size() * hashCode());
|
||||
|
||||
switch(dispersion)
|
||||
{
|
||||
case SCATTER:
|
||||
rockLayerGenerator = CNG.signature(rngx).freq(1000000);
|
||||
break;
|
||||
case WISPY:
|
||||
rockLayerGenerator = CNG.signature(rngx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public KList<BlockData> getRockData()
|
||||
{
|
||||
rockLock.lock();
|
||||
|
||||
if(rockData == null)
|
||||
{
|
||||
rockData = new KList<>();
|
||||
for(String ix : rockPalette)
|
||||
{
|
||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||
if(bx != null)
|
||||
{
|
||||
rockData.add(bx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rockLock.unlock();
|
||||
|
||||
return rockData;
|
||||
}
|
||||
|
||||
public BlockData getFluid(RNG rng, double x, double y, double z)
|
||||
{
|
||||
if(fluidLayerGenerator == null)
|
||||
{
|
||||
cacheFluidGenerator(rng);
|
||||
}
|
||||
|
||||
if(fluidLayerGenerator != null)
|
||||
{
|
||||
if(dispersion.equals(Dispersion.SCATTER))
|
||||
{
|
||||
return getFluidData().get(fluidLayerGenerator.fit(0, 30000000, x, y, z) % getFluidData().size());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return getFluidData().get(fluidLayerGenerator.fit(0, getFluidData().size() - 1, x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
return getFluidData().get(0);
|
||||
}
|
||||
|
||||
public void cacheFluidGenerator(RNG rng)
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(getFluidData().size() * hashCode());
|
||||
|
||||
switch(dispersion)
|
||||
{
|
||||
case SCATTER:
|
||||
fluidLayerGenerator = CNG.signature(rngx).freq(1000000);
|
||||
break;
|
||||
case WISPY:
|
||||
fluidLayerGenerator = CNG.signature(rngx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public KList<BlockData> getFluidData()
|
||||
{
|
||||
fluidLock.lock();
|
||||
|
||||
if(fluidData == null)
|
||||
{
|
||||
fluidData = new KList<>();
|
||||
for(String ix : fluidPalette)
|
||||
{
|
||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||
if(bx != null)
|
||||
{
|
||||
fluidData.add(bx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fluidLock.unlock();
|
||||
|
||||
return fluidData;
|
||||
}
|
||||
|
||||
public double getDimensionAngle()
|
||||
{
|
||||
if(rad == null)
|
||||
|
@ -10,12 +10,15 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.ChunkPosition;
|
||||
import ninja.bytecode.iris.util.IObjectPlacer;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.collections.KMap;
|
||||
@ -24,6 +27,8 @@ import ninja.bytecode.shuriken.collections.KMap;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisObject extends IrisRegistrant
|
||||
{
|
||||
private static final Material SNOW = Material.SNOW;
|
||||
private static final BlockData[] SNOW_LAYERS = new BlockData[] {BlockDataTools.getBlockData("minecraft:snow[layers=1]"), BlockDataTools.getBlockData("minecraft:snow[layers=2]"), BlockDataTools.getBlockData("minecraft:snow[layers=3]"), BlockDataTools.getBlockData("minecraft:snow[layers=4]"), BlockDataTools.getBlockData("minecraft:snow[layers=5]"), BlockDataTools.getBlockData("minecraft:snow[layers=6]"), BlockDataTools.getBlockData("minecraft:snow[layers=7]"), BlockDataTools.getBlockData("minecraft:snow[layers=8]")};
|
||||
private KMap<BlockVector, BlockData> blocks;
|
||||
private int w;
|
||||
private int d;
|
||||
@ -115,20 +120,84 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
|
||||
public void place(int x, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
|
||||
{
|
||||
place(x, -1, z, placer, config, rng);
|
||||
}
|
||||
|
||||
public void place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
|
||||
{
|
||||
boolean yf = rng.nextBoolean();
|
||||
boolean xf = rng.nextBoolean();
|
||||
int spinx = rng.imax() / 1000;
|
||||
int spiny = rng.imax() / 1000;
|
||||
int spinz = rng.imax() / 1000;
|
||||
int y = placer.getHighest(x, z) + config.getRotation().rotate(new BlockVector(0, getCenter().getBlockY(), 0), yf, xf, spinx, spiny, spinz).getBlockY();
|
||||
int y = yv < 0 ? placer.getHighest(x, z) + config.getRotation().rotate(new BlockVector(0, getCenter().getBlockY(), 0), yf, xf, spinx, spiny, spinz).getBlockY() : yv;
|
||||
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
|
||||
for(BlockVector g : blocks.k())
|
||||
{
|
||||
BlockVector i = g.clone();
|
||||
i = config.getRotation().rotate(i.clone(), yf, xf, spinx, spiny, spinz).clone();
|
||||
i = config.getTranslate().translate(i.clone()).clone();
|
||||
placer.set(x + i.getBlockX(), y + i.getBlockY(), z + i.getBlockZ(), blocks.get(g));
|
||||
BlockData data = blocks.get(g);
|
||||
|
||||
if(placer.isPreventingDecay() && data instanceof Leaves && !((Leaves) data).isPersistent())
|
||||
{
|
||||
((Leaves) data).setPersistent(true);
|
||||
}
|
||||
|
||||
for(IrisObjectReplace j : config.getEdit())
|
||||
{
|
||||
if(j.getFind().matches(data))
|
||||
{
|
||||
data = j.getReplace();
|
||||
}
|
||||
}
|
||||
|
||||
int xx = x + (int) Math.round(i.getX());
|
||||
int yy = y + (int) Math.round(i.getY());
|
||||
int zz = z + (int) Math.round(i.getZ());
|
||||
|
||||
if(heightmap != null)
|
||||
{
|
||||
ChunkPosition pos = new ChunkPosition(xx, zz);
|
||||
|
||||
if(!heightmap.containsKey(pos))
|
||||
{
|
||||
heightmap.put(pos, yy);
|
||||
}
|
||||
|
||||
if(heightmap.get(pos) < yy)
|
||||
{
|
||||
heightmap.put(pos, yy);
|
||||
}
|
||||
}
|
||||
|
||||
placer.set(xx, yy, zz, data);
|
||||
}
|
||||
|
||||
if(heightmap != null)
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(3468854);
|
||||
|
||||
for(ChunkPosition i : heightmap.k())
|
||||
{
|
||||
int vx = i.getX();
|
||||
int vy = heightmap.get(i);
|
||||
int vz = i.getZ();
|
||||
|
||||
if(config.getSnow() > 0)
|
||||
{
|
||||
BlockData bd = placer.get(vx, vy, vz);
|
||||
if(bd != null && bd.getMaterial().equals(SNOW))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int height = rngx.i(0, (int) (config.getSnow() * 7));
|
||||
placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,22 @@ public class IrisObjectPlacement
|
||||
{
|
||||
@Desc("List of objects to place")
|
||||
private KList<String> place = new KList<>();
|
||||
|
||||
@Desc("Find and replace blocks")
|
||||
private KList<IrisObjectReplace> edit = new KList<>();
|
||||
|
||||
@Desc("Translate this object's placement")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Rotate this objects placement")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("The maximum layer level of a snow filter overtop of this placement. Set to 0 to disable. Max of 1.")
|
||||
private double snow = 0;
|
||||
|
||||
@Desc("The chance for this to place in a chunk. If you need multiple per chunk, set this to 1 and use density.")
|
||||
private double chance = 1;
|
||||
|
||||
@Desc("If the chance check passes, place this many in a single chunk")
|
||||
private int density = 1;
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
package ninja.bytecode.iris.object;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import lombok.Data;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.Desc;
|
||||
|
||||
@Desc("Find and replace object materials")
|
||||
@Data
|
||||
public class IrisObjectReplace
|
||||
{
|
||||
private String find;
|
||||
private String replace;
|
||||
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
private transient BlockData findData;
|
||||
private transient BlockData replaceData;
|
||||
|
||||
public IrisObjectReplace()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BlockData getFind()
|
||||
{
|
||||
if(findData == null)
|
||||
{
|
||||
findData = BlockDataTools.getBlockData(find);
|
||||
}
|
||||
|
||||
return findData;
|
||||
}
|
||||
|
||||
public BlockData getReplace()
|
||||
{
|
||||
if(replaceData == null)
|
||||
{
|
||||
replaceData = BlockDataTools.getBlockData(replace);
|
||||
}
|
||||
|
||||
return replaceData;
|
||||
}
|
||||
}
|
@ -46,6 +46,9 @@ public class IrisRegion extends IrisRegistrant
|
||||
@Desc("Spot biomes splotch themselves across this region like lakes")
|
||||
private KList<IrisRegionSpot> spotBiomes = new KList<>();
|
||||
|
||||
@Desc("Define regional deposit generators that add onto the global deposit generators")
|
||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||
|
||||
private transient CNG shoreHeightGenerator;
|
||||
private transient ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
@ -21,6 +22,7 @@ public class AtomicSliver
|
||||
private KMap<Integer, BlockData> block;
|
||||
private KMap<Integer, Biome> biome;
|
||||
private int highestBlock = 0;
|
||||
private int highestGround = 0;
|
||||
private int highestBiome = 0;
|
||||
private int x;
|
||||
private int z;
|
||||
@ -42,6 +44,11 @@ public class AtomicSliver
|
||||
|
||||
block.put(h, d);
|
||||
highestBlock = h > highestBlock ? h : highestBlock;
|
||||
|
||||
if(!d.getMaterial().equals(Material.WATER) && !d.getMaterial().equals(Material.LAVA))
|
||||
{
|
||||
highestGround = h > highestGround ? h : highestGround;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSilently(int h, BlockData d)
|
||||
@ -96,6 +103,9 @@ public class AtomicSliver
|
||||
{
|
||||
this.block = new KMap<Integer, BlockData>();
|
||||
int h = din.readByte() - Byte.MIN_VALUE;
|
||||
highestBlock = h;
|
||||
highestGround = din.readByte() - Byte.MIN_VALUE;
|
||||
|
||||
for(int i = 0; i <= h; i++)
|
||||
{
|
||||
block.put(i, BlockDataTools.getBlockData(din.readUTF()));
|
||||
@ -105,6 +115,7 @@ public class AtomicSliver
|
||||
public void write(DataOutputStream dos) throws IOException
|
||||
{
|
||||
dos.writeByte(highestBlock + Byte.MIN_VALUE);
|
||||
dos.writeByte(highestGround + Byte.MIN_VALUE);
|
||||
|
||||
for(int i = 0; i <= highestBlock; i++)
|
||||
{
|
||||
@ -132,7 +143,7 @@ public class AtomicSliver
|
||||
|
||||
public void inject(ChunkData currentData)
|
||||
{
|
||||
for(int i = 0; i < getHighestBlock(); i++)
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
if(block.get(i) != null && !block.get(i).equals(AIR))
|
||||
{
|
||||
|
@ -17,13 +17,15 @@ public class AtomicWorldData
|
||||
private KMap<ChunkPosition, AtomicSliverMap> loadedChunks;
|
||||
private KMap<ChunkPosition, AtomicRegionData> loadedSections;
|
||||
private KMap<ChunkPosition, Long> lastRegion;
|
||||
private String prefix;
|
||||
|
||||
public AtomicWorldData(World world)
|
||||
public AtomicWorldData(World world, String prefix)
|
||||
{
|
||||
this.world = world;
|
||||
loadedSections = new KMap<>();
|
||||
loadedChunks = new KMap<>();
|
||||
lastRegion = new KMap<>();
|
||||
this.prefix = prefix;
|
||||
getSubregionFolder().mkdirs();
|
||||
}
|
||||
|
||||
@ -226,7 +228,7 @@ public class AtomicWorldData
|
||||
|
||||
public File getSubregionFolder()
|
||||
{
|
||||
return new File(world.getWorldFolder(), "subregion");
|
||||
return new File(world.getWorldFolder(), "subregion-" + prefix);
|
||||
}
|
||||
|
||||
public KMap<ChunkPosition, AtomicSliverMap> getLoadedChunks()
|
||||
|
@ -9,4 +9,6 @@ public interface IObjectPlacer
|
||||
public void set(int x, int y, int z, BlockData d);
|
||||
|
||||
public BlockData get(int x, int y, int z);
|
||||
|
||||
public boolean isPreventingDecay();
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
|
||||
public class InvertedBiomeGrid implements BiomeGrid
|
||||
{
|
||||
private BiomeGrid grid;
|
||||
|
||||
public InvertedBiomeGrid(BiomeGrid real)
|
||||
{
|
||||
this.grid = real;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Biome getBiome(int arg0, int arg1)
|
||||
{
|
||||
return grid.getBiome(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int arg0, int arg1, int arg2)
|
||||
{
|
||||
return grid.getBiome(arg0, 255 - arg1, arg2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void setBiome(int arg0, int arg1, Biome arg2)
|
||||
{
|
||||
grid.setBiome(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int arg0, int arg1, int arg2, Biome arg3)
|
||||
{
|
||||
grid.setBiome(arg0, 255 - arg1, arg2, arg3);
|
||||
}
|
||||
}
|
@ -50,7 +50,6 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
x = x % 2 == 0 ? x + 1 : x;
|
||||
z = z % 2 == 0 ? z + 1 : z;
|
||||
parallaxSize = new ChunkPosition(x, z);
|
||||
Iris.info("Parallax View Distance: " + x + "x" + z);
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
@ -68,6 +67,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
Iris.hotloader.track(j);
|
||||
Iris.info("Loading " + resourceTypeName + ": " + j.getPath());
|
||||
t.setLoadKey(name);
|
||||
parallaxSize = null;
|
||||
lock.unlock();
|
||||
return t;
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class PhasicBiomeStorage
|
||||
{
|
||||
private static final int e = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
|
||||
private static final int f = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2;
|
||||
public static final int a;
|
||||
public static final int b;
|
||||
public static final int c;
|
||||
private final Biome[] g;
|
||||
|
||||
static
|
||||
{
|
||||
a = 1 << e + e + f;
|
||||
b = (1 << e) - 1;
|
||||
c = (1 << f) - 1;
|
||||
}
|
||||
|
||||
public PhasicBiomeStorage(Biome[] abiomebase)
|
||||
{
|
||||
this.g = abiomebase;
|
||||
}
|
||||
|
||||
public PhasicBiomeStorage()
|
||||
{
|
||||
this(new Biome[a]);
|
||||
}
|
||||
|
||||
public static int clamp(int var0, int var1, int var2)
|
||||
{
|
||||
if(var0 < var1)
|
||||
{
|
||||
return var1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return var0 > var2 ? var2 : var0;
|
||||
}
|
||||
}
|
||||
|
||||
public Biome getBiome(int i, int j, int k)
|
||||
{
|
||||
int l = i & b;
|
||||
int i1 = clamp(j, 0, c);
|
||||
int j1 = k & b;
|
||||
return this.g[i1 << e + e | j1 << e | l];
|
||||
}
|
||||
|
||||
public void setBiome(int i, int j, int k, Biome biome)
|
||||
{
|
||||
int l = i & b;
|
||||
int i1 = clamp(j, 0, c);
|
||||
int j1 = k & b;
|
||||
this.g[i1 << e + e | j1 << e | l] = biome;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user