9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-25 10:09:14 +00:00

1.14+ support

This commit is contained in:
Daniel Mills
2020-09-04 07:33:00 -04:00
parent 4340d584c1
commit fbc02881d7
22 changed files with 305 additions and 413 deletions

View File

@@ -47,6 +47,9 @@ public class Iris extends MortarPlugin
public static IrisBoardManager board;
public static MultiverseCoreLink linkMultiverseCore;
private static IrisLock lock = new IrisLock("Iris");
public static boolean customModels = doesSupportCustomModels();
public static boolean awareEntities = doesSupportAwareness();
public static boolean biome3d = doesSupport3DBiomes();
public static boolean lowMemoryMode = false;
@Permission
@@ -61,6 +64,27 @@ public class Iris extends MortarPlugin
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4 * 1000 * 1000 * 1000;
}
private static boolean doesSupport3DBiomes()
{
int v = Integer.valueOf(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15;
}
private static boolean doesSupportCustomModels()
{
int v = Integer.valueOf(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 14;
}
private static boolean doesSupportAwareness()
{
int v = Integer.valueOf(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15;
}
@Override
public void start()
{
@@ -108,7 +132,7 @@ public class Iris extends MortarPlugin
{
if(i.getGenerator() instanceof IrisChunkGenerator)
{
((IrisChunkGenerator) i).close();
((IrisChunkGenerator) i.getGenerator()).close();
}
}
for(GroupedExecutor i : executors)
@@ -304,7 +328,8 @@ public class Iris extends MortarPlugin
padd + C.GRAY + " "+C.DARK_GRAY+"@@@"+C.GRAY+"@@@@@@@@@@@@@@"
};
//@done
Iris.info(Bukkit.getVersion());
Iris.info(Bukkit.getBukkitVersion() + " bk");
for(int i = 0; i < info.length; i++)
{
splash[i] += info[i];
@@ -314,7 +339,22 @@ public class Iris extends MortarPlugin
if(lowMemoryMode)
{
Iris.warn("Low Memory mode Activated! For better performance, allocate 4gb or more to this server.");
Iris.verbose("* Low Memory mode Activated! For better performance, allocate 4gb or more to this server.");
}
if(!biome3d)
{
Iris.verbose("* This version of minecraft does not support 3D biomes (1.15 and up). Iris will generate as normal, but biome colors will not vary underground & in the sky.");
}
if(!customModels)
{
Iris.verbose("* This version of minecraft does not support custom model data in loot items (1.14 and up). Iris will generate as normal, but loot will not have custom models.");
}
if(!doesSupportAwareness())
{
Iris.verbose("* This version of minecraft does not support entity awareness.");
}
}
}

View File

@@ -359,7 +359,14 @@ public class ProjectManager
}
});
World world = Bukkit.createWorld(new WorldCreator("iris/" + UUID.randomUUID()).seed(1337).generator(gx).generateStructures(false).type(WorldType.NORMAL).environment(d.getEnvironment()));
//@builder
World world = Bukkit.createWorld(new WorldCreator("iris/" + UUID.randomUUID())
.seed(1337)
.generator(gx)
.generateStructures(d.isVanillaStructures())
.type(WorldType.NORMAL)
.environment(d.getEnvironment()));
//@done
Iris.linkMultiverseCore.removeFromConfig(world);
done.set(true);
@@ -409,6 +416,7 @@ public class ProjectManager
Iris.info("Packaging Dimension " + dimension.getName() + " " + (obfuscate ? "(Obfuscated)" : ""));
KSet<IrisRegion> regions = new KSet<>();
KSet<IrisBiome> biomes = new KSet<>();
KSet<IrisEntity> entities = new KSet<>();
KSet<IrisStructure> structures = new KSet<>();
KSet<IrisGenerator> generators = new KSet<>();
KSet<IrisLootTable> loot = new KSet<>();
@@ -422,6 +430,11 @@ public class ProjectManager
biomes.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(Iris.globaldata.getLootLoader().load(i))));
structures.forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(Iris.globaldata.getLootLoader().load(i))));
structures.forEach((b) -> b.getTiles().forEach((r) -> r.getLoot().getTables().forEach((i) -> loot.add(Iris.globaldata.getLootLoader().load(i)))));
structures.forEach((r) -> r.getEntitySpawns().forEach((sp) -> entities.add(Iris.globaldata.getEntityLoader().load(sp.getEntity()))));
structures.forEach((s) -> s.getTiles().forEach((r) -> r.getEntitySpawns().forEach((sp) -> entities.add(Iris.globaldata.getEntityLoader().load(sp.getEntity())))));
biomes.forEach((r) -> r.getEntitySpawns().forEach((sp) -> entities.add(Iris.globaldata.getEntityLoader().load(sp.getEntity()))));
regions.forEach((r) -> r.getEntitySpawns().forEach((sp) -> entities.add(Iris.globaldata.getEntityLoader().load(sp.getEntity()))));
dimension.getEntitySpawns().forEach((sp) -> entities.add(Iris.globaldata.getEntityLoader().load(sp.getEntity())));
KMap<String, String> renameObjects = new KMap<>();
String a = "";
@@ -621,6 +634,13 @@ public class ProjectManager
b.append(IO.hash(a));
}
for(IrisEntity i : entities)
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a);
b.append(IO.hash(a));
}
for(IrisLootTable i : loot)
{
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);

View File

@@ -333,6 +333,11 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
public void close()
{
if(!isDev())
{
return;
}
getNoLoot().clear();
getNoLoot().trimToSize();
HandlerList.unregisterAll(this);

View File

@@ -52,7 +52,7 @@ public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
if(!folder.exists())
{
Iris.error("Missing World iris/dimensions folder!");
Iris.error("Missing World iris/dimensions folder! (" + folder.getAbsolutePath() + ")");
setDimensionName("error-missing-dimension");
return;
}

View File

@@ -26,6 +26,7 @@ import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.IObjectPlacer;
import com.volmit.iris.util.IrisLock;
import com.volmit.iris.util.IrisStructureResult;
import com.volmit.iris.util.J;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.PrecisionStopwatch;
@@ -62,6 +63,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
setParallaxMap(new AtomicWorldData(world));
setGlText(new GenLayerText(this, rng.nextParallelRNG(32485)));
setGlUpdate(null);
J.a(() -> getDimension().getParallaxSize(this));
}
protected void onClose()

View File

@@ -138,6 +138,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
IrisRegion region = sampleRegion(rx, rz);
IrisBiome biome = sampleTrueBiome(rx, rz, noise);
IrisBiome landBiome = null;
Biome onlyBiome = Iris.biome3d ? null : biome.getGroundBiome(getMasterRandom(), rz, getDimension().getFluidHeight(), rx);
if(biome == null)
{
@@ -204,17 +205,27 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
if(!biomeAssigned && biomeMap != null)
{
biomeAssigned = true;
sliver.set(k, biome.getGroundBiome(getMasterRandom(), rz, k, rx));
biomeMap.setBiome(x, z, biome);
for(int kv = max; kv < biomeMax; kv++)
if(Iris.biome3d)
{
Biome skyBiome = biome.getSkyBiome(getMasterRandom(), rz, kv, rx);
sliver.set(kv, skyBiome);
sliver.set(k, biome.getGroundBiome(getMasterRandom(), rz, k, rx));
for(int kv = max; kv < biomeMax; kv++)
{
Biome skyBiome = biome.getSkyBiome(getMasterRandom(), rz, kv, rx);
sliver.set(kv, skyBiome);
}
}
else
{
sliver.set(getFluidHeight(), onlyBiome);
}
biomeMap.setBiome(x, z, biome);
}
if(k <= Math.max(height, fluidHeight))
if(Iris.biome3d && k <= Math.max(height, fluidHeight))
{
sliver.set(k, biome.getGroundBiome(getMasterRandom(), rz, k, rx));
}
@@ -278,10 +289,13 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
{
for(CaveResult i : caveResults)
{
for(int j = i.getFloor(); j <= i.getCeiling(); j++)
if(Iris.biome3d)
{
sliver.set(j, caveBiome);
sliver.set(j, caveBiome.getGroundBiome(getMasterRandom(), rz, j, rx));
for(int j = i.getFloor(); j <= i.getCeiling(); j++)
{
sliver.set(j, caveBiome);
sliver.set(j, caveBiome.getGroundBiome(getMasterRandom(), rz, j, rx));
}
}
KList<BlockData> floor = caveBiome.generateLayers(wx, wz, rockRandom, i.getFloor() - 2, i.getFloor() - 2);

View File

@@ -29,6 +29,7 @@ public class AtomicSliver
public static boolean forgetful = false;
private transient KMap<Integer, IrisBiome> truebiome;
private transient KMap<Integer, Biome> biome;
private transient Biome onlyBiome;
private transient IrisLock lock = new IrisLock("Sliver");
private transient int highestBiome = 0;
private transient long last = M.ms();
@@ -41,6 +42,7 @@ public class AtomicSliver
public AtomicSliver(int x, int z)
{
onlyBiome = null;
this.x = x;
this.z = z;
blockUpdates = new KSet<>();
@@ -164,9 +166,9 @@ public class AtomicSliver
public Biome getBiome(int h)
{
if(forgetful)
if(!Iris.biome3d)
{
return Biome.THE_VOID;
return onlyBiome != null ? onlyBiome : Biome.THE_VOID;
}
last = M.ms();
@@ -182,7 +184,17 @@ public class AtomicSliver
public void set(int h, Biome d)
{
lock.lock();
biome.put(h, d);
if(Iris.biome3d)
{
biome.put(h, d);
}
else
{
onlyBiome = d;
}
modified = true;
highestBiome = h > highestBiome ? h : highestBiome;
lock.unlock();
@@ -220,13 +232,18 @@ public class AtomicSliver
lock.unlock();
}
@SuppressWarnings("deprecation")
public void write(BiomeGrid d)
{
if(forgetful)
lock.lock();
if(!Iris.biome3d)
{
d.setBiome(x, z, onlyBiome);
lock.unlock();
return;
}
lock.lock();
for(int i = 0; i <= highestBiome; i++)
{
if(biome.get(i) != null)
@@ -234,15 +251,12 @@ public class AtomicSliver
d.setBiome(x, i, z, biome.get(i));
}
}
lock.unlock();
}
public void write(HeightMap height)
{
if(forgetful)
{
return;
}
lock.lock();
height.setHeight(x, z, highestBlock);
lock.unlock();
@@ -250,10 +264,6 @@ public class AtomicSliver
public void read(DataInputStream din) throws IOException
{
if(forgetful)
{
return;
}
lock.lock();
this.block = new KMap<Integer, BlockData>();

View File

@@ -62,6 +62,7 @@ public class GenLayerUpdate extends BlockPopulator
}
p.end();
gen.getMetrics().getUpdate().put(p.getMilliseconds());
}
public void update(Chunk c, int x, int y, int z, int rx, int rz, RNG rng)

View File

@@ -637,8 +637,6 @@ public class IrisDimension extends IrisRegistrant
IrisLock t = new IrisLock("t");
Iris.verbose("Checking sizes for " + Form.f(objects.size()) + " referenced objects.");
int tc = g.getThreads();
g.changeThreadCount(64);
for(String i : objects)
{
g.getAccelerant().queue("tx-psize", () ->
@@ -661,7 +659,6 @@ public class IrisDimension extends IrisRegistrant
}
g.getAccelerant().waitFor("tx-psize");
g.changeThreadCount(tc);
int x = Math.max(xg.get(), Math.max(yg.get(), zg.get()));
int z = x;

View File

@@ -5,7 +5,6 @@ import java.lang.reflect.Field;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.meta.ItemMeta;
import com.volmit.iris.Iris;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.MaxNumber;
@@ -47,9 +46,17 @@ public class IrisEnchantment
public void apply(RNG rng, ItemMeta meta)
{
if(rng.nextDouble() < chance)
try
{
meta.addEnchant(getEnchant(), getLevel(rng), true);
if(rng.nextDouble() < chance)
{
meta.addEnchant(getEnchant(), getLevel(rng), true);
}
}
catch(Throwable e)
{
}
}
@@ -71,8 +78,6 @@ public class IrisEnchantment
}
}
Iris.warn("Can't find enchantment type: " + getEnchantment());
return null;
}

View File

@@ -244,7 +244,7 @@ public class IrisEntity extends IrisRegistrant
}
}
if(e instanceof Mob)
if(Iris.awareEntities && e instanceof Mob)
{
Mob m = (Mob) e;
m.setAware(isAware());

View File

@@ -40,8 +40,8 @@ public class IrisEntitySpawn
@Desc("The 1 in RARITY chance for this entity to spawn")
private int rarity = 1;
private AtomicCache<RNG> rng = new AtomicCache<>();
private AtomicCache<IrisEntity> ent = new AtomicCache<>();
private transient AtomicCache<RNG> rng = new AtomicCache<>();
private transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
public Entity on(IrisChunkGenerator g, Location at, EntityType t, EntitySpawnEvent ee)
{

View File

@@ -69,7 +69,7 @@ public class IrisLoot
private double maxDurability = 1;
@DontObfuscate
@Desc("Define a custom model identifier")
@Desc("Define a custom model identifier 1.14+ only")
private Integer customModel = null;
@DontObfuscate
@@ -123,98 +123,8 @@ public class IrisLoot
public ItemStack get(boolean debug, RNG rng)
{
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
try
{
Damageable d = (Damageable) m;
int max = getType().getMaxDurability();
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
}
for(IrisEnchantment i : getEnchantments())
{
i.apply(rng, m);
}
for(IrisAttributeModifier i : getAttributes())
{
i.apply(rng, m);
}
m.setCustomModelData(getCustomModel());
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for(ItemFlag i : getItemFlags())
{
m.addItemFlags(i);
}
KList<String> lore = new KList<>();
getLore().forEach((i) ->
{
String mf = C.translateAlternateColorCodes('&', i);
if(mf.length() > 24)
{
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
{
lore.add(g.trim());
}
}
else
{
lore.add(mf);
}
});
if(debug)
{
if(lore.isNotEmpty())
{
lore.add(C.GRAY + "--------------------");
}
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
}
m.setLore(lore);
if(getLeatherColor() != null && m instanceof LeatherArmorMeta)
{
Color c = Color.decode(getLeatherColor());
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
}
if(getDyeColor() != null && m instanceof Colorable)
{
((Colorable) m).setColor(getDyeColor());
}
is.setItemMeta(m);
return is;
}
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
{
if(debug)
{
chance.reset();
}
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
{
if(getType() == null)
{
Iris.warn("Cant find item type " + type);
return null;
}
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
@@ -235,7 +145,11 @@ public class IrisLoot
i.apply(rng, m);
}
m.setCustomModelData(getCustomModel());
if(Iris.customModels)
{
m.setCustomModelData(getCustomModel());
}
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
@@ -272,15 +186,127 @@ public class IrisLoot
lore.add(C.GRAY + "--------------------");
}
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
}
m.setLore(lore);
if(getLeatherColor() != null && m instanceof LeatherArmorMeta)
{
Color c = Color.decode(getLeatherColor());
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
}
if(getDyeColor() != null && m instanceof Colorable)
{
((Colorable) m).setColor(getDyeColor());
}
is.setItemMeta(m);
return is;
}
catch(Throwable e)
{
}
return new ItemStack(Material.AIR);
}
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
{
if(debug)
{
chance.reset();
}
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
{
if(getType() == null)
{
Iris.warn("Cant find item type " + type);
return null;
}
try
{
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
{
Damageable d = (Damageable) m;
int max = getType().getMaxDurability();
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
}
for(IrisEnchantment i : getEnchantments())
{
i.apply(rng, m);
}
for(IrisAttributeModifier i : getAttributes())
{
i.apply(rng, m);
}
if(Iris.customModels)
{
m.setCustomModelData(getCustomModel());
}
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for(ItemFlag i : getItemFlags())
{
m.addItemFlags(i);
}
KList<String> lore = new KList<>();
getLore().forEach((i) ->
{
String mf = C.translateAlternateColorCodes('&', i);
if(mf.length() > 24)
{
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
{
lore.add(g.trim());
}
}
else
{
lore.add(mf);
}
});
if(debug)
{
if(lore.isNotEmpty())
{
lore.add(C.GRAY + "--------------------");
}
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
}
m.setLore(lore);
is.setItemMeta(m);
return is;
}
catch(Throwable e)
{
}
}
return null;
}
}

View File

@@ -1,75 +0,0 @@
package com.volmit.iris.util;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
public class BiomeStorage
{
private static final int e;
private static final int f;
public static final int a;
public static final int b;
public static final int c;
private final Biome[] g;
static
{
e = (int) Math.round(Math.log(16.0) / Math.log(2.0)) - 2;
f = (int) Math.round(Math.log(256.0) / Math.log(2.0)) - 2;
a = 1 << BiomeStorage.e + BiomeStorage.e + BiomeStorage.f;
b = (1 << BiomeStorage.e) - 1;
c = (1 << BiomeStorage.f) - 1;
}
public BiomeStorage(final Biome[] aBiome)
{
this.g = aBiome;
}
public BiomeStorage()
{
this(new Biome[BiomeStorage.a]);
}
public BiomeStorage b()
{
return new BiomeStorage(this.g.clone());
}
public void inject(BiomeGrid grid)
{
for(int i = 0; i < 256; i++)
{
for(int j = 0; j < 16; j++)
{
for(int k = 0; k < 16; k++)
{
Biome b = getBiome(j, i, k);
if(b == null || b.equals(Biome.THE_VOID))
{
continue;
}
grid.setBiome(j, i, k, b);
}
}
}
}
public Biome getBiome(final int i, final int j, final int k)
{
final int l = i & BiomeStorage.b;
final int i2 = MathHelper.clamp(j, 0, BiomeStorage.c);
final int j2 = k & BiomeStorage.b;
return this.g[i2 << BiomeStorage.e + BiomeStorage.e | j2 << BiomeStorage.e | l];
}
public void setBiome(final int i, final int j, final int k, final Biome biome)
{
final int l = i & BiomeStorage.b;
final int i2 = MathHelper.clamp(j, 0, BiomeStorage.c);
final int j2 = k & BiomeStorage.b;
this.g[i2 << BiomeStorage.e + BiomeStorage.e | j2 << BiomeStorage.e | l] = biome;
}
}

View File

@@ -3,6 +3,8 @@ package com.volmit.iris.util;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import com.volmit.iris.Iris;
public class InvertedBiomeGrid implements BiomeGrid
{
private BiomeGrid grid;
@@ -22,6 +24,11 @@ public class InvertedBiomeGrid implements BiomeGrid
@Override
public Biome getBiome(int arg0, int arg1, int arg2)
{
if(!Iris.biome3d)
{
return getBiome(arg0, arg2);
}
return grid.getBiome(arg0, 255 - arg1, arg2);
}
@@ -35,6 +42,12 @@ public class InvertedBiomeGrid implements BiomeGrid
@Override
public void setBiome(int arg0, int arg1, int arg2, Biome arg3)
{
if(!Iris.biome3d)
{
setBiome(arg0, arg2, arg3);
return;
}
grid.setBiome(arg0, 255 - arg1, arg2, arg3);
}
}

View File

@@ -1,58 +0,0 @@
package com.volmit.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;
}
}

View File

@@ -1,137 +0,0 @@
package com.volmit.iris.util;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.bukkit.material.MaterialData;
@SuppressWarnings("deprecation")
public class PreemptiveChunk implements BiomeGrid, ChunkData
{
private ChunkData c;
private BiomeStorage b;
public PreemptiveChunk(ChunkData c)
{
this.c = c;
this.b = new BiomeStorage();
}
public void inject(ChunkData ic, BiomeGrid ib)
{
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 256; j++)
{
for(int k = 0; k < 16; k++)
{
if(!getType(i, j, k).equals(Material.AIR))
{
ic.setBlock(i, j, k, getBlockData(i, j, k));
}
}
}
}
b.inject(ib);
}
@Override
public Biome getBiome(int arg0, int arg1)
{
throw new UnsupportedOperationException("Not Supported. Use x y z");
}
@Override
public Biome getBiome(int x, int y, int z)
{
return b.getBiome(x, y, z);
}
@Override
public void setBiome(int x, int z, Biome arg2)
{
for(int i = 0; i < 256; i++)
{
b.setBiome(x, i, z, arg2);
}
}
@Override
public void setBiome(int arg0, int arg1, int arg2, Biome arg3)
{
b.setBiome(arg0, arg1, arg2, arg3);
}
@Override
public BlockData getBlockData(int arg0, int arg1, int arg2)
{
return c.getBlockData(arg0, arg1, arg2);
}
@Deprecated
@Override
public byte getData(int arg0, int arg1, int arg2)
{
return c.getData(arg0, arg1, arg2);
}
@Override
public int getMaxHeight()
{
return c.getMaxHeight();
}
@Override
public Material getType(int arg0, int arg1, int arg2)
{
return c.getType(arg0, arg1, arg2);
}
@Deprecated
@Override
public MaterialData getTypeAndData(int arg0, int arg1, int arg2)
{
return c.getTypeAndData(arg0, arg1, arg2);
}
@Override
public void setBlock(int arg0, int arg1, int arg2, Material arg3)
{
c.setBlock(arg0, arg1, arg2, arg3);
}
@Deprecated
@Override
public void setBlock(int arg0, int arg1, int arg2, MaterialData arg3)
{
c.setBlock(arg0, arg1, arg2, arg3);
}
@Override
public void setBlock(int arg0, int arg1, int arg2, BlockData arg3)
{
c.setBlock(arg0, arg1, arg2, arg3);
}
@Override
public void setRegion(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, Material arg6)
{
c.setRegion(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}
@Deprecated
@Override
public void setRegion(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, MaterialData arg6)
{
c.setRegion(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}
@Override
public void setRegion(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, BlockData arg6)
{
c.setRegion(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}
}

View File

@@ -157,7 +157,16 @@ public class PregenJob implements Listener
if(chunkSpiraler.hasNext())
{
chunkSpiraler.next();
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.YELLOW);
try
{
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.YELLOW);
}
catch(Throwable e)
{
}
if(isChunkWithin(chunkX, chunkZ))
{