This commit is contained in:
cyberpwn
2022-01-12 01:47:38 -05:00
parent 8c00499e76
commit 2dde426df6
463 changed files with 11845 additions and 10159 deletions

View File

@@ -50,24 +50,24 @@ public class HeadlessWorld {
this.dimension = dimension;
this.studio = studio;
world = IrisWorld.builder()
.environment(dimension.getEnvironment())
.worldFolder(new File(worldName))
.seed(seed)
.maxHeight(256)
.minHeight(0)
.name(worldName)
.build();
.environment(dimension.getEnvironment())
.worldFolder(new File(worldName))
.seed(seed)
.maxHeight(256)
.minHeight(0)
.name(worldName)
.build();
world.worldFolder().mkdirs();
new File(world.worldFolder(), "region").mkdirs();
if (!studio && !new File(world.worldFolder(), "iris/pack").exists()) {
if(!studio && !new File(world.worldFolder(), "iris/pack").exists()) {
Iris.service(StudioSVC.class).installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
}
}
public static HeadlessWorld from(World world) {
return new HeadlessWorld(world.getName(), IrisToolbelt.access(world)
.getEngine().getTarget().getDimension(), world.getSeed());
.getEngine().getTarget().getDimension(), world.getSeed());
}
public static HeadlessWorld from(String name, String dimension, long seed) {
@@ -78,13 +78,13 @@ public class HeadlessWorld {
public HeadlessGenerator generate() {
Engine e = null;
if (getWorld().tryGetRealWorld()) {
if (IrisToolbelt.isIrisWorld(getWorld().realWorld())) {
if(getWorld().tryGetRealWorld()) {
if(IrisToolbelt.isIrisWorld(getWorld().realWorld())) {
e = IrisToolbelt.access(getWorld().realWorld()).getEngine();
}
}
if (e != null) {
if(e != null) {
Iris.info("Using Existing Engine " + getWorld().name() + " for Headless Pregeneration.");
}
@@ -93,11 +93,11 @@ public class HeadlessWorld {
public World load() {
World w = new WorldCreator(worldName)
.environment(dimension.getEnvironment())
.seed(world.getRawWorldSeed())
.generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(),
dimension.getLoadKey()))
.createWorld();
.environment(dimension.getEnvironment())
.seed(world.getRawWorldSeed())
.generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(),
dimension.getLoadKey()))
.createWorld();
world.realWorld(w);
return w;
}

View File

@@ -18,54 +18,46 @@
package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.EnginePanic;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.reflect.V;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.arithmetic.FittedStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.*;
import java.util.List;
public interface IRare {
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) {
return ProceduralStream.of((x, z) -> pick(possibilities, noise.get(x, z)),
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
new Interpolated<T>() {
@Override
public double toDouble(T t) {
return 0;
}
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
new Interpolated<T>() {
@Override
public double toDouble(T t) {
return 0;
}
@Override
public T fromDouble(double d) {
return null;
}
});
@Override
public T fromDouble(double d) {
return null;
}
});
}
static <T extends IRare> T pickSlowly(List<T> possibilities, double noiseValue) {
if (possibilities.isEmpty()) {
if(possibilities.isEmpty()) {
return null;
}
if (possibilities.size() == 1) {
if(possibilities.size() == 1) {
return possibilities.get(0);
}
KList<T> rarityTypes = new KList<>();
int totalRarity = 0;
for (T i : possibilities) {
for(T i : possibilities) {
totalRarity += IRare.get(i);
}
for (T i : possibilities) {
for(T i : possibilities) {
rarityTypes.addMultiple(i, totalRarity / IRare.get(i));
}
@@ -73,23 +65,23 @@ public interface IRare {
}
static <T extends IRare> T pick(List<T> possibilities, double noiseValue) {
if (possibilities.isEmpty()) {
if(possibilities.isEmpty()) {
return null;
}
if (possibilities.size() == 1) {
if(possibilities.size() == 1) {
return possibilities.get(0);
}
int totalWeight = 0; // This is he baseline
int buffer = 0;
for (T i : possibilities) { // Im adding all of the rarity together
for(T i : possibilities) { // Im adding all of the rarity together
totalWeight += i.getRarity();
}
double threshold = totalWeight * (possibilities.size() - 1) * noiseValue;
for (T i : possibilities) {
for(T i : possibilities) {
buffer += totalWeight - i.getRarity();
if (buffer >= threshold) {
if(buffer >= threshold) {
return i;
}
}
@@ -98,18 +90,18 @@ public interface IRare {
static <T extends IRare> T pickOld(List<T> possibilities, double noiseValue) {
if (possibilities.isEmpty()) {
if(possibilities.isEmpty()) {
return null;
}
if (possibilities.size() == 1) {
if(possibilities.size() == 1) {
return possibilities.get(0);
}
double completeWeight = 0.0;
double highestWeight = 0.0;
for (T item : possibilities) {
for(T item : possibilities) {
double weight = Math.max(item.getRarity(), 1);
highestWeight = Math.max(highestWeight, weight);
completeWeight += weight;
@@ -118,10 +110,10 @@ public interface IRare {
double r = noiseValue * completeWeight;
double countWeight = 0.0;
for (T item : possibilities) {
for(T item : possibilities) {
double weight = Math.max(highestWeight - Math.max(item.getRarity(), 1), 1);
countWeight += weight;
if (countWeight >= r) {
if(countWeight >= r) {
return item;
}
}

View File

@@ -65,13 +65,13 @@ public class IrisAttributeModifier {
private double chance = 1;
public void apply(RNG rng, ItemMeta meta) {
if (rng.nextDouble() < getChance()) {
if(rng.nextDouble() < getChance()) {
meta.addAttributeModifier(getAttribute(), new AttributeModifier(getName(), getAmount(rng), getOperation()));
}
}
public void apply(RNG rng, Attributable meta) {
if (rng.nextDouble() < getChance()) {
if(rng.nextDouble() < getChance()) {
meta.getAttribute(getAttribute()).addModifier(new AttributeModifier(getName(), getAmount(rng), getOperation()));
}
}

View File

@@ -78,19 +78,19 @@ public class IrisAxisRotationClamp {
}
public double getRadians(int rng) {
if (forceLock) {
if(forceLock) {
return Math.toRadians(Math.ceil(Math.abs((max % 360D))));
}
if (isUnlimited()) {
if (interval < 1) {
if(isUnlimited()) {
if(interval < 1) {
interval = 1;
}
return Math.toRadians((interval * (Math.ceil(Math.abs((rng % 360D) / interval)))) % 360D);
}
if (min == max && min != 0) {
if(min == max && min != 0) {
return Math.toRadians(max);
}

View File

@@ -183,14 +183,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
if(ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
for(IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
b = i.generate(x, y, z, rng, data);
if(b != null) {
return b;
}
}
@@ -210,7 +210,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KMap<String, Integer> l = new KMap<>();
for (IrisBiomeGeneratorLink i : getGenerators()) {
for(IrisBiomeGeneratorLink i : getGenerators()) {
l.put(i.getGenerator(), i.getMax());
}
@@ -225,7 +225,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KMap<String, Integer> l = new KMap<>();
for (IrisBiomeGeneratorLink i : getGenerators()) {
for(IrisBiomeGeneratorLink i : getGenerators()) {
l.put(i.getGenerator(), i.getMin());
}
@@ -240,7 +240,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KMap<String, IrisBiomeGeneratorLink> l = new KMap<>();
for (IrisBiomeGeneratorLink i : getGenerators()) {
for(IrisBiomeGeneratorLink i : getGenerators()) {
l.put(i.getGenerator(), i);
}
@@ -253,7 +253,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
IrisBiome biome = data.getBiomeLoader().load(getCarvingBiome());
if (biome == null) {
if(biome == null) {
biome = this;
}
@@ -266,8 +266,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KList<IrisObjectPlacement> o = getObjects().copy();
for (IrisObjectPlacement i : o.copy()) {
if (!i.getCarvingSupport().supportsSurface()) {
for(IrisObjectPlacement i : o.copy()) {
if(!i.getCarvingSupport().supportsSurface()) {
o.remove(i);
}
}
@@ -281,8 +281,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KList<IrisObjectPlacement> o = getObjects().copy();
for (IrisObjectPlacement i : o.copy()) {
if (!i.getCarvingSupport().supportsCarving()) {
for(IrisObjectPlacement i : o.copy()) {
if(!i.getCarvingSupport().supportsCarving()) {
o.remove(i);
}
}
@@ -294,7 +294,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public double getHeight(Engine xg, double x, double z, long seed) {
double height = 0;
for (IrisBiomeGeneratorLink i : generators) {
for(IrisBiomeGeneratorLink i : generators) {
height += i.getHeight(xg, x, z, seed);
}
@@ -303,7 +303,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public CNG getBiomeGenerator(RNG random) {
return biomeGenerator.aquire(() ->
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader()));
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader()));
}
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
@@ -311,54 +311,54 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public KList<BlockData> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
if (isLockLayers()) {
if(isLockLayers()) {
return generateLockedLayers(wx, wz, random, maxDepth, height, rdata, complex);
}
KList<BlockData> data = new KList<>();
if (maxDepth <= 0) {
if(maxDepth <= 0) {
return data;
}
for (int i = 0; i < layers.size(); i++) {
for(int i = 0; i < layers.size(); i++) {
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
IrisSlopeClip sc = getLayers().get(i).getSlopeCondition();
if (!sc.isDefault()) {
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
if(!sc.isDefault()) {
if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
d = 0;
}
}
if (d <= 0) {
if(d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
for(int j = 0; j < d; j++) {
if(data.size() >= maxDepth) {
break;
}
try {
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata));
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
}
if (data.size() >= maxDepth) {
if(data.size() >= maxDepth) {
break;
}
if (dim.isExplodeBiomePalettes()) {
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
if(dim.isExplodeBiomePalettes()) {
for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
data.add(BARRIER);
if (data.size() >= maxDepth) {
if(data.size() >= maxDepth) {
break;
}
}
@@ -371,40 +371,40 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public KList<BlockData> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
KList<BlockData> data = new KList<>();
if (maxDepth <= 0) {
if(maxDepth <= 0) {
return data;
}
for (int i = 0; i < caveCeilingLayers.size(); i++) {
for(int i = 0; i < caveCeilingLayers.size(); i++) {
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
double d = hgen.fit(caveCeilingLayers.get(i).getMinHeight(), caveCeilingLayers.get(i).getMaxHeight(), wx / caveCeilingLayers.get(i).getZoom(), wz / caveCeilingLayers.get(i).getZoom());
if (d <= 0) {
if(d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
for(int j = 0; j < d; j++) {
if(data.size() >= maxDepth) {
break;
}
try {
data.add(getCaveCeilingLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / caveCeilingLayers.get(i).getZoom(), j, (wz - j) / caveCeilingLayers.get(i).getZoom(), rdata));
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
}
if (data.size() >= maxDepth) {
if(data.size() >= maxDepth) {
break;
}
if (dim.isExplodeBiomePalettes()) {
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
if(dim.isExplodeBiomePalettes()) {
for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
data.add(BARRIER);
if (data.size() >= maxDepth) {
if(data.size() >= maxDepth) {
break;
}
}
@@ -418,41 +418,41 @@ public class IrisBiome extends IrisRegistrant implements IRare {
KList<BlockData> data = new KList<>();
KList<BlockData> real = new KList<>();
int maxDepth = Math.min(maxDepthf, getLockLayersMax());
if (maxDepth <= 0) {
if(maxDepth <= 0) {
return data;
}
for (int i = 0; i < layers.size(); i++) {
for(int i = 0; i < layers.size(); i++) {
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
IrisSlopeClip sc = getLayers().get(i).getSlopeCondition();
if (!sc.isDefault()) {
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
if(!sc.isDefault()) {
if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
d = 0;
}
}
if (d <= 0) {
if(d <= 0) {
continue;
}
for (int j = 0; j < d; j++) {
for(int j = 0; j < d; j++) {
try {
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata));
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
}
}
if (data.isEmpty()) {
if(data.isEmpty()) {
return real;
}
for (int i = 0; i < maxDepth; i++) {
for(int i = 0; i < maxDepth; i++) {
int offset = (255 - height) - i;
int index = offset % data.size();
real.add(data.get(Math.max(index, 0)));
@@ -466,7 +466,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : getGenerators()) {
for(IrisBiomeGeneratorLink i : getGenerators()) {
maxHeight += i.getMax();
}
@@ -479,14 +479,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
int maxHeight = 0;
for (IrisBiomeGeneratorLink i : getGenerators()) {
for(IrisBiomeGeneratorLink i : getGenerators()) {
maxHeight += i.getMax();
}
int gg = 0;
for (IrisObjectPlacement i : getObjects()) {
for (IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
for(IrisObjectPlacement i : getObjects()) {
for(IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
gg = Math.max(gg, j.getH());
}
}
@@ -503,28 +503,28 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
KList<BlockData> data = new KList<>();
for (int i = 0; i < seaLayers.size(); i++) {
for(int i = 0; i < seaLayers.size(); i++) {
CNG hgen = getLayerSeaHeightGenerators(random, rdata).get(i);
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom());
if (d < 0) {
if(d < 0) {
continue;
}
for (int j = 0; j < d; j++) {
if (data.size() >= maxDepth) {
for(int j = 0; j < d; j++) {
if(data.size() >= maxDepth) {
break;
}
try {
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom(), rdata));
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
}
if (data.size() >= maxDepth) {
if(data.size() >= maxDepth) {
break;
}
}
@@ -539,7 +539,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
int m = 7235;
for (IrisBiomePaletteLayer i : getLayers()) {
for(IrisBiomePaletteLayer i : getLayers()) {
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), rdata));
}
@@ -554,7 +554,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
int m = 7735;
for (IrisBiomePaletteLayer i : getSeaLayers()) {
for(IrisBiomePaletteLayer i : getSeaLayers()) {
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), data));
}
@@ -563,7 +563,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public boolean isLand() {
if (inferredType == null) {
if(inferredType == null) {
return true;
}
@@ -571,7 +571,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public boolean isSea() {
if (inferredType == null) {
if(inferredType == null) {
return false;
}
return inferredType.equals(InferredType.SEA);
@@ -583,18 +583,18 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isShore() {
if (inferredType == null) {
if(inferredType == null) {
return false;
}
return inferredType.equals(InferredType.SHORE);
}
public Biome getSkyBiome(RNG rng, double x, double y, double z) {
if (biomeSkyScatter.size() == 1) {
if(biomeSkyScatter.size() == 1) {
return biomeSkyScatter.get(0);
}
if (biomeSkyScatter.isEmpty()) {
if(biomeSkyScatter.isEmpty()) {
return getGroundBiome(rng, x, y, z);
}
@@ -602,7 +602,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public IrisBiomeCustom getCustomBiome(RNG rng, double x, double y, double z) {
if (customDerivitives.size() == 1) {
if(customDerivitives.size() == 1) {
return customDerivitives.get(0);
}
@@ -614,7 +614,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
{
KList<IrisBiome> realChildren = new KList<>();
for (String i : getChildren()) {
for(String i : getChildren()) {
realChildren.add(g.getData().getBiomeLoader().load(i));
}
@@ -627,8 +627,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
m.addAll(getChildren());
limit--;
if (limit > 0) {
for (String i : getChildren()) {
if(limit > 0) {
for(String i : getChildren()) {
IrisBiome b = g.getData().getBiomeLoader().load(i);
m.addAll(b.getAllChildren(g, limit));
}
@@ -639,11 +639,11 @@ public class IrisBiome extends IrisRegistrant implements IRare {
//TODO: Test
public Biome getGroundBiome(RNG rng, double x, double y, double z) {
if (biomeScatter.isEmpty()) {
if(biomeScatter.isEmpty()) {
return getDerivative();
}
if (biomeScatter.size() == 1) {
if(biomeScatter.size() == 1) {
return biomeScatter.get(0);
}
@@ -651,7 +651,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public BlockData getSurfaceBlock(int x, int z, RNG rng, IrisData idm) {
if (getLayers().isEmpty()) {
if(getLayers().isEmpty()) {
return B.get("AIR");
}
@@ -659,12 +659,12 @@ public class IrisBiome extends IrisRegistrant implements IRare {
}
public Color getColor(Engine engine, RenderType type) {
switch (type) {
switch(type) {
case BIOME, HEIGHT, CAVE_LAND, REGION, BIOME_SEA, BIOME_LAND -> {
return this.cacheColor.aquire(() -> {
if (this.color == null) {
if(this.color == null) {
RandomColor randomColor = new RandomColor(getName().hashCode());
if (this.getVanillaDerivative() == null) {
if(this.getVanillaDerivative() == null) {
Iris.warn("No vanilla biome found for " + getName());
return new Color(randomColor.randomColor());
}
@@ -678,7 +678,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
try {
return Color.decode(this.color);
} catch (NumberFormatException e) {
} catch(NumberFormatException e) {
Iris.warn("Could not parse color \"" + this.color + "\" for biome " + getName());
return new Color(new RandomColor(getName().hashCode()).randomColor());
}
@@ -688,7 +688,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return cacheColorObjectDensity.aquire(() -> {
double density = 0;
for (IrisObjectPlacement i : getObjects()) {
for(IrisObjectPlacement i : getObjects()) {
density += i.getDensity() * i.getChance();
}
@@ -699,7 +699,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return cacheColorDecoratorLoad.aquire(() -> {
double density = 0;
for (IrisDecorator i : getDecorators()) {
for(IrisDecorator i : getDecorators()) {
density += i.getChance() * Math.min(1, i.getStackMax()) * 256;
}

View File

@@ -102,7 +102,7 @@ public class IrisBiomeCustom {
effects.put("water_color", parseColor(getWaterColor()));
effects.put("water_fog_color", parseColor(getWaterFogColor()));
if (ambientParticle != null) {
if(ambientParticle != null) {
JSONObject particle = new JSONObject();
JSONObject po = new JSONObject();
po.put("type", ambientParticle.getParticle().name().toLowerCase());
@@ -111,11 +111,11 @@ public class IrisBiomeCustom {
effects.put("particle", particle);
}
if (!getGrassColor().isEmpty()) {
if(!getGrassColor().isEmpty()) {
effects.put("grass_color", parseColor(getGrassColor()));
}
if (!getFoliageColor().isEmpty()) {
if(!getFoliageColor().isEmpty()) {
effects.put("foliage_color", parseColor(getFoliageColor()));
}
@@ -135,15 +135,15 @@ public class IrisBiomeCustom {
j.put("carvers", new JSONObject());
j.put("features", new JSONArray());
if (spawnRarity > 0) {
if(spawnRarity > 0) {
j.put("creature_spawn_probability", spawnRarity);
}
if (getSpawns() != null && getSpawns().isNotEmpty()) {
if(getSpawns() != null && getSpawns().isNotEmpty()) {
JSONObject spawners = new JSONObject();
KMap<IrisBiomeCustomSpawnType, JSONArray> groups = new KMap<>();
for (IrisBiomeCustomSpawn i : getSpawns()) {
for(IrisBiomeCustomSpawn i : getSpawns()) {
JSONArray g = groups.computeIfAbsent(i.getGroup(), (k) -> new JSONArray());
JSONObject o = new JSONObject();
o.put("type", "minecraft:" + i.getType().name().toLowerCase());
@@ -153,7 +153,7 @@ public class IrisBiomeCustom {
g.put(o);
}
for (IrisBiomeCustomSpawnType i : groups.k()) {
for(IrisBiomeCustomSpawnType i : groups.k()) {
spawners.put(i.name().toLowerCase(Locale.ROOT), groups.get(i));
}
@@ -167,7 +167,7 @@ public class IrisBiomeCustom {
String v = (c.startsWith("#") ? c : "#" + c).trim();
try {
return Color.decode(v).getRGB();
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
Iris.error("Error Parsing '''color''', (" + c + ")");
}

View File

@@ -63,7 +63,7 @@ public class IrisBiomeGeneratorLink {
{
IrisGenerator gen = g.getData().getGeneratorLoader().load(getGenerator());
if (gen == null) {
if(gen == null) {
gen = new IrisGenerator();
}

View File

@@ -75,11 +75,11 @@ public class IrisBiomePaletteLayer {
}
public BlockData get(RNG rng, double x, double y, double z, IrisData data) {
if (getBlockData(data).isEmpty()) {
if(getBlockData(data).isEmpty()) {
return null;
}
if (getBlockData(data).size() == 1) {
if(getBlockData(data).size() == 1) {
return getBlockData(data).get(0);
}
@@ -104,10 +104,10 @@ public class IrisBiomePaletteLayer {
return blockData.aquire(() ->
{
KList<BlockData> blockData = new KList<>();
for (IrisBlockData ix : palette) {
for(IrisBlockData ix : palette) {
BlockData bx = ix.getBlockData(data);
if (bx != null) {
for (int i = 0; i < ix.getWeight(); i++) {
if(bx != null) {
for(int i = 0; i < ix.getWeight(); i++) {
blockData.add(bx);
}
}

View File

@@ -74,18 +74,18 @@ public class IrisBlockData extends IrisRegistrant {
IrisBlockData b = new IrisBlockData();
String v = j.toLowerCase().trim();
if (v.contains("[")) {
if(v.contains("[")) {
KList<String> props = new KList<>();
String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
b.setBlock(v.split("\\Q[\\E")[0]);
if (rp.contains(",")) {
if(rp.contains(",")) {
props.add(rp.split("\\Q,\\E"));
} else {
props.add(rp);
}
for (String i : props) {
for(String i : props) {
Object kg = filter(i.split("\\Q=\\E")[1]);
b.data.put(i.split("\\Q=\\E")[0], kg);
}
@@ -97,23 +97,23 @@ public class IrisBlockData extends IrisRegistrant {
}
private static Object filter(String string) {
if (string.equals("true")) {
if(string.equals("true")) {
return true;
}
if (string.equals("false")) {
if(string.equals("false")) {
return false;
}
try {
return Integer.parseInt(string);
} catch (Throwable ignored) {
} catch(Throwable ignored) {
// Checks
}
try {
return Double.valueOf(string).intValue();
} catch (Throwable ignored) {
} catch(Throwable ignored) {
// Checks
}
@@ -121,13 +121,13 @@ public class IrisBlockData extends IrisRegistrant {
}
public String computeProperties(KMap<String, Object> data) {
if (data.isEmpty()) {
if(data.isEmpty()) {
return "";
}
KList<String> r = new KList<>();
for (Map.Entry<String, Object> entry : data.entrySet()) {
for(Map.Entry<String, Object> entry : data.entrySet()) {
r.add(entry.getKey() + "=" + filter(entry.getValue().toString()));
}
@@ -145,37 +145,37 @@ public class IrisBlockData extends IrisRegistrant {
IrisBlockData customData = data.getBlockLoader().load(getBlock(), false);
if (customData != null) {
if(customData != null) {
b = customData.getBlockData(data);
if (b != null) {
if(b != null) {
b = b.clone();
String st = b.getAsString(true);
if (st.contains("[")) {
if(st.contains("[")) {
st = st.split("\\Q[\\E")[0];
}
KMap<String, Object> cdata = customData.getData().copy();
for (String i : getData().keySet()) {
for(String i : getData().keySet()) {
cdata.put(i, getData().get(i));
}
String sx = keyify(st) + computeProperties(cdata);
if (debug) {
if(debug) {
Iris.debug("Block Data used " + sx + " (CUSTOM)");
}
BlockData bx = B.get(sx);
if (bx != null) {
if(bx != null) {
return bx;
}
if (b != null) {
if(b != null) {
return b;
}
}
@@ -184,15 +184,15 @@ public class IrisBlockData extends IrisRegistrant {
String ss = keyify(getBlock()) + computeProperties();
b = B.get(ss);
if (debug) {
if(debug) {
Iris.debug("Block Data used " + ss);
}
if (b != null) {
if(b != null) {
return b;
}
if (backup != null) {
if(backup != null) {
return backup.getBlockData(data);
}
@@ -201,7 +201,7 @@ public class IrisBlockData extends IrisRegistrant {
}
private String keyify(String dat) {
if (dat.contains(":")) {
if(dat.contains(":")) {
return dat;
}

View File

@@ -60,10 +60,10 @@ public class IrisBlockDrops {
{
KList<BlockData> b = new KList<>();
for (IrisBlockData i : getBlocks()) {
for(IrisBlockData i : getBlocks()) {
BlockData dd = i.getBlockData(rdata);
if (dd != null) {
if(dd != null) {
b.add(dd);
}
}
@@ -71,8 +71,8 @@ public class IrisBlockDrops {
return b.removeDuplicates();
});
for (BlockData i : list) {
if (exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) {
for(BlockData i : list) {
if(exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) {
return true;
}
}
@@ -81,8 +81,8 @@ public class IrisBlockDrops {
}
public void fillDrops(boolean debug, KList<ItemStack> d) {
for (IrisLoot i : getDrops()) {
if (RNG.r.i(1, i.getRarity()) == i.getRarity()) {
for(IrisLoot i : getDrops()) {
if(RNG.r.i(1, i.getRarity()) == i.getRarity()) {
d.add(i.get(debug, RNG.r));
}
}

View File

@@ -67,37 +67,37 @@ public class IrisCarving {
@BlockCoordinates
public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
if (caves.isNotEmpty()) {
for (IrisCavePlacer i : caves) {
if(caves.isNotEmpty()) {
for(IrisCavePlacer i : caves) {
i.generateCave(writer, rng, engine, x, y, z, waterHint);
}
}
if (ravines.isNotEmpty()) {
for (IrisRavinePlacer i : ravines) {
if(ravines.isNotEmpty()) {
for(IrisRavinePlacer i : ravines) {
i.generateRavine(writer, rng, engine, x, y, z, waterHint);
}
}
if (spheres.isNotEmpty()) {
for (IrisSphere i : spheres) {
if (rng.nextInt(i.getRarity()) == 0) {
if(spheres.isNotEmpty()) {
for(IrisSphere i : spheres) {
if(rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
}
if (elipsoids.isNotEmpty()) {
for (IrisElipsoid i : elipsoids) {
if (rng.nextInt(i.getRarity()) == 0) {
if(elipsoids.isNotEmpty()) {
for(IrisElipsoid i : elipsoids) {
if(rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
}
if (pyramids.isNotEmpty()) {
for (IrisPyramid i : pyramids) {
if (rng.nextInt(i.getRarity()) == 0) {
if(pyramids.isNotEmpty()) {
for(IrisPyramid i : pyramids) {
if(rng.nextInt(i.getRarity()) == 0) {
i.generate(rng, engine, writer, x, y, z);
}
}
@@ -107,23 +107,23 @@ public class IrisCarving {
public int getMaxRange(IrisData data) {
int max = 0;
for (IrisCavePlacer i : caves) {
for(IrisCavePlacer i : caves) {
max = Math.max(max, i.getSize(data));
}
for (IrisRavinePlacer i : ravines) {
for(IrisRavinePlacer i : ravines) {
max = Math.max(max, i.getSize(data));
}
if (elipsoids.isNotEmpty()) {
if(elipsoids.isNotEmpty()) {
max = (int) Math.max(elipsoids.stream().mapToDouble(IrisElipsoid::maxSize).max().getAsDouble(), max);
}
if (spheres.isNotEmpty()) {
if(spheres.isNotEmpty()) {
max = (int) Math.max(spheres.stream().mapToDouble(IrisSphere::maxSize).max().getAsDouble(), max);
}
if (pyramids.isNotEmpty()) {
if(pyramids.isNotEmpty()) {
max = (int) Math.max(pyramids.stream().mapToDouble(IrisPyramid::maxSize).max().getAsDouble(), max);
}

View File

@@ -76,12 +76,12 @@ public class IrisCave extends IrisRegistrant {
});
int highestWater = Math.max(waterHint, -1);
if (highestWater == -1) {
for (IrisPosition i : points) {
if(highestWater == -1) {
for(IrisPosition i : points) {
double yy = i.getY() + girth;
int th = engine.getHeight(x, z, true);
if (yy > th && th < engine.getDimension().getFluidHeight()) {
if(yy > th && th < engine.getDimension().getFluidHeight()) {
highestWater = Math.max(highestWater, (int) yy);
break;
}
@@ -91,7 +91,7 @@ public class IrisCave extends IrisRegistrant {
int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight());
for (IrisPosition i : points) {
for(IrisPosition i : points) {
fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h);
}
@@ -99,8 +99,8 @@ public class IrisCave extends IrisRegistrant {
MatterCavern w = new MatterCavern(true, customBiome, (byte) 1);
writer.setLineConsumer(points,
girth, true,
(xf, yf, zf) -> yf <= h ? w : c);
girth, true,
(xf, yf, zf) -> yf <= h ? w : c);
}
@Override

View File

@@ -68,24 +68,24 @@ public class IrisCavePlacer implements IRare {
}
public void generateCave(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
if (fail.get()) {
if(fail.get()) {
return;
}
if (rng.nextInt(rarity) != 0) {
if(rng.nextInt(rarity) != 0) {
return;
}
IrisData data = engine.getData();
IrisCave cave = getRealCave(data);
if (cave == null) {
if(cave == null) {
Iris.warn("Unable to locate cave for generation!");
fail.set(true);
return;
}
if (y == -1) {
if(y == -1) {
int h = (int) caveStartHeight.get(rng, x, z, data);
int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9);
y = Math.min(h, ma);
@@ -93,7 +93,7 @@ public class IrisCavePlacer implements IRare {
try {
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
} catch (Throwable e) {
} catch(Throwable e) {
e.printStackTrace();
fail.set(true);
}
@@ -102,7 +102,7 @@ public class IrisCavePlacer implements IRare {
public int getSize(IrisData data) {
IrisCave cave = getRealCave(data);
if (cave != null) {
if(cave != null) {
return cave.getMaxSize(data);
}

View File

@@ -55,7 +55,7 @@ public class IrisColor {
private int blue = 0;
public static Color blend(Color... c) {
if (c == null || c.length <= 0) {
if(c == null || c.length <= 0) {
return null;
}
float ratio = 1f / ((float) c.length);
@@ -65,7 +65,7 @@ public class IrisColor {
int g = 0;
int b = 0;
for (Color value : c) {
for(Color value : c) {
int rgb = value.getRGB();
int a1 = (rgb >> 24 & 0xff);
int r1 = ((rgb & 0xff0000) >> 16);
@@ -82,11 +82,11 @@ public class IrisColor {
public Color getColor() {
return color.aquire(() -> {
if (hex != null) {
if(hex != null) {
String v = (hex.startsWith("#") ? hex : "#" + hex).trim();
try {
return Color.decode(v);
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -101,11 +101,11 @@ public class IrisColor {
}
public int getAsRGB() {
if (hex != null) {
if(hex != null) {
try {
if (hex.startsWith("#")) hex = hex.substring(1);
if(hex.startsWith("#")) hex = hex.substring(1);
return Integer.parseInt(hex, 16);
} catch (NumberFormatException e) {
} catch(NumberFormatException e) {
return 0;
}
}

View File

@@ -61,17 +61,17 @@ public class IrisCommand {
}
public void run(Location at) {
if (!isValid(at.getWorld())) {
if(!isValid(at.getWorld())) {
return;
}
for (String command : commands) {
for(String command : commands) {
command = (command.startsWith("/") ? command.replaceFirst("/", "") : command)
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
.replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY()))
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
.replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY()))
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
final String finalCommand = command;
if (repeat) {
if(repeat) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay, repeatDelay);
} else {
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay);

View File

@@ -70,18 +70,18 @@ public class IrisCommandRegistry {
private boolean commandAllRandomLocations = true;
public void run(Player p) {
if (rawCommands.isNotEmpty()) {
if(rawCommands.isNotEmpty()) {
Location part = p.getLocation().clone().add(
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
for (IrisCommand rawCommand : rawCommands) {
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
for(IrisCommand rawCommand : rawCommands) {
rawCommand.run(part);
if (commandAllRandomLocations) {
if(commandAllRandomLocations) {
part = p.getLocation().clone().add(
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
}
}
}

View File

@@ -48,11 +48,11 @@ public class IrisCompat {
J.attemptAsync(() -> IO.writeAll(new File(f.getParentFile(), "compat.default.json"), defa));
if (!f.exists()) {
if(!f.exists()) {
J.a(() -> {
try {
IO.writeAll(f, defa);
} catch (IOException e) {
} catch(IOException e) {
Iris.error("Failed to writeNodeData to compat file");
Iris.reportError(e);
}
@@ -63,14 +63,14 @@ public class IrisCompat {
try {
IrisCompat rea = new Gson().fromJson(IO.readAll(f), IrisCompat.class);
for (IrisCompatabilityBlockFilter i : rea.getBlockFilters()) {
for(IrisCompatabilityBlockFilter i : rea.getBlockFilters()) {
def.getBlockFilters().add(i);
}
for (IrisCompatabilityItemFilter i : rea.getItemFilters()) {
for(IrisCompatabilityItemFilter i : rea.getItemFilters()) {
def.getItemFilters().add(i);
}
} catch (Throwable e) {
} catch(Throwable e) {
e.printStackTrace();
Iris.reportError(e);
}
@@ -264,21 +264,21 @@ public class IrisCompat {
BlockData tx = B.getOrNull(buf);
if (tx != null) {
if(tx != null) {
return tx;
}
searching:
while (true) {
if (err-- <= 0) {
while(true) {
if(err-- <= 0) {
return B.get("STONE");
}
for (IrisCompatabilityBlockFilter i : blockFilters) {
if (i.getWhen().equalsIgnoreCase(buf)) {
for(IrisCompatabilityBlockFilter i : blockFilters) {
if(i.getWhen().equalsIgnoreCase(buf)) {
BlockData b = i.getReplace();
if (b != null) {
if(b != null) {
return b;
}
@@ -296,28 +296,28 @@ public class IrisCompat {
int err = 16;
Material txf = B.getMaterialOrNull(buf);
if (txf != null) {
if(txf != null) {
return txf;
}
int nomore = 64;
searching:
while (true) {
if (nomore < 0) {
while(true) {
if(nomore < 0) {
return B.getMaterial("STONE");
}
nomore--;
if (err-- <= 0) {
if(err-- <= 0) {
break;
}
for (IrisCompatabilityItemFilter i : itemFilters) {
if (i.getWhen().equalsIgnoreCase(buf)) {
for(IrisCompatabilityItemFilter i : itemFilters) {
if(i.getWhen().equalsIgnoreCase(buf)) {
Material b = i.getReplace();
if (b != null) {
if(b != null) {
return b;
}
@@ -332,28 +332,28 @@ public class IrisCompat {
buf = n;
BlockData tx = B.getOrNull(buf);
if (tx != null) {
if(tx != null) {
return tx.getMaterial();
}
nomore = 64;
searching:
while (true) {
if (nomore < 0) {
while(true) {
if(nomore < 0) {
return B.getMaterial("STONE");
}
nomore--;
if (err-- <= 0) {
if(err-- <= 0) {
return B.getMaterial("STONE");
}
for (IrisCompatabilityBlockFilter i : blockFilters) {
if (i.getWhen().equalsIgnoreCase(buf)) {
for(IrisCompatabilityBlockFilter i : blockFilters) {
if(i.getWhen().equalsIgnoreCase(buf)) {
BlockData b = i.getReplace();
if (b != null) {
if(b != null) {
return b.getMaterial();
}

View File

@@ -59,7 +59,7 @@ public class IrisCompatabilityBlockFilter {
{
BlockData b = B.getOrNull(supplement);
if (b == null) {
if(b == null) {
return null;
}

View File

@@ -56,7 +56,7 @@ public class IrisCompatabilityItemFilter {
{
Material b = B.getMaterialOrNull(supplement);
if (b == null) {
if(b == null) {
return null;
}

View File

@@ -75,7 +75,7 @@ public class IrisDecorator {
private int stackMax = 1;
@DependsOn({"stackMin", "stackMax"})
@Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" +
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
private boolean scaleStack = false;
@Required
@MinNumber(0)
@@ -97,19 +97,19 @@ public class IrisDecorator {
private double topThreshold = 1.0;
public int getHeight(RNG rng, double x, double z, IrisData data) {
if (stackMin == stackMax) {
if(stackMin == stackMax) {
return stackMin;
}
return getHeightGenerator(rng, data)
.fit(stackMin, stackMax,
x / heightVariance.getZoom(),
z / heightVariance.getZoom()) + 1;
.fit(stackMin, stackMax,
x / heightVariance.getZoom(),
z / heightVariance.getZoom()) + 1;
}
public CNG getHeightGenerator(RNG rng, IrisData data) {
return heightGenerator.aquire(() ->
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
}
public CNG getGenerator(RNG rng, IrisData data) {
@@ -118,9 +118,9 @@ public class IrisDecorator {
public CNG getVarianceGenerator(RNG rng, IrisData data) {
return varianceGenerator.aquire(() ->
variance.create(
rng.nextParallelRNG(getBlockData(data).size()), data)
.scale(1D / variance.getZoom()));
variance.create(
rng.nextParallelRNG(getBlockData(data).size()), data)
.scale(1D / variance.getZoom()));
}
public KList<IrisBlockData> add(String b) {
@@ -129,7 +129,7 @@ public class IrisDecorator {
}
public BlockData getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) {
if (getBlockData(data).isEmpty()) {
if(getBlockData(data).isEmpty()) {
Iris.warn("Empty Block Data for " + b.getName());
return null;
}
@@ -137,8 +137,8 @@ public class IrisDecorator {
double xx = x / style.getZoom();
double zz = z / style.getZoom();
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) {
if (getBlockData(data).size() == 1) {
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) {
if(getBlockData(data).size() == 1) {
return getBlockData(data).get(0);
}
@@ -149,7 +149,7 @@ public class IrisDecorator {
}
public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
if (getBlockData(data).isEmpty()) {
if(getBlockData(data).isEmpty()) {
Iris.warn("Empty Block Data for " + b.getName());
return null;
}
@@ -158,13 +158,13 @@ public class IrisDecorator {
double yy = y;
double zz = z;
if (!getVarianceGenerator(rng, data).isStatic()) {
if(!getVarianceGenerator(rng, data).isStatic()) {
xx = x / style.getZoom();
yy = y / style.getZoom();
zz = z / style.getZoom();
}
if (getBlockData(data).size() == 1) {
if(getBlockData(data).size() == 1) {
return getBlockData(data).get(0);
}
@@ -172,15 +172,15 @@ public class IrisDecorator {
}
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
if (getBlockDataTops(data).isEmpty()) {
if(getBlockDataTops(data).isEmpty()) {
return getBlockData100(b, rng, x, y, z, data);
}
double xx = x / style.getZoom();
double zz = z / style.getZoom();
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
if (getBlockData(data).size() == 1) {
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
if(getBlockData(data).size() == 1) {
return getBlockDataTops(data).get(0);
}
@@ -194,10 +194,10 @@ public class IrisDecorator {
return blockData.aquire(() ->
{
KList<BlockData> blockData = new KList<>();
for (IrisBlockData i : palette) {
for(IrisBlockData i : palette) {
BlockData bx = i.getBlockData(data);
if (bx != null) {
for (int n = 0; n < i.getWeight(); n++) {
if(bx != null) {
for(int n = 0; n < i.getWeight(); n++) {
blockData.add(bx);
}
}
@@ -211,10 +211,10 @@ public class IrisDecorator {
return blockDataTops.aquire(() ->
{
KList<BlockData> blockDataTops = new KList<>();
for (IrisBlockData i : topPalette) {
for(IrisBlockData i : topPalette) {
BlockData bx = i.getBlockData(data);
if (bx != null) {
for (int n = 0; n < i.getWeight(); n++) {
if(bx != null) {
for(int n = 0; n < i.getWeight(); n++) {
blockDataTops.add(bx);
}
}

View File

@@ -89,7 +89,7 @@ public class IrisDepositGenerator {
RNG rngv = rng.nextParallelRNG(3957778);
KList<IrisObject> objectsf = new KList<>();
for (int i = 0; i < varience; i++) {
for(int i = 0; i < varience; i++) {
objectsf.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598), rdata));
}
@@ -108,10 +108,10 @@ public class IrisDepositGenerator {
int w = dim / 2;
IrisObject o = new IrisObject(dim, dim, dim);
if (s == 1) {
if(s == 1) {
o.getBlocks().put(o.getCenter(), nextBlock(rngv, rdata));
} else {
while (s > 0) {
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();
@@ -131,10 +131,10 @@ public class IrisDepositGenerator {
{
KList<BlockData> blockData = new KList<>();
for (IrisBlockData ix : palette) {
for(IrisBlockData ix : palette) {
BlockData bx = ix.getBlockData(rdata);
if (bx != null) {
if(bx != null) {
blockData.add(bx);
}
}

View File

@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
@@ -230,14 +229,14 @@ public class IrisDimension extends IrisRegistrant {
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
if(ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
for(IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
b = i.generate(x, y, z, rng, data);
if(b != null) {
return b;
}
}
@@ -250,11 +249,11 @@ public class IrisDimension extends IrisRegistrant {
int jump = strongholdJumpDistance;
RNG rng = new RNG((seed * 223) + 12945);
for (int i = 0; i < maxStrongholds + 1; i++) {
for(int i = 0; i < maxStrongholds + 1; i++) {
int m = i + 1;
pos.add(new Position2(
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)),
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D))
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)),
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D))
));
}
@@ -300,7 +299,7 @@ public class IrisDimension extends IrisRegistrant {
public KList<IrisRegion> getAllRegions(DataProvider g) {
KList<IrisRegion> r = new KList<>();
for (String i : getRegions()) {
for(String i : getRegions()) {
r.add(g.getData().getRegionLoader().load(i));
}
@@ -310,7 +309,7 @@ public class IrisDimension extends IrisRegistrant {
public KList<IrisRegion> getAllAnyRegions() {
KList<IrisRegion> r = new KList<>();
for (String i : getRegions()) {
for(String i : getRegions()) {
r.add(IrisData.loadAnyRegion(i));
}
@@ -324,8 +323,8 @@ public class IrisDimension extends IrisRegistrant {
public KList<IrisBiome> getAllAnyBiomes() {
KList<IrisBiome> r = new KList<>();
for (IrisRegion i : getAllAnyRegions()) {
if (i == null) {
for(IrisRegion i : getAllAnyRegions()) {
if(i == null) {
continue;
}
@@ -336,7 +335,7 @@ public class IrisDimension extends IrisRegistrant {
}
public IrisGeneratorStyle getBiomeStyle(InferredType type) {
switch (type) {
switch(type) {
case CAVE:
return caveBiomeStyle;
case LAND:
@@ -358,14 +357,14 @@ public class IrisDimension extends IrisRegistrant {
IO.delete(new File(datapacks, "iris/data/" + getLoadKey().toLowerCase()));
for (IrisBiome i : getAllBiomes(data)) {
if (i.isCustom()) {
for(IrisBiome i : getAllBiomes(data)) {
if(i.isCustom()) {
write = true;
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
for(IrisBiomeCustom j : i.getCustomDerivitives()) {
File output = new File(datapacks, "iris/data/" + getLoadKey().toLowerCase() + "/worldgen/biome/" + j.getId() + ".json");
if (!output.exists()) {
if(!output.exists()) {
changed = true;
}
@@ -373,7 +372,7 @@ public class IrisDimension extends IrisRegistrant {
output.getParentFile().mkdirs();
try {
IO.writeAll(output, j.generateJson());
} catch (IOException e) {
} catch(IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -381,18 +380,18 @@ public class IrisDimension extends IrisRegistrant {
}
}
if (write) {
if(write) {
File mcm = new File(datapacks, "iris/pack.mcmeta");
try {
IO.writeAll(mcm, """
{
"pack": {
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
"pack_format": 7
}
{
"pack": {
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
"pack_format": 7
}
""");
} catch (IOException e) {
}
""");
} catch(IOException e) {
Iris.reportError(e);
e.printStackTrace();
}

View File

@@ -67,7 +67,7 @@ public enum IrisDirection {
}
public static IrisDirection getDirection(BlockFace f) {
return switch (f) {
return switch(f) {
case DOWN -> DOWN_NEGATIVE_Y;
case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X;
case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z;
@@ -79,9 +79,9 @@ public enum IrisDirection {
}
public static IrisDirection fromJigsawBlock(String direction) {
for (IrisDirection i : IrisDirection.values()) {
if (i.name().toLowerCase().split("\\Q_\\E")[0]
.equals(direction.split("\\Q_\\E")[0])) {
for(IrisDirection i : IrisDirection.values()) {
if(i.name().toLowerCase().split("\\Q_\\E")[0]
.equals(direction.split("\\Q_\\E")[0])) {
return i;
}
}
@@ -90,7 +90,7 @@ public enum IrisDirection {
}
public static IrisDirection getDirection(Jigsaw.Orientation orientation) {
return switch (orientation) {
return switch(orientation) {
case DOWN_EAST, UP_EAST, EAST_UP -> EAST_POSITIVE_X;
case DOWN_NORTH, UP_NORTH, NORTH_UP -> NORTH_NEGATIVE_Z;
case DOWN_SOUTH, UP_SOUTH, SOUTH_UP -> SOUTH_POSITIVE_Z;
@@ -103,11 +103,11 @@ public enum IrisDirection {
double m = Double.MAX_VALUE;
IrisDirection s = null;
for (IrisDirection i : values()) {
for(IrisDirection i : values()) {
Vector x = i.toVector();
double g = x.distance(v);
if (g < m) {
if(g < m) {
m = g;
s = i;
}
@@ -120,11 +120,11 @@ public enum IrisDirection {
double m = Double.MAX_VALUE;
IrisDirection s = null;
for (IrisDirection i : d) {
for(IrisDirection i : d) {
Vector x = i.toVector();
double g = x.distance(v);
if (g < m) {
if(g < m) {
m = g;
s = i;
}
@@ -137,11 +137,11 @@ public enum IrisDirection {
double m = Double.MAX_VALUE;
IrisDirection s = null;
for (IrisDirection i : d) {
for(IrisDirection i : d) {
Vector x = i.toVector();
double g = x.distance(v);
if (g < m) {
if(g < m) {
m = g;
s = i;
}
@@ -157,8 +157,8 @@ public enum IrisDirection {
public static IrisDirection getDirection(Vector v) {
Vector k = VectorMath.triNormalize(v.clone().normalize());
for (IrisDirection i : udnews()) {
if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
for(IrisDirection i : udnews()) {
if(i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
return i;
}
}
@@ -174,24 +174,25 @@ public enum IrisDirection {
* Get the directional value from the given byte from common directional blocks
* (MUST BE BETWEEN 0 and 5 INCLUSIVE)
*
* @param b the byte
* @param b
* the byte
* @return the direction or null if the byte is outside of the inclusive range
* 0-5
*/
public static IrisDirection fromByte(byte b) {
if (b > 5 || b < 0) {
if(b > 5 || b < 0) {
return null;
}
if (b == 0) {
if(b == 0) {
return DOWN_NEGATIVE_Y;
} else if (b == 1) {
} else if(b == 1) {
return UP_POSITIVE_Y;
} else if (b == 2) {
} else if(b == 2) {
return NORTH_NEGATIVE_Z;
} else if (b == 3) {
} else if(b == 3) {
return SOUTH_POSITIVE_Z;
} else if (b == 4) {
} else if(b == 4) {
return WEST_NEGATIVE_X;
} else {
return EAST_POSITIVE_X;
@@ -199,25 +200,25 @@ public enum IrisDirection {
}
public static void calculatePermutations() {
if (permute != null) {
if(permute != null) {
return;
}
permute = new KMap<>();
for (IrisDirection i : udnews()) {
for (IrisDirection j : udnews()) {
for(IrisDirection i : udnews()) {
for(IrisDirection j : udnews()) {
GBiset<IrisDirection, IrisDirection> b = new GBiset<>(i, j);
if (i.equals(j)) {
if(i.equals(j)) {
permute.put(b, new DOP("DIRECT") {
@Override
public Vector op(Vector v) {
return v;
}
});
} else if (i.reverse().equals(j)) {
if (i.isVertical()) {
} else if(i.reverse().equals(j)) {
if(i.isVertical()) {
permute.put(b, new DOP("R180CCZ") {
@Override
public Vector op(Vector v) {
@@ -232,42 +233,42 @@ public enum IrisDirection {
}
});
}
} else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CX") {
@Override
public Vector op(Vector v) {
return VectorMath.rotate90CX(v);
}
});
} else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CCX") {
@Override
public Vector op(Vector v) {
return VectorMath.rotate90CCX(v);
}
});
} else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CY") {
@Override
public Vector op(Vector v) {
return VectorMath.rotate90CY(v);
}
});
} else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CCY") {
@Override
public Vector op(Vector v) {
return VectorMath.rotate90CCY(v);
}
});
} else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CZ") {
@Override
public Vector op(Vector v) {
return VectorMath.rotate90CZ(v);
}
});
} else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
} else if(getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
permute.put(b, new DOP("R90CCZ") {
@Override
public Vector op(Vector v) {
@@ -288,7 +289,7 @@ public enum IrisDirection {
@Override
public String toString() {
return switch (this) {
return switch(this) {
case DOWN_NEGATIVE_Y -> "Down";
case EAST_POSITIVE_X -> "East";
case NORTH_NEGATIVE_Z -> "North";
@@ -308,7 +309,7 @@ public enum IrisDirection {
}
public boolean isCrooked(IrisDirection to) {
if (equals(to.reverse())) {
if(equals(to.reverse())) {
return false;
}
@@ -318,9 +319,9 @@ public enum IrisDirection {
public Vector angle(Vector initial, IrisDirection d) {
calculatePermutations();
for (Map.Entry<GBiset<IrisDirection, IrisDirection>, DOP> entry : permute.entrySet()) {
for(Map.Entry<GBiset<IrisDirection, IrisDirection>, DOP> entry : permute.entrySet()) {
GBiset<IrisDirection, IrisDirection> i = entry.getKey();
if (i.getA().equals(this) && i.getB().equals(d)) {
if(i.getA().equals(this) && i.getB().equals(d)) {
return entry.getValue().op(initial);
}
}
@@ -329,7 +330,7 @@ public enum IrisDirection {
}
public IrisDirection reverse() {
switch (this) {
switch(this) {
case DOWN_NEGATIVE_Y:
return UP_POSITIVE_Y;
case EAST_POSITIVE_X:
@@ -371,7 +372,7 @@ public enum IrisDirection {
* @return the byte value
*/
public byte byteValue() {
switch (this) {
switch(this) {
case DOWN_NEGATIVE_Y:
return 0;
case EAST_POSITIVE_X:
@@ -392,7 +393,7 @@ public enum IrisDirection {
}
public BlockFace getFace() {
return switch (this) {
return switch(this) {
case DOWN_NEGATIVE_Y -> BlockFace.DOWN;
case EAST_POSITIVE_X -> BlockFace.EAST;
case NORTH_NEGATIVE_Z -> BlockFace.NORTH;
@@ -404,7 +405,7 @@ public enum IrisDirection {
}
public Axis getAxis() {
return switch (this) {
return switch(this) {
case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y;
case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X;
case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z;

View File

@@ -65,15 +65,15 @@ public class IrisDuration {
public long toMilliseconds() {
return getMilliseconds()
+ TimeUnit.SECONDS.toMillis(getSeconds())
+ TimeUnit.MINUTES.toMillis(getMinutes())
+ TimeUnit.HOURS.toMillis(getHours())
+ TimeUnit.DAYS.toMillis(getDays())
+ (getMinecraftTicks() * 50L)
+ (getMinecraftHours() * 50000L)
+ (getMinecraftWeeks() * 50000L)
+ (getMinecraftDays() * 24000L)
+ (getMinecraftWeeks() * 168000L)
+ (getMinecraftLunarCycles() * 192000L);
+ TimeUnit.SECONDS.toMillis(getSeconds())
+ TimeUnit.MINUTES.toMillis(getMinutes())
+ TimeUnit.HOURS.toMillis(getHours())
+ TimeUnit.DAYS.toMillis(getDays())
+ (getMinecraftTicks() * 50L)
+ (getMinecraftHours() * 50000L)
+ (getMinecraftWeeks() * 50000L)
+ (getMinecraftDays() * 24000L)
+ (getMinecraftWeeks() * 168000L)
+ (getMinecraftLunarCycles() * 192000L);
}
}

View File

@@ -166,19 +166,19 @@ public class IrisEffect {
{
PotionEffectType t = PotionEffectType.LUCK;
if (getPotionEffect().isEmpty()) {
if(getPotionEffect().isEmpty()) {
return t;
}
try {
for (PotionEffectType i : PotionEffectType.values()) {
if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
for(PotionEffectType i : PotionEffectType.values()) {
if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
t = i;
return t;
}
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -190,50 +190,50 @@ public class IrisEffect {
}
public void apply(Player p, Engine g) {
if (!canTick()) {
if(!canTick()) {
return;
}
if (RNG.r.nextInt(chance) != 0) {
if(RNG.r.nextInt(chance) != 0) {
return;
}
if (sound != null) {
if(sound != null) {
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
J.s(() -> p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)));
}
if (particleEffect != null) {
if(particleEffect != null) {
Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1);
part.add(RNG.r.d(), 0, RNG.r.d());
if (extra != 0) {
if(extra != 0) {
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra));
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra));
} else {
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
}
}
if (commandRegistry != null) {
if(commandRegistry != null) {
commandRegistry.run(p);
}
if (potionStrength > -1) {
if (p.hasPotionEffect(getRealType())) {
if(potionStrength > -1) {
if(p.hasPotionEffect(getRealType())) {
PotionEffect e = p.getPotionEffect(getRealType());
if (e.getAmplifier() > getPotionStrength()) {
if(e.getAmplifier() > getPotionStrength()) {
return;
}
@@ -241,45 +241,45 @@ public class IrisEffect {
}
J.s(() -> p.addPotionEffect(new PotionEffect(getRealType(),
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
Math.max(potionTicksMax, potionTicksMin)),
getPotionStrength(),
true, false, false)));
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
Math.max(potionTicksMax, potionTicksMin)),
getPotionStrength(),
true, false, false)));
}
}
public void apply(Entity p) {
if (!canTick()) {
if(!canTick()) {
return;
}
if (RNG.r.nextInt(chance) != 0) {
if(RNG.r.nextInt(chance) != 0) {
return;
}
if (sound != null) {
if(sound != null) {
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
J.s(() -> p.getWorld().playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)));
}
if (particleEffect != null) {
if(particleEffect != null) {
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1, 1, 1).multiply(RNG.r.d())).subtract(new Vector(1, 1, 1).multiply(RNG.r.d()));
part.add(RNG.r.d(), 0, RNG.r.d());
if (extra != 0) {
if(extra != 0) {
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra));
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra));
} else {
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
}
}
}

View File

@@ -53,9 +53,9 @@ public class IrisElipsoid implements IRare {
@SuppressWarnings("SuspiciousNameCombination")
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
writer.setElipsoid(x, y, z,
xRadius.get(rng, z, y, engine.getData()),
yRadius.get(rng, x, z, engine.getData()),
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)));
xRadius.get(rng, z, y, engine.getData()),
yRadius.get(rng, x, z, engine.getData()),
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)));
}
public double maxSize() {

View File

@@ -61,25 +61,25 @@ public class IrisEnchantment {
public void apply(RNG rng, ItemMeta meta) {
try {
if (rng.nextDouble() < chance) {
if (meta instanceof EnchantmentStorageMeta) {
if(rng.nextDouble() < chance) {
if(meta instanceof EnchantmentStorageMeta) {
((EnchantmentStorageMeta) meta).addStoredEnchant(getEnchant(), getLevel(rng), true);
return;
}
meta.addEnchant(getEnchant(), getLevel(rng), true);
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
}
public Enchantment getEnchant() {
for (Field i : Enchantment.class.getDeclaredFields()) {
if (i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) {
for(Field i : Enchantment.class.getDeclaredFields()) {
if(i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) {
try {
return (Enchantment) i.get(null);
} catch (IllegalArgumentException | IllegalAccessException e) {
} catch(IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
Iris.reportError(e);
}

View File

@@ -28,10 +28,10 @@ public class IrisEngineChunkData {
private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>();
public void cleanup(Engine engine) {
for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
for(IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
if(sp == null || i.canSpawn(sp.getMaximumRate())) {
getCooldowns().remove(i);
}
}

View File

@@ -38,8 +38,8 @@ public class IrisEngineData {
public IrisEngineChunkData getChunk(int x, int z) {
long k = Cache.key(x, z);
for (IrisEngineChunkData i : chunks) {
if (i.getChunk() == k) {
for(IrisEngineChunkData i : chunks) {
if(i.getChunk() == k) {
return i;
}
}
@@ -51,18 +51,18 @@ public class IrisEngineData {
}
public void cleanup(Engine engine) {
for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
if(sp == null || i.canSpawn(sp.getMaximumRate())) {
getSpawnerCooldowns().remove(i);
}
}
for (IrisEngineChunkData i : chunks.copy()) {
for(IrisEngineChunkData i : chunks.copy()) {
i.cleanup(engine);
if (i.isEmpty()) {
if(i.isEmpty()) {
getChunks().remove(i);
}
}

View File

@@ -186,22 +186,22 @@ public class IrisEntity extends IrisRegistrant {
}
public Entity spawn(Engine gen, Location at, RNG rng) {
if (!Chunks.isSafe(at)) {
if(!Chunks.isSafe(at)) {
return null;
}
if (isSpawnEffectRiseOutOfGround()) {
if(isSpawnEffectRiseOutOfGround()) {
AtomicReference<Location> f = new AtomicReference<>(at);
try {
J.sfut(() -> {
if (Chunks.hasPlayersNearby(f.get())) {
if(Chunks.hasPlayersNearby(f.get())) {
Location b = f.get().clone();
Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ());
f.set(start);
}
}).get();
} catch (InterruptedException e) {
} catch(InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
} catch(ExecutionException e) {
e.printStackTrace();
}
at = f.get();
@@ -209,23 +209,23 @@ public class IrisEntity extends IrisRegistrant {
Entity ee = doSpawn(at);
if (ee == null && !Chunks.isSafe(at)) {
if(ee == null && !Chunks.isSafe(at)) {
return null;
}
if (!spawnerScript.isEmpty() && ee == null) {
synchronized (this) {
if(!spawnerScript.isEmpty() && ee == null) {
synchronized(this) {
gen.getExecution().getAPI().setLocation(at);
try {
ee = (Entity) gen.getExecution().evaluate(spawnerScript);
} catch (Throwable ex) {
} catch(Throwable ex) {
Iris.error("You must return an Entity in your scripts to use entity scripts!");
ex.printStackTrace();
}
}
}
if (ee == null) {
if(ee == null) {
return null;
}
@@ -239,25 +239,25 @@ public class IrisEntity extends IrisRegistrant {
e.setPersistent(isKeepEntity() || IrisSettings.get().getWorld().isForcePersistEntities());
int gg = 0;
for (IrisEntity i : passengers) {
for(IrisEntity i : passengers) {
Entity passenger = i.spawn(gen, at, rng.nextParallelRNG(234858 + gg++));
if (!Bukkit.isPrimaryThread()) {
if(!Bukkit.isPrimaryThread()) {
J.s(() -> e.addPassenger(passenger));
}
}
if (e instanceof Attributable) {
if(e instanceof Attributable) {
Attributable a = (Attributable) e;
for (IrisAttributeModifier i : getAttributes()) {
for(IrisAttributeModifier i : getAttributes()) {
i.apply(rng, a);
}
}
if (e instanceof Lootable) {
if(e instanceof Lootable) {
Lootable l = (Lootable) e;
if (getLoot().getTables().isNotEmpty()) {
if(getLoot().getTables().isNotEmpty()) {
Location finalAt = at;
l.setLootTable(new LootTable() {
@Override
@@ -269,7 +269,7 @@ public class IrisEntity extends IrisRegistrant {
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
KList<ItemStack> items = new KList<>();
for (String fi : getLoot().getTables()) {
for(String fi : getLoot().getTables()) {
IrisLootTable i = gen.getData().getLootLoader().load(fi);
items.addAll(i.getLoot(gen.isStudio(), false, rng.nextParallelRNG(345911), InventorySlotType.STORAGE, finalAt.getBlockX(), finalAt.getBlockY(), finalAt.getBlockZ(), 8, 4));
}
@@ -279,7 +279,7 @@ public class IrisEntity extends IrisRegistrant {
@Override
public void fillInventory(Inventory inventory, Random random, LootContext context) {
for (ItemStack i : populateLoot(random, context)) {
for(ItemStack i : populateLoot(random, context)) {
inventory.addItem(i);
}
@@ -289,52 +289,52 @@ public class IrisEntity extends IrisRegistrant {
}
}
if (e instanceof LivingEntity) {
if(e instanceof LivingEntity) {
LivingEntity l = (LivingEntity) e;
l.setAI(isAi());
l.setCanPickupItems(isPickupItems());
if (getLeashHolder() != null) {
if(getLeashHolder() != null) {
l.setLeashHolder(getLeashHolder().spawn(gen, at, rng.nextParallelRNG(234548)));
}
l.setRemoveWhenFarAway(isRemovable());
if (getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) {
if(getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) {
l.getEquipment().setHelmet(getHelmet().get(gen.isStudio(), rng));
}
if (getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) {
if(getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) {
l.getEquipment().setChestplate(getChestplate().get(gen.isStudio(), rng));
}
if (getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) {
if(getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) {
l.getEquipment().setLeggings(getLeggings().get(gen.isStudio(), rng));
}
if (getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) {
if(getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) {
l.getEquipment().setBoots(getBoots().get(gen.isStudio(), rng));
}
if (getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) {
if(getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) {
l.getEquipment().setItemInMainHand(getMainHand().get(gen.isStudio(), rng));
}
if (getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) {
if(getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) {
l.getEquipment().setItemInOffHand(getOffHand().get(gen.isStudio(), rng));
}
}
if (e instanceof Ageable && isBaby()) {
if(e instanceof Ageable && isBaby()) {
((Ageable) e).setBaby();
}
if (e instanceof Panda) {
if(e instanceof Panda) {
((Panda) e).setMainGene(getPandaMainGene());
((Panda) e).setMainGene(getPandaHiddenGene());
}
if (e instanceof Villager) {
if(e instanceof Villager) {
Villager villager = (Villager) e;
villager.setRemoveWhenFarAway(false);
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
@@ -342,27 +342,27 @@ public class IrisEntity extends IrisRegistrant {
}, 1);
}
if (e instanceof Mob) {
if(e instanceof Mob) {
Mob m = (Mob) e;
m.setAware(isAware());
}
if (spawnEffect != null) {
if(spawnEffect != null) {
spawnEffect.apply(e);
}
if (postSpawnScripts.isNotEmpty()) {
synchronized (this) {
if(postSpawnScripts.isNotEmpty()) {
synchronized(this) {
gen.getExecution().getAPI().setLocation(at);
gen.getExecution().getAPI().setEntity(ee);
for (String i : postSpawnScripts) {
for(String i : postSpawnScripts) {
gen.getExecution().execute(i);
}
}
}
if (rawCommands.isNotEmpty()) {
if(rawCommands.isNotEmpty()) {
final Location fat = at;
rawCommands.forEach(r -> r.run(fat));
}
@@ -370,7 +370,7 @@ public class IrisEntity extends IrisRegistrant {
Location finalAt1 = at;
J.s(() -> {
if (isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) {
if(isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) {
Location start = finalAt1.clone();
e.setInvulnerable(true);
((LivingEntity) e).setAI(false);
@@ -379,17 +379,17 @@ public class IrisEntity extends IrisRegistrant {
AtomicInteger t = new AtomicInteger(0);
AtomicInteger v = new AtomicInteger(0);
v.set(J.sr(() -> {
if (t.get() > 100) {
if(t.get() > 100) {
J.csr(v.get());
return;
}
t.incrementAndGet();
if (e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) {
if(e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) {
e.teleport(start.add(new Vector(0, 0.1, 0)));
ItemStack itemCrackData = new ItemStack(((LivingEntity) e).getEyeLocation().clone().subtract(0, 2, 0).getBlock().getBlockData().getMaterial());
e.getWorld().spawnParticle(Particle.ITEM_CRACK, ((LivingEntity) e).getEyeLocation(), 6, 0.2, 0.4, 0.2, 0.06f, itemCrackData);
if (M.r(0.2)) {
if(M.r(0.2)) {
e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f);
}
} else {
@@ -410,11 +410,11 @@ public class IrisEntity extends IrisRegistrant {
private int surfaceY(Location l) {
int m = l.getBlockY();
while (m-- > 0) {
while(m-- > 0) {
Location ll = l.clone();
ll.setY(m);
if (ll.getBlock().getType().isSolid()) {
if(ll.getBlock().getType().isSolid()) {
return m;
}
}
@@ -423,30 +423,30 @@ public class IrisEntity extends IrisRegistrant {
}
private Entity doSpawn(Location at) {
if (!Chunks.isSafe(at)) {
if(!Chunks.isSafe(at)) {
return null;
}
if (type.equals(EntityType.UNKNOWN)) {
if(type.equals(EntityType.UNKNOWN)) {
return null;
}
if (!Bukkit.isPrimaryThread()) {
if(!Bukkit.isPrimaryThread()) {
// Someone called spawn (worldedit maybe?) on a non server thread
// Due to the structure of iris, we will call it sync and busy wait until it's done.
AtomicReference<Entity> ae = new AtomicReference<>();
try {
J.s(() -> ae.set(doSpawn(at)));
} catch (Throwable e) {
} catch(Throwable e) {
return null;
}
PrecisionStopwatch p = PrecisionStopwatch.start();
while (ae.get() == null) {
while(ae.get() == null) {
J.sleep(25);
if (p.getMilliseconds() > 500) {
if(p.getMilliseconds() > 500) {
return null;
}
}
@@ -454,8 +454,8 @@ public class IrisEntity extends IrisRegistrant {
return ae.get();
}
if (isSpecialType()) {
if (specialType.toLowerCase().startsWith("mythicmobs:")) {
if(isSpecialType()) {
if(specialType.toLowerCase().startsWith("mythicmobs:")) {
return Iris.linkMythicMobs.spawnMob(specialType.substring(11), at);
} else {
Iris.warn("Invalid mob type to spawn: '" + specialType + "'!");

View File

@@ -70,28 +70,28 @@ public class IrisEntitySpawn implements IRare {
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
int s = 0;
if (spawns > 0) {
for (int id = 0; id < spawns; id++) {
if(spawns > 0) {
for(int id = 0; id < spawns; id++) {
int x = (c.getX() * 16) + rng.i(15);
int z = (c.getZ() * 16) + rng.i(15);
int h = gen.getHeight(x, z, true);
int hf = gen.getHeight(x, z, false);
Location l = switch (getReferenceSpawner().getGroup()) {
Location l = switch(getReferenceSpawner().getGroup()) {
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
case CAVE -> gen.getMantle().findMarkers(c.getX(), c.getZ(), MarkerMatter.CAVE_FLOOR)
.convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng);
.convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng);
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h + 1, hf), z);
};
if (l != null) {
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
if (spawn100(gen, l) != null) {
if(l != null) {
if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
if(spawn100(gen, l) != null) {
s++;
}
}
} else {
if (spawn100(gen, l) != null) {
if(spawn100(gen, l) != null) {
s++;
}
}
@@ -106,28 +106,28 @@ public class IrisEntitySpawn implements IRare {
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
int s = 0;
if (!gen.getWorld().tryGetRealWorld()) {
if(!gen.getWorld().tryGetRealWorld()) {
return 0;
}
World world = gen.getWorld().realWorld();
if (spawns > 0) {
if(spawns > 0) {
if (referenceMarker != null) {
if(referenceMarker != null) {
gen.getMantle().getMantle().remove(c.getX(), c.getY(), c.getZ(), MatterMarker.class);
}
for (int id = 0; id < spawns; id++) {
for(int id = 0; id < spawns; id++) {
Location l = c.toLocation(world).add(0, 1, 0);
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
if (spawn100(gen, l, true) != null) {
if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
if(spawn100(gen, l, true) != null) {
s++;
}
}
} else {
if (spawn100(gen, l, true) != null) {
if(spawn100(gen, l, true) != null) {
s++;
}
}
@@ -142,11 +142,11 @@ public class IrisEntitySpawn implements IRare {
}
public Entity spawn(Engine g, Location at) {
if (getRealEntity(g) == null) {
if(getRealEntity(g) == null) {
return null;
}
if (rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) {
if(rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) {
return spawn100(g, at);
}
@@ -160,23 +160,23 @@ public class IrisEntitySpawn implements IRare {
private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) {
try {
IrisEntity irisEntity = getRealEntity(g);
if(irisEntity == null){ // No entity
if(irisEntity == null) { // No entity
Iris.debug(" You are trying to spawn an entity that does not exist!");
return null;
}
if (!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) {
if(!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) {
return null;
}
Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
if (e != null) {
if(e != null) {
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
}
return e;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
Iris.error(" Failed to retrieve real entity @ " + at + " (entity: " + getEntity() + ")");

View File

@@ -65,21 +65,21 @@ public class IrisExpression extends IrisRegistrant {
Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables.
try {
for (IrisExpressionLoad i : variables) {
for(IrisExpressionLoad i : variables) {
scope.addInvocationVariable(i.getName());
}
scope.addInvocationVariable("x");
scope.addInvocationVariable("y");
scope.addInvocationVariable("z");
} catch (Throwable e) {
} catch(Throwable e) {
e.printStackTrace();
Iris.error("Script Variable load error in " + getLoadFile().getPath());
}
try {
return parser.parse(getExpression(), scope);
} catch (Throwable e) {
} catch(Throwable e) {
e.printStackTrace();
Iris.error("Script load error in " + getLoadFile().getPath());
}
@@ -90,13 +90,13 @@ public class IrisExpression extends IrisRegistrant {
public ProceduralStream<Double> stream(RNG rng) {
return streamCache.aquire(() -> ProceduralStream.of((x, z) -> evaluate(rng, x, z),
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
}
public double evaluate(RNG rng, double x, double z) {
double[] g = new double[3 + getVariables().size()];
int m = 0;
for (IrisExpressionLoad i : getVariables()) {
for(IrisExpressionLoad i : getVariables()) {
g[m++] = i.getValue(rng, getLoader(), x, z);
}
@@ -110,7 +110,7 @@ public class IrisExpression extends IrisRegistrant {
public double evaluate(RNG rng, double x, double y, double z) {
double[] g = new double[3 + getVariables().size()];
int m = 0;
for (IrisExpressionLoad i : getVariables()) {
for(IrisExpressionLoad i : getVariables()) {
g[m++] = i.getValue(rng, getLoader(), x, y, z);
}

View File

@@ -60,15 +60,15 @@ public class IrisExpressionLoad {
private transient AtomicCache<Double> valueCache = new AtomicCache<>();
public double getValue(RNG rng, IrisData data, double x, double z) {
if (engineValue != null) {
if(engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
}
if (engineStreamValue != null) {
if(engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
}
if (styleValue != null) {
if(styleValue != null) {
return styleValue.create(rng, data).noise(x, z);
}
@@ -76,15 +76,15 @@ public class IrisExpressionLoad {
}
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
if (engineValue != null) {
if(engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
}
if (engineStreamValue != null) {
if(engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
}
if (styleValue != null) {
if(styleValue != null) {
return styleValue.create(rng, data).noise(x, y, z);
}

View File

@@ -49,14 +49,14 @@ public class IrisFluidBodies {
@BlockCoordinates
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
if (rivers.isNotEmpty()) {
for (IrisRiver i : rivers) {
if(rivers.isNotEmpty()) {
for(IrisRiver i : rivers) {
i.generate(writer, rng, engine, x, y, z);
}
}
if (lakes.isNotEmpty()) {
for (IrisLake i : lakes) {
if(lakes.isNotEmpty()) {
for(IrisLake i : lakes) {
i.generate(writer, rng, engine, x, y, z);
}
}
@@ -65,11 +65,11 @@ public class IrisFluidBodies {
public int getMaxRange(IrisData data) {
int max = 0;
for (IrisRiver i : rivers) {
for(IrisRiver i : rivers) {
max = Math.max(max, i.getSize(data));
}
for (IrisLake i : lakes) {
for(IrisLake i : lakes) {
max = Math.max(max, i.getSize(data));
}

View File

@@ -105,28 +105,28 @@ public class IrisGenerator extends IrisRegistrant {
}
public <T extends IRare> T fitRarity(KList<T> b, long superSeed, double rx, double rz) {
if (b.size() == 0) {
if(b.size() == 0) {
return null;
}
if (b.size() == 1) {
if(b.size() == 1) {
return b.get(0);
}
KList<T> rarityMapped = new KList<>();
boolean o = false;
int max = 1;
for (T i : b) {
if (i.getRarity() > max) {
for(T i : b) {
if(i.getRarity() > max) {
max = i.getRarity();
}
}
max++;
for (T i : b) {
for (int j = 0; j < max - i.getRarity(); j++) {
if (o = !o) {
for(T i : b) {
for(int j = 0; j < max - i.getRarity(); j++) {
if(o = !o) {
rarityMapped.add(i);
} else {
rarityMapped.add(0, i);
@@ -134,11 +134,11 @@ public class IrisGenerator extends IrisRegistrant {
}
}
if (rarityMapped.size() == 1) {
if(rarityMapped.size() == 1) {
return rarityMapped.get(0);
}
if (rarityMapped.isEmpty()) {
if(rarityMapped.isEmpty()) {
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
}
@@ -146,11 +146,11 @@ public class IrisGenerator extends IrisRegistrant {
}
public <T> T fit(T[] v, long superSeed, double rx, double rz) {
if (v.length == 0) {
if(v.length == 0) {
return null;
}
if (v.length == 1) {
if(v.length == 1) {
return v[0];
}
@@ -158,11 +158,11 @@ public class IrisGenerator extends IrisRegistrant {
}
public <T> T fit(List<T> v, long superSeed, double rx, double rz) {
if (v.size() == 0) {
if(v.size() == 0) {
return null;
}
if (v.size() == 1) {
if(v.size() == 1) {
return v.get(0);
}
@@ -170,7 +170,7 @@ public class IrisGenerator extends IrisRegistrant {
}
public int fit(int min, int max, long superSeed, double rx, double rz) {
if (min == max) {
if(min == max) {
return min;
}
@@ -180,7 +180,7 @@ public class IrisGenerator extends IrisRegistrant {
}
public int fit(double min, double max, long superSeed, double rx, double rz) {
if (min == max) {
if(min == max) {
return (int) Math.round(min);
}
@@ -190,7 +190,7 @@ public class IrisGenerator extends IrisRegistrant {
}
public double fitDouble(double min, double max, long superSeed, double rx, double rz) {
if (min == max) {
if(min == max) {
return min;
}
@@ -209,7 +209,7 @@ public class IrisGenerator extends IrisRegistrant {
}
public double getHeight(double rx, double ry, double rz, long superSeed, boolean no3d) {
if (composite.isEmpty()) {
if(composite.isEmpty()) {
return 0;
}
@@ -217,16 +217,16 @@ public class IrisGenerator extends IrisRegistrant {
double h = multiplicitive ? 1 : 0;
double tp = 0;
if (composite.size() == 1) {
if (multiplicitive) {
if(composite.size() == 1) {
if(multiplicitive) {
h *= composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
} else {
tp += composite.get(0).getOpacity();
h += composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
}
} else {
for (IrisNoiseGenerator i : composite) {
if (multiplicitive) {
for(IrisNoiseGenerator i : composite) {
if(multiplicitive) {
h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
} else {
tp += i.getOpacity();
@@ -237,7 +237,7 @@ public class IrisGenerator extends IrisRegistrant {
double v = multiplicitive ? h * opacity : (h / tp) * opacity;
if (Double.isNaN(v)) {
if(Double.isNaN(v)) {
v = 0;
}
@@ -275,7 +275,7 @@ public class IrisGenerator extends IrisRegistrant {
public KList<IrisNoiseGenerator> getAllComposites() {
KList<IrisNoiseGenerator> g = new KList<>();
for (IrisNoiseGenerator i : composite) {
for(IrisNoiseGenerator i : composite) {
g.addAll(i.getAllComposites());
}

View File

@@ -29,14 +29,11 @@ import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.noise.ExpressionNoise;
import com.volmit.iris.util.noise.ImageNoise;
import com.volmit.iris.util.stream.ProceduralStream;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.List;
@Snippet("style")
@Accessors(chain = true)
@NoArgsConstructor
@@ -84,39 +81,34 @@ public class IrisGeneratorStyle {
}
public CNG createNoCache(RNG rng, IrisData data) {
if (getExpression() != null) {
if(getExpression() != null) {
IrisExpression e = data.getExpressionLoader().load(getExpression());
if (e != null) {
if(e != null) {
CNG cng = new CNG(rng, new ExpressionNoise(rng, e), 1D, 1)
.bake().scale(1D / zoom).pow(exponent).bake();
.bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing);
if (fracture != null) {
if(fracture != null) {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}
return cng;
}
}
else if(getImageMap() != null)
{
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D/zoom).pow(exponent).bake();
} else if(getImageMap() != null) {
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing);
if (fracture != null) {
if(fracture != null) {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}
return cng;
@@ -125,13 +117,12 @@ public class IrisGeneratorStyle {
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing);
if (fracture != null) {
if(fracture != null) {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
}
if(cellularFrequency > 0)
{
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
if(cellularFrequency > 0) {
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
}
return cng;

View File

@@ -30,34 +30,28 @@ import java.io.File;
import java.io.IOException;
public class IrisImage extends IrisRegistrant {
private BufferedImage image;
private final BufferedImage image;
public int getWidth()
{
public int getWidth() {
return image.getWidth();
}
public int getHeight()
{
public int getHeight() {
return image.getHeight();
}
public int getRawValue(int x, int z)
{
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0)
{
public int getRawValue(int x, int z) {
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) {
return 0;
}
return image.getRGB(x, z);
}
public double getValue(IrisImageChannel channel, int x, int z)
{
public double getValue(IrisImageChannel channel, int x, int z) {
int color = getRawValue(x, z);
switch(channel)
{
switch(channel) {
case RED -> {
return ((color >> 16) & 0xFF) / 255D;
}
@@ -105,13 +99,11 @@ public class IrisImage extends IrisRegistrant {
return color;
}
public IrisImage()
{
public IrisImage() {
this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB));
}
public IrisImage(BufferedImage image)
{
public IrisImage(BufferedImage image) {
this.image = image;
}
@@ -136,10 +128,8 @@ public class IrisImage extends IrisRegistrant {
try {
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
for(int i = 0; i < getWidth(); i++)
{
for(int j = 0; j < getHeight(); j++)
{
for(int i = 0; i < getWidth(); i++) {
for(int j = 0; j < getHeight(); j++) {
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB());
}
}

View File

@@ -20,21 +20,13 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.project.SchemaBuilder;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.mantle.MantleWriter;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.engine.object.annotations.Snippet;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.interpolation.InterpolationMethod;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -72,26 +64,23 @@ public class IrisImageMap {
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
public double getNoise(IrisData data, int x, int z)
{
public double getNoise(IrisData data, int x, int z) {
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
if(i == null)
{
if(i == null) {
Iris.error("NULL IMAGE FOR " + image);
}
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx,zz) -> rawNoise(i, xx, zz));
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz));
}
private double rawNoise(IrisImage i, double x, double z)
{
private double rawNoise(IrisImage i, double x, double z) {
x /= coordinateScale;
z /= coordinateScale;
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;
z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z;
x = isTiled() ? x % i.getWidth() : x;
z = isTiled() ? z % i.getHeight() : z;
double v = i.getValue(getChannel(), (int)x, (int)z);
double v = i.getValue(getChannel(), (int) x, (int) z);
return isInverted() ? 1D - v : v;
}
}

View File

@@ -57,7 +57,7 @@ public class IrisInterpolator {
@Override
public boolean equals(Object o) {
if (o instanceof IrisInterpolator i) {
if(o instanceof IrisInterpolator i) {
return i.getFunction().equals(function) && i.getHorizontalScale() == horizontalScale;
}

View File

@@ -67,7 +67,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
try {
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
return Math.max(v.getBlockX(), v.getBlockZ());
} catch (IOException e) {
} catch(IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -81,7 +81,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
try {
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
return Math.max(Math.max(v.getBlockX(), v.getBlockZ()), v.getBlockY());
} catch (IOException e) {
} catch(IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -92,8 +92,8 @@ public class IrisJigsawPiece extends IrisRegistrant {
public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) {
for (IrisJigsawPieceConnector i : connectors) {
if (i.getPosition().equals(relativePosition)) {
for(IrisJigsawPieceConnector i : connectors) {
if(i.getPosition().equals(relativePosition)) {
return i;
}
}
@@ -110,7 +110,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
p.setConnectors(new KList<>());
p.setPlacementOptions(getPlacementOptions());
for (IrisJigsawPieceConnector i : getConnectors()) {
for(IrisJigsawPieceConnector i : getConnectors()) {
p.getConnectors().add(i.copy());
}

View File

@@ -71,19 +71,19 @@ public class IrisJigsawStructure extends IrisRegistrant {
private transient AtomicCache<Integer> maxDimension = new AtomicCache<>();
private void loadPool(String p, KList<String> pools, KList<String> pieces) {
if (p.isEmpty()) {
if(p.isEmpty()) {
return;
}
IrisJigsawPool pool = getLoader().getJigsawPoolLoader().load(p);
if (pool == null) {
if(pool == null) {
Iris.warn("Can't find jigsaw pool: " + p);
return;
}
for (String i : pool.getPieces()) {
if (pieces.addIfMissing(i)) {
for(String i : pool.getPieces()) {
if(pieces.addIfMissing(i)) {
loadPiece(i, pools, pieces);
}
}
@@ -92,14 +92,14 @@ public class IrisJigsawStructure extends IrisRegistrant {
private void loadPiece(String p, KList<String> pools, KList<String> pieces) {
IrisJigsawPiece piece = getLoader().getJigsawPieceLoader().load(p);
if (piece == null) {
if(piece == null) {
Iris.warn("Can't find jigsaw piece: " + p);
return;
}
for (IrisJigsawPieceConnector i : piece.getConnectors()) {
for (String j : i.getPools()) {
if (pools.addIfMissing(j)) {
for(IrisJigsawPieceConnector i : piece.getConnectors()) {
for(String j : i.getPools()) {
if(pools.addIfMissing(j)) {
loadPool(j, pools, pieces);
}
}
@@ -108,16 +108,16 @@ public class IrisJigsawStructure extends IrisRegistrant {
public int getMaxDimension() {
return maxDimension.aquire(() -> {
if (useMaxPieceSizeForParallaxRadius) {
if(useMaxPieceSizeForParallaxRadius) {
int max = 0;
KList<String> pools = new KList<>();
KList<String> pieces = new KList<>();
for (String i : getPieces()) {
for(String i : getPieces()) {
loadPiece(i, pools, pieces);
}
for (String i : pieces) {
for(String i : pieces) {
max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension());
}
@@ -126,13 +126,13 @@ public class IrisJigsawStructure extends IrisRegistrant {
KList<String> pools = new KList<>();
KList<String> pieces = new KList<>();
for (String i : getPieces()) {
for(String i : getPieces()) {
loadPiece(i, pools, pieces);
}
int avg = 0;
for (String i : pieces) {
for(String i : pieces) {
avg += getLoader().getJigsawPieceLoader().load(i).getMax2dDimension();
}

View File

@@ -112,29 +112,29 @@ public class IrisLoot {
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
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()) {
for(IrisEnchantment i : getEnchantments()) {
i.apply(rng, m);
}
for (IrisAttributeModifier i : getAttributes()) {
for(IrisAttributeModifier i : getAttributes()) {
i.apply(rng, m);
}
try {
m.setCustomModelData(getCustomModel());
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for (ItemFlag i : getItemFlags()) {
for(ItemFlag i : getItemFlags()) {
m.addItemFlags(i);
}
@@ -144,8 +144,8 @@ public class IrisLoot {
{
String mf = C.translateAlternateColorCodes('&', i);
if (mf.length() > 24) {
for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
if(mf.length() > 24) {
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
lore.add(g.trim());
}
} else {
@@ -153,8 +153,8 @@ public class IrisLoot {
}
});
if (debug) {
if (lore.isNotEmpty()) {
if(debug) {
if(lore.isNotEmpty()) {
lore.add(C.GRAY + "--------------------");
}
@@ -163,18 +163,18 @@ public class IrisLoot {
m.setLore(lore);
if (getLeatherColor() != null && m instanceof LeatherArmorMeta) {
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) {
if(getDyeColor() != null && m instanceof Colorable) {
((Colorable) m).setColor(getDyeColor());
}
is.setItemMeta(m);
return is;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -183,12 +183,12 @@ public class IrisLoot {
}
public ItemStack get(boolean debug, boolean giveSomething, IrisLootTable table, RNG rng, int x, int y, int z) {
if (debug) {
if(debug) {
chance.reset();
}
if (giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) {
if (getType() == null) {
if(giveSomething || 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;
}
@@ -197,22 +197,22 @@ public class IrisLoot {
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
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()) {
for(IrisEnchantment i : getEnchantments()) {
i.apply(rng, m);
}
for (IrisAttributeModifier i : getAttributes()) {
for(IrisAttributeModifier i : getAttributes()) {
i.apply(rng, m);
}
try {
m.setCustomModelData(getCustomModel());
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -220,7 +220,7 @@ public class IrisLoot {
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
m.setUnbreakable(isUnbreakable());
for (ItemFlag i : getItemFlags()) {
for(ItemFlag i : getItemFlags()) {
m.addItemFlags(i);
}
@@ -230,8 +230,8 @@ public class IrisLoot {
{
String mf = C.translateAlternateColorCodes('&', i);
if (mf.length() > 24) {
for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
if(mf.length() > 24) {
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
lore.add(g.trim());
}
} else {
@@ -239,8 +239,8 @@ public class IrisLoot {
}
});
if (debug) {
if (lore.isNotEmpty()) {
if(debug) {
if(lore.isNotEmpty()) {
lore.add(C.GRAY + "--------------------");
}
@@ -251,7 +251,7 @@ public class IrisLoot {
m.setLore(lore);
is.setItemMeta(m);
return is;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}

View File

@@ -54,7 +54,7 @@ public class IrisLootReference {
{
KList<IrisLootTable> t = new KList<>();
for (String i : tables) {
for(String i : tables) {
t.add(g.getData().getLootLoader().load(i));
}

View File

@@ -70,15 +70,15 @@ public class IrisLootTable extends IrisRegistrant {
int m = 0;
int mx = rng.i(getMinPicked(), getMaxPicked());
while (m < mx) {
while(m < mx) {
int num = rng.i(loot.size());
IrisLoot l = loot.get(num);
if (l.getSlotTypes() == slot) {
if(l.getSlotTypes() == slot) {
ItemStack item = l.get(debug, false, this, rng, x, y, z);
if (item != null && item.getType() != Material.AIR) {
if(item != null && item.getType() != Material.AIR) {
lootf.add(item);
m++;
}

View File

@@ -55,11 +55,11 @@ public class IrisMaterialPalette {
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("STONE"));
public BlockData get(RNG rng, double x, double y, double z, IrisData rdata) {
if (getBlockData(rdata).isEmpty()) {
if(getBlockData(rdata).isEmpty()) {
return null;
}
if (getBlockData(rdata).size() == 1) {
if(getBlockData(rdata).size() == 1) {
return getBlockData(rdata).get(0);
}
@@ -95,10 +95,10 @@ public class IrisMaterialPalette {
return blockData.aquire(() ->
{
KList<BlockData> blockData = new KList<>();
for (IrisBlockData ix : palette) {
for(IrisBlockData ix : palette) {
BlockData bx = ix.getBlockData(rdata);
if (bx != null) {
for (int i = 0; i < ix.getWeight(); i++) {
if(bx != null) {
for(int i = 0; i < ix.getWeight(); i++) {
blockData.add(bx);
}
}

View File

@@ -95,7 +95,7 @@ public class IrisNoiseGenerator {
}
public double getNoise(long superSeed, double xv, double zv, IrisData data) {
if (!enabled) {
if(!enabled) {
return offsetY;
}
@@ -103,8 +103,8 @@ public class IrisNoiseGenerator {
double z = zv;
int g = 33;
for (IrisNoiseGenerator i : fracture) {
if (i.isEnabled()) {
for(IrisNoiseGenerator i : fracture) {
if(i.isEnabled()) {
x += i.getNoise(superSeed + seed + g, xv, zv, data) - (opacity / 2D);
z -= i.getNoise(superSeed + seed + g, zv, xv, data) - (opacity / 2D);
}
@@ -126,7 +126,7 @@ public class IrisNoiseGenerator {
g.add(this);
for (IrisNoiseGenerator i : getFracture()) {
for(IrisNoiseGenerator i : getFracture()) {
g.addAll(i.getAllComposites());
}

View File

@@ -79,7 +79,7 @@ public class IrisObject extends IrisRegistrant {
protected static final BlockData AIR = B.get("CAVE_AIR");
protected static final BlockData VAIR = B.get("VOID_AIR");
protected static final BlockData VAIR_DEBUG = B.get("COBWEB");
protected static final BlockData[] SNOW_LAYERS = new BlockData[]{B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")};
protected static final BlockData[] SNOW_LAYERS = new BlockData[] {B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")};
protected transient final IrisLock readLock = new IrisLock("read-conclock");
@Getter
@Setter
@@ -124,7 +124,7 @@ public class IrisObject extends IrisRegistrant {
public static AxisAlignedBB getAABBFor(BlockVector size) {
BlockVector center = new BlockVector(size.getX() / 2, size.getY() / 2, size.getZ() / 2);
return new AxisAlignedBB(new IrisPosition(new BlockVector(0, 0, 0).subtract(center).toBlockVector()),
new IrisPosition(new BlockVector(size.getX() - 1, size.getY() - 1, size.getZ() - 1).subtract(center).toBlockVector()));
new IrisPosition(new BlockVector(size.getX() - 1, size.getY() - 1, size.getZ() - 1).subtract(center).toBlockVector()));
}
@SuppressWarnings({"resource", "RedundantSuppression"})
@@ -145,9 +145,9 @@ public class IrisObject extends IrisRegistrant {
int topBlockZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
int bottomBlockZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
for (int x = bottomBlockX; x <= topBlockX; x++) {
for (int z = bottomBlockZ; z <= topBlockZ; z++) {
for (int y = bottomBlockY; y <= topBlockY; y++) {
for(int x = bottomBlockX; x <= topBlockX; x++) {
for(int z = bottomBlockZ; z <= topBlockZ; z++) {
for(int y = bottomBlockY; y <= topBlockY; y++) {
locations.add(new BlockVector(x, y, z));
}
}
@@ -160,7 +160,7 @@ public class IrisObject extends IrisRegistrant {
}
public void ensureSmartBored(boolean debug) {
if (smartBored) {
if(smartBored) {
return;
}
@@ -168,7 +168,7 @@ public class IrisObject extends IrisRegistrant {
BlockData vair = debug ? VAIR_DEBUG : VAIR;
lock.lock();
AtomicInteger applied = new AtomicInteger();
if (getBlocks().isEmpty()) {
if(getBlocks().isEmpty()) {
lock.unlock();
Iris.warn("Cannot Smart Bore " + getLoadKey() + " because it has 0 blocks in it.");
smartBored = true;
@@ -178,7 +178,7 @@ public class IrisObject extends IrisRegistrant {
BlockVector max = new BlockVector(Double.MIN_VALUE, Double.MIN_VALUE, Double.MIN_VALUE);
BlockVector min = new BlockVector(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
max.setX(Math.max(i.getX(), max.getX()));
min.setX(Math.min(i.getX(), min.getX()));
max.setY(Math.max(i.getY(), max.getY()));
@@ -190,25 +190,25 @@ public class IrisObject extends IrisRegistrant {
BurstExecutor burst = MultiBurst.burst.burst();
// Smash X
for (int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) {
for(int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) {
int finalRayY = rayY;
burst.queue(() -> {
for (int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) {
for(int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) {
int start = Integer.MAX_VALUE;
int end = Integer.MIN_VALUE;
for (int ray = min.getBlockX(); ray <= max.getBlockX(); ray++) {
if (getBlocks().containsKey(new BlockVector(ray, finalRayY, rayZ))) {
for(int ray = min.getBlockX(); ray <= max.getBlockX(); ray++) {
if(getBlocks().containsKey(new BlockVector(ray, finalRayY, rayZ))) {
start = Math.min(ray, start);
end = Math.max(ray, end);
}
}
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for (int i = start; i <= end; i++) {
if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for(int i = start; i <= end; i++) {
BlockVector v = new BlockVector(i, finalRayY, rayZ);
if (!B.isAir(getBlocks().get(v))) {
if(!B.isAir(getBlocks().get(v))) {
getBlocks().computeIfAbsent(v, (vv) -> vair);
applied.getAndIncrement();
}
@@ -219,25 +219,25 @@ public class IrisObject extends IrisRegistrant {
}
// Smash Y
for (int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) {
for(int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) {
int finalRayX = rayX;
burst.queue(() -> {
for (int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) {
for(int rayZ = min.getBlockZ(); rayZ <= max.getBlockZ(); rayZ++) {
int start = Integer.MAX_VALUE;
int end = Integer.MIN_VALUE;
for (int ray = min.getBlockY(); ray <= max.getBlockY(); ray++) {
if (getBlocks().containsKey(new BlockVector(finalRayX, ray, rayZ))) {
for(int ray = min.getBlockY(); ray <= max.getBlockY(); ray++) {
if(getBlocks().containsKey(new BlockVector(finalRayX, ray, rayZ))) {
start = Math.min(ray, start);
end = Math.max(ray, end);
}
}
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for (int i = start; i <= end; i++) {
if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for(int i = start; i <= end; i++) {
BlockVector v = new BlockVector(finalRayX, i, rayZ);
if (!B.isAir(getBlocks().get(v))) {
if(!B.isAir(getBlocks().get(v))) {
getBlocks().computeIfAbsent(v, (vv) -> vair);
applied.getAndIncrement();
}
@@ -248,25 +248,25 @@ public class IrisObject extends IrisRegistrant {
}
// Smash Z
for (int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) {
for(int rayX = min.getBlockX(); rayX <= max.getBlockX(); rayX++) {
int finalRayX = rayX;
burst.queue(() -> {
for (int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) {
for(int rayY = min.getBlockY(); rayY <= max.getBlockY(); rayY++) {
int start = Integer.MAX_VALUE;
int end = Integer.MIN_VALUE;
for (int ray = min.getBlockZ(); ray <= max.getBlockZ(); ray++) {
if (getBlocks().containsKey(new BlockVector(finalRayX, rayY, ray))) {
for(int ray = min.getBlockZ(); ray <= max.getBlockZ(); ray++) {
if(getBlocks().containsKey(new BlockVector(finalRayX, rayY, ray))) {
start = Math.min(ray, start);
end = Math.max(ray, end);
}
}
if (start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for (int i = start; i <= end; i++) {
if(start != Integer.MAX_VALUE && end != Integer.MIN_VALUE) {
for(int i = start; i <= end; i++) {
BlockVector v = new BlockVector(finalRayX, rayY, i);
if (!B.isAir(getBlocks().get(v))) {
if(!B.isAir(getBlocks().get(v))) {
getBlocks().computeIfAbsent(v, (vv) -> vair);
applied.getAndIncrement();
}
@@ -287,11 +287,11 @@ public class IrisObject extends IrisRegistrant {
o.setLoadKey(o.getLoadKey());
o.setCenter(getCenter().clone());
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
o.getBlocks().put(i.clone(), Objects.requireNonNull(getBlocks().get(i)).clone());
}
for (BlockVector i : getStates().keySet()) {
for(BlockVector i : getStates().keySet()) {
o.getStates().put(i.clone(), Objects.requireNonNull(getStates().get(i)).clone());
}
@@ -306,17 +306,17 @@ public class IrisObject extends IrisRegistrant {
center = new BlockVector(w / 2, h / 2, d / 2);
int s = din.readInt();
for (int i = 0; i < s; i++) {
for(int i = 0; i < s; i++) {
getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(din.readUTF()));
}
try {
int size = din.readInt();
for (int i = 0; i < size; i++) {
for(int i = 0; i < size; i++) {
getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -327,7 +327,7 @@ public class IrisObject extends IrisRegistrant {
this.w = din.readInt();
this.h = din.readInt();
this.d = din.readInt();
if (!din.readUTF().equals("Iris V2 IOB;")) {
if(!din.readUTF().equals("Iris V2 IOB;")) {
return;
}
center = new BlockVector(w / 2, h / 2, d / 2);
@@ -335,19 +335,19 @@ public class IrisObject extends IrisRegistrant {
int i;
KList<String> palette = new KList<>();
for (i = 0; i < s; i++) {
for(i = 0; i < s; i++) {
palette.add(din.readUTF());
}
s = din.readInt();
for (i = 0; i < s; i++) {
for(i = 0; i < s; i++) {
getBlocks().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), B.get(palette.get(din.readShort())));
}
s = din.readInt();
for (i = 0; i < s; i++) {
for(i = 0; i < s; i++) {
getStates().put(new BlockVector(din.readShort(), din.readShort(), din.readShort()), TileData.read(din));
}
}
@@ -360,19 +360,19 @@ public class IrisObject extends IrisRegistrant {
dos.writeUTF("Iris V2 IOB;");
KList<String> palette = new KList<>();
for (BlockData i : getBlocks().values()) {
for(BlockData i : getBlocks().values()) {
palette.addIfMissing(i.getAsString());
}
dos.writeShort(palette.size());
for (String i : palette) {
for(String i : palette) {
dos.writeUTF(i);
}
dos.writeInt(getBlocks().size());
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
dos.writeShort(i.getBlockX());
dos.writeShort(i.getBlockY());
dos.writeShort(i.getBlockZ());
@@ -380,7 +380,7 @@ public class IrisObject extends IrisRegistrant {
}
dos.writeInt(getStates().size());
for (BlockVector i : getStates().keySet()) {
for(BlockVector i : getStates().keySet()) {
dos.writeShort(i.getBlockX());
dos.writeShort(i.getBlockY());
dos.writeShort(i.getBlockZ());
@@ -393,7 +393,7 @@ public class IrisObject extends IrisRegistrant {
try {
read(fin);
fin.close();
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
fin.close();
fin = new FileInputStream(file);
@@ -403,7 +403,7 @@ public class IrisObject extends IrisRegistrant {
}
public void write(File file) throws IOException {
if (file == null) {
if(file == null) {
return;
}
@@ -416,7 +416,7 @@ public class IrisObject extends IrisRegistrant {
BlockVector min = new BlockVector();
BlockVector max = new BlockVector();
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
min.setX(Math.min(min.getX(), i.getX()));
min.setY(Math.min(min.getY(), i.getY()));
min.setZ(Math.min(min.getZ(), i.getZ()));
@@ -433,17 +433,17 @@ public class IrisObject extends IrisRegistrant {
public void clean() {
KMap<BlockVector, BlockData> d = new KMap<>();
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
}
KMap<BlockVector, TileData<? extends TileState>> dx = new KMap<>();
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
d.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getBlocks().get(i)));
}
for (BlockVector i : getStates().keySet()) {
for(BlockVector i : getStates().keySet()) {
dx.put(new BlockVector(i.getBlockX(), i.getBlockY(), i.getBlockZ()), Objects.requireNonNull(getStates().get(i)));
}
@@ -452,7 +452,7 @@ public class IrisObject extends IrisRegistrant {
}
public BlockVector getSigned(int x, int y, int z) {
if (x >= w || y >= h || z >= d) {
if(x >= w || y >= h || z >= d) {
throw new RuntimeException(x + " " + y + " " + z + " exceeds limit of " + w + " " + h + " " + d);
}
@@ -462,7 +462,7 @@ public class IrisObject extends IrisRegistrant {
public void setUnsigned(int x, int y, int z, BlockData block) {
BlockVector v = getSigned(x, y, z);
if (block == null) {
if(block == null) {
getBlocks().remove(v);
getStates().remove(v);
} else {
@@ -473,14 +473,14 @@ public class IrisObject extends IrisRegistrant {
public void setUnsigned(int x, int y, int z, Block block) {
BlockVector v = getSigned(x, y, z);
if (block == null) {
if(block == null) {
getBlocks().remove(v);
getStates().remove(v);
} else {
BlockData data = block.getBlockData();
getBlocks().put(v, data);
TileData<? extends TileState> state = TileData.getTileState(block);
if (state != null) {
if(state != null) {
Iris.info("Saved State " + v);
getStates().put(v, state);
}
@@ -506,7 +506,7 @@ public class IrisObject extends IrisRegistrant {
public int place(int x, int yv, int z, IObjectPlacer oplacer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener, CarveResult c, IrisData rdata) {
IObjectPlacer placer = (config.getHeightmap() != null) ? new HeightmapObjectPlacer(oplacer.getEngine() == null ? IrisContext.get().getEngine() : oplacer.getEngine(), rng, x, yv, z, config, oplacer) : oplacer;
if (config.isSmartBore()) {
if(config.isSmartBore()) {
ensureSmartBored(placer.isDebugSmartBore());
}
@@ -524,127 +524,127 @@ public class IrisObject extends IrisRegistrant {
yrand = yrand > 0 ? rng.i(0, yrand) : yrand < 0 ? rng.i(yrand, 0) : yrand;
boolean bail = false;
if (yv < 0) {
if (config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) {
if(yv < 0) {
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) {
y = (c != null ? c.getSurface() : placer.getHighest(x, z, getLoader(), config.isUnderwater())) + rty;
if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
bail = true;
}
} else if (config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
} else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
bail = true;
break;
}
if (h > y) {
if(h > y) {
y = h;
}
}
}
} else if (config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) {
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT)) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
bail = true;
break;
}
if (h > y) {
if(h > y) {
y = h;
}
}
}
} else if (config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) {
} else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT)) {
y = 257;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
bail = true;
break;
}
if (h < y) {
if(h < y) {
y = h;
}
}
}
} else if (config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) {
} else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT)) {
y = 257;
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
for(int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
for(int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
if (placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
if(placer.isCarved(i, h, j) || placer.isCarved(i, h - 1, j) || placer.isCarved(i, h - 2, j) || placer.isCarved(i, h - 3, j)) {
bail = true;
break;
}
if (h < y) {
if(h < y) {
y = h;
}
}
}
} else if (config.getMode().equals(ObjectPlaceMode.PAINT)) {
} else if(config.getMode().equals(ObjectPlaceMode.PAINT)) {
y = placer.getHighest(x, z, getLoader(), config.isUnderwater()) + rty;
if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
bail = true;
}
}
} else {
y = yv;
if (placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
if(placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z)) {
bail = true;
}
}
if (yv >= 0 && config.isBottom()) {
if(yv >= 0 && config.isBottom()) {
y += Math.floorDiv(h, 2);
bail = placer.isCarved(x, y, z) || placer.isCarved(x, y - 1, z) || placer.isCarved(x, y - 2, z) || placer.isCarved(x, y - 3, z);
}
if (bail) {
if(bail) {
return -1;
}
if (yv < 0) {
if (!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z)) {
if(yv < 0) {
if(!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z)) {
return -1;
}
}
if (c != null && Math.max(0, h + yrand + ty) + 1 >= c.getHeight()) {
if(c != null && Math.max(0, h + yrand + ty) + 1 >= c.getHeight()) {
return -1;
}
if (config.isUnderwater() && y + rty + ty >= placer.getFluidHeight()) {
if(config.isUnderwater() && y + rty + ty >= placer.getFluidHeight()) {
return -1;
}
if (!config.getClamp().canPlace(y + rty + ty, y - rty + ty)) {
if(!config.getClamp().canPlace(y + rty + ty, y - rty + ty)) {
return -1;
}
if (config.isBore()) {
if(config.isBore()) {
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
for (int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) {
for (int j = y - Math.floorDiv(h, 2) - config.getBoreExtendMinY() + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) + config.getBoreExtendMaxY() - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) {
for (int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) {
for(int i = x - Math.floorDiv(w, 2) + (int) offset.getX(); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0) + (int) offset.getX(); i++) {
for(int j = y - Math.floorDiv(h, 2) - config.getBoreExtendMinY() + (int) offset.getY(); j <= y + Math.floorDiv(h, 2) + config.getBoreExtendMaxY() - (h % 2 == 0 ? 1 : 0) + (int) offset.getY(); j++) {
for(int k = z - Math.floorDiv(d, 2) + (int) offset.getZ(); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0) + (int) offset.getX(); k++) {
placer.set(i, j, k, AIR);
}
}
@@ -658,34 +658,34 @@ public class IrisObject extends IrisRegistrant {
KMap<BlockVector, String> markers = null;
try {
if (config.getMarkers().isNotEmpty() && placer.getEngine() != null) {
if(config.getMarkers().isNotEmpty() && placer.getEngine() != null) {
markers = new KMap<>();
for (IrisObjectMarker j : config.getMarkers()) {
for(IrisObjectMarker j : config.getMarkers()) {
IrisMarker marker = getLoader().getMarkerLoader().load(j.getMarker());
if (marker == null) {
if(marker == null) {
continue;
}
int max = j.getMaximumMarkers();
for (BlockVector i : getBlocks().k().shuffle()) {
if (max <= 0) {
for(BlockVector i : getBlocks().k().shuffle()) {
if(max <= 0) {
break;
}
BlockData data = getBlocks().get(i);
for (BlockData k : j.getMark(rdata)) {
if (max <= 0) {
for(BlockData k : j.getMark(rdata)) {
if(max <= 0) {
break;
}
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
boolean a = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 1, 0))));
boolean fff = !blocks.containsKey(new BlockVector(i.clone().add(new BlockVector(0, 2, 0))));
if ((marker.isEmptyAbove() && a && fff) || !marker.isEmptyAbove()) {
if(!marker.isEmptyAbove() || (a && fff)) {
markers.put(i, j.getMarker());
max--;
}
@@ -695,20 +695,20 @@ public class IrisObject extends IrisRegistrant {
}
}
for (BlockVector g : getBlocks().keySet()) {
for(BlockVector g : getBlocks().keySet()) {
BlockData d;
TileData<? extends TileState> tile = null;
try {
d = getBlocks().get(g);
tile = getStates().get(g);
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (cme)");
d = AIR;
}
if (d == null) {
if(d == null) {
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (null)");
d = AIR;
}
@@ -718,21 +718,21 @@ public class IrisObject extends IrisRegistrant {
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
if (stilting && i.getBlockY() < lowest && !B.isAir(data)) {
if(stilting && i.getBlockY() < lowest && !B.isAir(data)) {
lowest = i.getBlockY();
}
if (placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
if(placer.isPreventingDecay() && (data) instanceof Leaves && !((Leaves) (data)).isPersistent()) {
((Leaves) data).setPersistent(true);
}
for (IrisObjectReplace j : config.getEdit()) {
if (rng.chance(j.getChance())) {
for (BlockData k : j.getFind(rdata)) {
if (j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
for(IrisObjectReplace j : config.getEdit()) {
if(rng.chance(j.getChance())) {
for(BlockData k : j.getFind(rdata)) {
if(j.isExact() ? k.matches(data) : k.getMaterial().equals(data.getMaterial())) {
BlockData newData = j.getReplace(rng, i.getX() + x, i.getY() + y, i.getZ() + z, rdata).clone();
if (newData.getMaterial() == data.getMaterial()) {
if(newData.getMaterial() == data.getMaterial()) {
data = data.merge(newData);
} else {
data = newData;
@@ -747,70 +747,70 @@ public class IrisObject extends IrisRegistrant {
int yy = y + (int) Math.round(i.getY());
zz = z + (int) Math.round(i.getZ());
if (warped) {
if(warped) {
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader());
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader());
}
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
if(yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, getLoader(), config.isUnderwater());
}
if (heightmap != null) {
if(heightmap != null) {
Position2 pos = new Position2(xx, zz);
if (!heightmap.containsKey(pos)) {
if(!heightmap.containsKey(pos)) {
heightmap.put(pos, yy);
}
if (heightmap.get(pos) < yy) {
if(heightmap.get(pos) < yy) {
heightmap.put(pos, yy);
}
}
if (config.isMeld() && !placer.isSolid(xx, yy, zz)) {
if(config.isMeld() && !placer.isSolid(xx, yy, zz)) {
continue;
}
if (config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
if(config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged) {
((Waterlogged) data).setWaterlogged(true);
}
if (listener != null) {
if(listener != null) {
listener.accept(new BlockPosition(xx, yy, zz));
}
if (markers != null && markers.containsKey(g)) {
if(markers != null && markers.containsKey(g)) {
placer.getEngine().getMantle().getMantle().set(xx, yy, zz, new MatterMarker(markers.get(g)));
}
if (!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
if(!data.getMaterial().equals(Material.AIR) && !data.getMaterial().equals(Material.CAVE_AIR)) {
placer.set(xx, yy, zz, data);
if (tile != null) {
if(tile != null) {
placer.setTile(xx, yy, zz, tile);
}
}
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
readLock.unlock();
if (stilting) {
if(stilting) {
readLock.lock();
for (BlockVector g : getBlocks().keySet()) {
for(BlockVector g : getBlocks().keySet()) {
BlockData d;
try {
d = getBlocks().get(g);
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt cme)");
d = AIR;
}
if (d == null) {
if(d == null) {
Iris.warn("Failed to read block node " + g.getBlockX() + "," + g.getBlockY() + "," + g.getBlockZ() + " in object " + getLoadKey() + " (stilt null)");
d = AIR;
}
@@ -819,30 +819,30 @@ public class IrisObject extends IrisRegistrant {
i = config.getRotation().rotate(i.clone(), spinx, spiny, spinz).clone();
i = config.getTranslate().translate(i.clone(), config.getRotation(), spinx, spiny, spinz).clone();
if (i.getBlockY() != lowest) {
if(i.getBlockY() != lowest) {
continue;
}
if (d == null || B.isAir(d)) {
if(d == null || B.isAir(d)) {
continue;
}
xx = x + (int) Math.round(i.getX());
zz = z + (int) Math.round(i.getZ());
if (warped) {
if(warped) {
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader());
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader());
}
int yg = placer.getHighest(xx, zz, getLoader(), config.isUnderwater());
if (yv >= 0 && config.isBottom()) {
if(yv >= 0 && config.isBottom()) {
y += Math.floorDiv(h, 2);
}
for (int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) {
for(int j = lowest + y; j > yg - config.getOverStilt() - 1; j--) {
placer.set(xx, j, zz, d);
}
}
@@ -850,15 +850,15 @@ public class IrisObject extends IrisRegistrant {
readLock.unlock();
}
if (heightmap != null) {
if(heightmap != null) {
RNG rngx = rng.nextParallelRNG(3468854);
for (Position2 i : heightmap.k()) {
for(Position2 i : heightmap.k()) {
int vx = i.getX();
int vy = heightmap.get(i);
int vz = i.getZ();
if (config.getSnow() > 0) {
if(config.getSnow() > 0) {
int height = rngx.i(0, (int) (config.getSnow() * 7));
placer.set(vx, vy + 1, vz, SNOW_LAYERS[Math.max(Math.min(height, 7), 0)]);
}
@@ -877,14 +877,14 @@ public class IrisObject extends IrisRegistrant {
public void rotate(IrisObjectRotation r, int spinx, int spiny, int spinz) {
KMap<BlockVector, BlockData> d = new KMap<>();
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
d.put(r.rotate(i.clone(), spinx, spiny, spinz), r.rotate(getBlocks().get(i).clone(),
spinx, spiny, spinz));
spinx, spiny, spinz));
}
KMap<BlockVector, TileData<? extends TileState>> dx = new KMap<>();
for (BlockVector i : getStates().keySet()) {
for(BlockVector i : getStates().keySet()) {
dx.put(r.rotate(i.clone(), spinx, spiny, spinz), getStates().get(i));
}
@@ -893,11 +893,11 @@ public class IrisObject extends IrisRegistrant {
}
public void place(Location at) {
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
Block b = at.clone().add(0, getCenter().getY(), 0).add(i).getBlock();
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
if (getStates().containsKey(i)) {
if(getStates().containsKey(i)) {
Iris.info(Objects.requireNonNull(states.get(i)).toString());
BlockState st = b.getState();
Objects.requireNonNull(getStates().get(i)).toBukkitTry(st);
@@ -907,11 +907,11 @@ public class IrisObject extends IrisRegistrant {
}
public void placeCenterY(Location at) {
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
Block b = at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock();
b.setBlockData(Objects.requireNonNull(getBlocks().get(i)), false);
if (getStates().containsKey(i)) {
if(getStates().containsKey(i)) {
Objects.requireNonNull(getStates().get(i)).toBukkitTry(b.getState());
}
}
@@ -926,7 +926,7 @@ public class IrisObject extends IrisRegistrant {
}
public void unplaceCenterY(Location at) {
for (BlockVector i : getBlocks().keySet()) {
for(BlockVector i : getBlocks().keySet()) {
at.clone().add(getCenter().getX(), getCenter().getY(), getCenter().getZ()).add(i).getBlock().setBlockData(AIR, false);
}
}
@@ -934,7 +934,7 @@ public class IrisObject extends IrisRegistrant {
public IrisObject scaled(double scale, IrisObjectPlacementScaleInterpolator interpolation) {
Vector sm1 = new Vector(scale - 1, scale - 1, scale - 1);
scale = Math.max(0.001, Math.min(50, scale));
if (scale < 1) {
if(scale < 1) {
scale = scale - 0.0001;
}
@@ -943,28 +943,28 @@ public class IrisObject extends IrisRegistrant {
@SuppressWarnings({"unchecked", "rawtypes"}) HashMap<BlockVector, BlockData> placeBlock = new HashMap();
Vector center = getCenter();
if (getH() == 2) {
if(getH() == 2) {
center = center.setY(center.getBlockY() + 0.5);
}
if (getW() == 2) {
if(getW() == 2) {
center = center.setX(center.getBlockX() + 0.5);
}
if (getD() == 2) {
if(getD() == 2) {
center = center.setZ(center.getBlockZ() + 0.5);
}
IrisObject oo = new IrisObject((int) Math.ceil((w * scale) + (scale * 2)), (int) Math.ceil((h * scale) + (scale * 2)), (int) Math.ceil((d * scale) + (scale * 2)));
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
for(Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
BlockData bd = entry.getValue();
placeBlock.put(entry.getKey().clone().add(HALF).subtract(center)
.multiply(scale).add(sm1).toBlockVector(), bd);
.multiply(scale).add(sm1).toBlockVector(), bd);
}
for (Map.Entry<BlockVector, BlockData> entry : placeBlock.entrySet()) {
for(Map.Entry<BlockVector, BlockData> entry : placeBlock.entrySet()) {
BlockVector v = entry.getKey();
if (scale > 1) {
for (BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) {
if(scale > 1) {
for(BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) {
oo.getBlocks().put(vec, entry.getValue());
}
} else {
@@ -972,8 +972,8 @@ public class IrisObject extends IrisRegistrant {
}
}
if (scale > 1) {
switch (interpolation) {
if(scale > 1) {
switch(interpolation) {
case TRILINEAR -> oo.trilinear((int) Math.round(scale));
case TRICUBIC -> oo.tricubic((int) Math.round(scale));
case TRIHERMITE -> oo.trihermite((int) Math.round(scale));
@@ -989,13 +989,13 @@ public class IrisObject extends IrisRegistrant {
BlockVector min = getAABB().minbv();
BlockVector max = getAABB().maxbv();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if (IrisInterpolation.getTrilinear(x, y, z, rad, (xx, yy, zz) -> {
for(int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for(int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if(IrisInterpolation.getTrilinear(x, y, z, rad, (xx, yy, zz) -> {
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
if (data == null || data.getMaterial().isAir()) {
if(data == null || data.getMaterial().isAir()) {
return 0;
}
@@ -1018,13 +1018,13 @@ public class IrisObject extends IrisRegistrant {
BlockVector min = getAABB().minbv();
BlockVector max = getAABB().maxbv();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if (IrisInterpolation.getTricubic(x, y, z, rad, (xx, yy, zz) -> {
for(int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for(int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if(IrisInterpolation.getTricubic(x, y, z, rad, (xx, yy, zz) -> {
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
if (data == null || data.getMaterial().isAir()) {
if(data == null || data.getMaterial().isAir()) {
return 0;
}
@@ -1051,13 +1051,13 @@ public class IrisObject extends IrisRegistrant {
BlockVector min = getAABB().minbv();
BlockVector max = getAABB().maxbv();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if (IrisInterpolation.getTrihermite(x, y, z, rad, (xx, yy, zz) -> {
for(int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for(int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
if(IrisInterpolation.getTrihermite(x, y, z, rad, (xx, yy, zz) -> {
BlockData data = v.get(new BlockVector((int) xx, (int) yy, (int) zz));
if (data == null || data.getMaterial().isAir()) {
if(data == null || data.getMaterial().isAir()) {
return 0;
}
@@ -1078,22 +1078,22 @@ public class IrisObject extends IrisRegistrant {
BlockVector vv = new BlockVector(x, y, z);
BlockData r = getBlocks().get(vv);
if (r != null && !r.getMaterial().isAir()) {
if(r != null && !r.getMaterial().isAir()) {
return r;
}
double d = Double.MAX_VALUE;
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
for(Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
BlockData dat = entry.getValue();
if (dat.getMaterial().isAir()) {
if(dat.getMaterial().isAir()) {
continue;
}
double dx = entry.getKey().distanceSquared(vv);
if (dx < d) {
if(dx < d) {
d = dx;
r = dat;
}

View File

@@ -57,10 +57,10 @@ public class IrisObjectLoot {
{
KList<BlockData> b = new KList<>();
for (IrisBlockData i : filter) {
for(IrisBlockData i : filter) {
BlockData bx = i.getBlockData(rdata);
if (bx != null) {
if(bx != null) {
b.add(bx);
}
}
@@ -70,8 +70,8 @@ public class IrisObjectLoot {
}
public boolean matchesFilter(IrisData manager, BlockData data) {
for (BlockData filterData : getFilter(manager)) {
if (filterData.matches(data)) return true;
for(BlockData filterData : getFilter(manager)) {
if(filterData.matches(data)) return true;
}
return false;
}

View File

@@ -66,10 +66,10 @@ public class IrisObjectMarker {
{
KList<BlockData> b = new KList<>();
for (IrisBlockData i : mark) {
for(IrisBlockData i : mark) {
BlockData bx = i.getBlockData(rdata);
if (bx != null) {
if(bx != null) {
b.add(bx);
}
}

View File

@@ -158,7 +158,7 @@ public class IrisObjectPlacement {
public CNG getSurfaceWarp(RNG rng, IrisData data) {
return surfaceWarp.aquire(() ->
getWarp().create(rng, data));
getWarp().create(rng, data));
}
public double warp(RNG rng, double x, double y, double z, IrisData data) {
@@ -166,7 +166,7 @@ public class IrisObjectPlacement {
}
public IrisObject getObject(DataProvider g, RNG random) {
if (place.isEmpty()) {
if(place.isEmpty()) {
return null;
}
@@ -174,8 +174,8 @@ public class IrisObjectPlacement {
}
public boolean matches(IrisTreeSize size, TreeType type) {
for (IrisTree i : getTrees()) {
if (i.matches(size, type)) {
for(IrisTree i : getTrees()) {
if(i.matches(size, type)) {
return true;
}
}
@@ -184,14 +184,14 @@ public class IrisObjectPlacement {
}
public int getDensity() {
if (densityStyle == null) {
if(densityStyle == null) {
return density;
}
return densityStyle.getMid();
}
public int getDensity(RNG rng, double x, double z, IrisData data) {
if (densityStyle == null) {
if(densityStyle == null) {
return density;
}
@@ -202,20 +202,20 @@ public class IrisObjectPlacement {
return cache.aquire(() -> {
TableCache tc = new TableCache();
for (IrisObjectLoot loot : getLoot()) {
for(IrisObjectLoot loot : getLoot()) {
IrisLootTable table = manager.getLootLoader().load(loot.getName());
if (table == null) {
if(table == null) {
Iris.warn("Couldn't find loot table " + loot.getName());
continue;
}
if (loot.getFilter().isEmpty()) //Table applies to all containers
if(loot.getFilter().isEmpty()) //Table applies to all containers
{
tc.global.put(table, loot.getWeight());
} else if (!loot.isExact()) //Table is meant to be by type
} else if(!loot.isExact()) //Table is meant to be by type
{
for (BlockData filterData : loot.getFilter(manager)) {
if (!tc.basic.containsKey(filterData.getMaterial())) {
for(BlockData filterData : loot.getFilter(manager)) {
if(!tc.basic.containsKey(filterData.getMaterial())) {
tc.basic.put(filterData.getMaterial(), new WeightedRandom<>());
}
@@ -223,12 +223,12 @@ public class IrisObjectPlacement {
}
} else //Filter is exact
{
for (BlockData filterData : loot.getFilter(manager)) {
if (!tc.exact.containsKey(filterData.getMaterial())) {
for(BlockData filterData : loot.getFilter(manager)) {
if(!tc.exact.containsKey(filterData.getMaterial())) {
tc.exact.put(filterData.getMaterial(), new KMap<>());
}
if (!tc.exact.get(filterData.getMaterial()).containsKey(filterData)) {
if(!tc.exact.get(filterData.getMaterial()).containsKey(filterData)) {
tc.exact.get(filterData.getMaterial()).put(filterData, new WeightedRandom<>());
}
@@ -243,20 +243,22 @@ public class IrisObjectPlacement {
/**
* Gets the loot table that should be used for the block
*
* @param data The block data of the block
* @param dataManager Iris Data Manager
* @param data
* The block data of the block
* @param dataManager
* Iris Data Manager
* @return The loot table it should use.
*/
public IrisLootTable getTable(BlockData data, IrisData dataManager) {
TableCache cache = getCache(dataManager);
if (B.isStorageChest(data)) {
if(B.isStorageChest(data)) {
IrisLootTable picked = null;
if (cache.exact.containsKey(data.getMaterial()) && cache.exact.containsKey(data)) {
if(cache.exact.containsKey(data.getMaterial()) && cache.exact.containsKey(data)) {
picked = cache.exact.get(data.getMaterial()).get(data).pullRandom();
} else if (cache.basic.containsKey(data.getMaterial())) {
} else if(cache.basic.containsKey(data.getMaterial())) {
picked = cache.basic.get(data.getMaterial()).pullRandom();
} else if (cache.global.getSize() > 0) {
} else if(cache.global.getSize() > 0) {
picked = cache.global.pullRandom();
}

View File

@@ -64,10 +64,10 @@ public class IrisObjectReplace {
{
KList<BlockData> b = new KList<>();
for (IrisBlockData i : find) {
for(IrisBlockData i : find) {
BlockData bx = i.getBlockData(rdata);
if (bx != null) {
if(bx != null) {
b.add(bx);
}
}

View File

@@ -92,7 +92,7 @@ public class IrisObjectRotation {
}
public IrisObject rotateCopy(IrisObject e) {
if (e == null) {
if(e == null) {
return null;
}
@@ -101,7 +101,7 @@ public class IrisObjectRotation {
public IrisJigsawPiece rotateCopy(IrisJigsawPiece v) {
IrisJigsawPiece piece = v.copy();
for (IrisJigsawPieceConnector i : piece.getConnectors()) {
for(IrisJigsawPieceConnector i : piece.getConnectors()) {
i.setPosition(rotate(i.getPosition()));
i.setDirection(rotate(i.getDirection()));
}
@@ -119,11 +119,11 @@ public class IrisObjectRotation {
}
public double getRotation(int spin, IrisAxisRotationClamp clamp) {
if (!enabled) {
if(!enabled) {
return 0;
}
if (!clamp.isEnabled()) {
if(!clamp.isEnabled()) {
return 0;
}
@@ -135,27 +135,27 @@ public class IrisObjectRotation {
int y = (int) Math.round(v.getY());
int z = (int) Math.round(v.getZ());
if (x == 0 && z == -1) {
if(x == 0 && z == -1) {
return BlockFace.NORTH;
}
if (x == 0 && z == 1) {
if(x == 0 && z == 1) {
return BlockFace.SOUTH;
}
if (x == 1 && z == 0) {
if(x == 1 && z == 0) {
return BlockFace.EAST;
}
if (x == -1 && z == 0) {
if(x == -1 && z == 0) {
return BlockFace.WEST;
}
if (y > 0) {
if(y > 0) {
return BlockFace.UP;
}
if (y < 0) {
if(y < 0) {
return BlockFace.DOWN;
}
@@ -167,28 +167,28 @@ public class IrisObjectRotation {
int y = v.getBlockY();
int z = v.getBlockZ();
if (x == 0 && z == -1) return BlockFace.NORTH;
if (x == 1 && z == -2) return BlockFace.NORTH_NORTH_EAST;
if (x == 1 && z == -1) return BlockFace.NORTH_EAST;
if (x == 2 && z == -1) return BlockFace.EAST_NORTH_EAST;
if (x == 1 && z == 0) return BlockFace.EAST;
if (x == 2 && z == 1) return BlockFace.EAST_SOUTH_EAST;
if (x == 1 && z == 1) return BlockFace.SOUTH_EAST;
if (x == 1 && z == 2) return BlockFace.SOUTH_SOUTH_EAST;
if (x == 0 && z == 1) return BlockFace.SOUTH;
if (x == -1 && z == 2) return BlockFace.SOUTH_SOUTH_WEST;
if (x == -1 && z == 1) return BlockFace.SOUTH_WEST;
if (x == -2 && z == 1) return BlockFace.WEST_SOUTH_WEST;
if (x == -1 && z == 0) return BlockFace.WEST;
if (x == -2 && z == -1) return BlockFace.WEST_NORTH_WEST;
if (x == -1 && z == -1) return BlockFace.NORTH_WEST;
if (x == -1 && z == -2) return BlockFace.NORTH_NORTH_WEST;
if(x == 0 && z == -1) return BlockFace.NORTH;
if(x == 1 && z == -2) return BlockFace.NORTH_NORTH_EAST;
if(x == 1 && z == -1) return BlockFace.NORTH_EAST;
if(x == 2 && z == -1) return BlockFace.EAST_NORTH_EAST;
if(x == 1 && z == 0) return BlockFace.EAST;
if(x == 2 && z == 1) return BlockFace.EAST_SOUTH_EAST;
if(x == 1 && z == 1) return BlockFace.SOUTH_EAST;
if(x == 1 && z == 2) return BlockFace.SOUTH_SOUTH_EAST;
if(x == 0 && z == 1) return BlockFace.SOUTH;
if(x == -1 && z == 2) return BlockFace.SOUTH_SOUTH_WEST;
if(x == -1 && z == 1) return BlockFace.SOUTH_WEST;
if(x == -2 && z == 1) return BlockFace.WEST_SOUTH_WEST;
if(x == -1 && z == 0) return BlockFace.WEST;
if(x == -2 && z == -1) return BlockFace.WEST_NORTH_WEST;
if(x == -1 && z == -1) return BlockFace.NORTH_WEST;
if(x == -1 && z == -2) return BlockFace.NORTH_NORTH_WEST;
if (y > 0) {
if(y > 0) {
return BlockFace.UP;
}
if (y < 0) {
if(y < 0) {
return BlockFace.DOWN;
}
@@ -196,7 +196,7 @@ public class IrisObjectRotation {
}
public BlockFace faceForAxis(Axis axis) {
return switch (axis) {
return switch(axis) {
case X -> BlockFace.EAST;
case Y -> BlockFace.UP;
case Z -> BlockFace.NORTH;
@@ -205,7 +205,7 @@ public class IrisObjectRotation {
}
public Axis axisFor(BlockFace f) {
return switch (f) {
return switch(f) {
case NORTH, SOUTH -> Axis.Z;
case EAST, WEST -> Axis.X;
default -> Axis.Y;
@@ -214,7 +214,7 @@ public class IrisObjectRotation {
}
public Axis axisFor2D(BlockFace f) {
return switch (f) {
return switch(f) {
case EAST, WEST, UP, DOWN -> Axis.X;
default -> Axis.Z;
};
@@ -228,22 +228,22 @@ public class IrisObjectRotation {
int spiny = (int) (90D * (Math.ceil(Math.abs((spinyy % 360D) / 90D))));
int spinz = (int) (90D * (Math.ceil(Math.abs((spinzz % 360D) / 90D))));
if (!canRotate()) {
if(!canRotate()) {
return d;
}
if (d instanceof Directional g) {
if(d instanceof Directional g) {
BlockFace f = g.getFacing();
BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ());
bv = rotate(bv.clone(), spinx, spiny, spinz);
BlockFace t = getFace(bv);
if (g.getFaces().contains(t)) {
if(g.getFaces().contains(t)) {
g.setFacing(t);
} else if (!g.getMaterial().isSolid()) {
} else if(!g.getMaterial().isSolid()) {
d = null;
}
} else if (d instanceof Rotatable g) {
} else if(d instanceof Rotatable g) {
BlockFace f = g.getRotation();
BlockVector bv = new BlockVector(f.getModX(), 0, f.getModZ());
@@ -252,36 +252,36 @@ public class IrisObjectRotation {
g.setRotation(face);
} else if (d instanceof Orientable) {
} else if(d instanceof Orientable) {
BlockFace f = getFace(((Orientable) d).getAxis());
BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ());
bv = rotate(bv.clone(), spinx, spiny, spinz);
Axis a = getAxis(bv);
if (!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) {
if(!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) {
((Orientable) d).setAxis(a);
}
} else if (d instanceof MultipleFacing g) {
} else if(d instanceof MultipleFacing g) {
List<BlockFace> faces = new KList<>();
for (BlockFace i : g.getFaces()) {
for(BlockFace i : g.getFaces()) {
BlockVector bv = new BlockVector(i.getModX(), i.getModY(), i.getModZ());
bv = rotate(bv.clone(), spinx, spiny, spinz);
BlockFace r = getFace(bv);
if (g.getAllowedFaces().contains(r)) {
if(g.getAllowedFaces().contains(r)) {
faces.add(r);
}
}
for (BlockFace i : g.getFaces()) {
for(BlockFace i : g.getFaces()) {
g.setFace(i, false);
}
for (BlockFace i : faces) {
for(BlockFace i : faces) {
g.setFace(i, true);
}
} else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) {
} else if(d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) {
//TODO: Fucks up logs
BlockFace f = faceForAxis(g.getAxis());
BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ());
@@ -290,7 +290,7 @@ public class IrisObjectRotation {
Axis a = !g.getAxes().contains(Axis.Y) ? axisFor(t) : axisFor2D(t);
((Orientable) d).setAxis(a);
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -299,15 +299,15 @@ public class IrisObjectRotation {
}
public Axis getAxis(BlockVector v) {
if (Math.abs(v.getBlockX()) > Math.max(Math.abs(v.getBlockY()), Math.abs(v.getBlockZ()))) {
if(Math.abs(v.getBlockX()) > Math.max(Math.abs(v.getBlockY()), Math.abs(v.getBlockZ()))) {
return Axis.X;
}
if (Math.abs(v.getBlockY()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockZ()))) {
if(Math.abs(v.getBlockY()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockZ()))) {
return Axis.Y;
}
if (Math.abs(v.getBlockZ()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockY()))) {
if(Math.abs(v.getBlockZ()) > Math.max(Math.abs(v.getBlockX()), Math.abs(v.getBlockY()))) {
return Axis.Z;
}
@@ -315,7 +315,7 @@ public class IrisObjectRotation {
}
private BlockFace getFace(Axis axis) {
return switch (axis) {
return switch(axis) {
case X -> BlockFace.EAST;
case Y -> BlockFace.UP;
case Z -> BlockFace.SOUTH;
@@ -331,22 +331,22 @@ public class IrisObjectRotation {
}
public BlockVector rotate(BlockVector b, int spinx, int spiny, int spinz) {
if (!canRotate()) {
if(!canRotate()) {
return b;
}
BlockVector v = b.clone();
if (canRotateX()) {
if (getXAxis().isLocked()) {
if (Math.abs(getXAxis().getMax()) % 360D == 180D) {
if(canRotateX()) {
if(getXAxis().isLocked()) {
if(Math.abs(getXAxis().getMax()) % 360D == 180D) {
v.setZ(-v.getZ());
v.setY(-v.getY());
} else if (getXAxis().getMax() % 360D == 90D || getXAxis().getMax() % 360D == -270D) {
} else if(getXAxis().getMax() % 360D == 90D || getXAxis().getMax() % 360D == -270D) {
double z = v.getZ();
v.setZ(v.getY());
v.setY(-z);
} else if (getXAxis().getMax() == -90D || getXAxis().getMax() % 360D == 270D) {
} else if(getXAxis().getMax() == -90D || getXAxis().getMax() % 360D == 270D) {
double z = v.getZ();
v.setZ(-v.getY());
v.setY(z);
@@ -358,16 +358,16 @@ public class IrisObjectRotation {
}
}
if (canRotateZ()) {
if (getZAxis().isLocked()) {
if (Math.abs(getZAxis().getMax()) % 360D == 180D) {
if(canRotateZ()) {
if(getZAxis().isLocked()) {
if(Math.abs(getZAxis().getMax()) % 360D == 180D) {
v.setY(-v.getY());
v.setX(-v.getX());
} else if (getZAxis().getMax() % 360D == 90D || getZAxis().getMax() % 360D == -270D) {
} else if(getZAxis().getMax() % 360D == 90D || getZAxis().getMax() % 360D == -270D) {
double y = v.getY();
v.setY(v.getX());
v.setX(-y);
} else if (getZAxis().getMax() == -90D || getZAxis().getMax() % 360D == 270D) {
} else if(getZAxis().getMax() == -90D || getZAxis().getMax() % 360D == 270D) {
double y = v.getY();
v.setY(-v.getX());
v.setX(y);
@@ -379,16 +379,16 @@ public class IrisObjectRotation {
}
}
if (canRotateY()) {
if (getYAxis().isLocked()) {
if (Math.abs(getYAxis().getMax()) % 360D == 180D) {
if(canRotateY()) {
if(getYAxis().isLocked()) {
if(Math.abs(getYAxis().getMax()) % 360D == 180D) {
v.setX(-v.getX());
v.setZ(-v.getZ());
} else if (getYAxis().getMax() % 360D == 90D || getYAxis().getMax() % 360D == -270D) {
} else if(getYAxis().getMax() % 360D == 90D || getYAxis().getMax() % 360D == -270D) {
double x = v.getX();
v.setX(v.getZ());
v.setZ(-x);
} else if (getYAxis().getMax() == -90D || getYAxis().getMax() % 360D == 270D) {
} else if(getYAxis().getMax() == -90D || getYAxis().getMax() % 360D == 270D) {
double x = v.getX();
v.setX(-v.getZ());
v.setZ(x);

View File

@@ -38,11 +38,11 @@ import lombok.experimental.Accessors;
@Data
public class IrisObjectScale {
private static transient ConcurrentLinkedHashMap<IrisObject, KList<IrisObject>> cache
= new ConcurrentLinkedHashMap.Builder<IrisObject, KList<IrisObject>>()
.initialCapacity(64)
.maximumWeightedCapacity(1024)
.concurrencyLevel(32)
.build();
= new ConcurrentLinkedHashMap.Builder<IrisObject, KList<IrisObject>>()
.initialCapacity(64)
.maximumWeightedCapacity(1024)
.concurrencyLevel(32)
.build();
@MinNumber(1)
@MaxNumber(32)
@Desc("Iris Objects are scaled and cached to speed up placements. Because of this extra memory is used, so we evenly distribute variations across the defined scale range, then pick one randomly. If the differences is small, use a lower number. For more possibilities on the scale spectrum, increase this at the cost of memory.")
@@ -69,7 +69,7 @@ public class IrisObjectScale {
public double getMaxScale() {
double mx = 0;
for (double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) {
for(double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) {
mx = i;
}
@@ -77,13 +77,13 @@ public class IrisObjectScale {
}
public IrisObject get(RNG rng, IrisObject origin) {
if (shouldScale()) {
if(shouldScale()) {
return origin;
}
return cache.computeIfAbsent(origin, (k) -> {
KList<IrisObject> c = new KList<>();
for (double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) {
for(double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) {
c.add(origin.scaled(i, getInterpolation()));
}

View File

@@ -62,7 +62,7 @@ public class IrisObjectTranslate {
}
public BlockVector translate(BlockVector i) {
if (canTranslate()) {
if(canTranslate()) {
return (BlockVector) i.clone().add(new BlockVector(x, y, z));
}
@@ -70,7 +70,7 @@ public class IrisObjectTranslate {
}
public BlockVector translate(BlockVector clone, IrisObjectRotation rotation, int sx, int sy, int sz) {
if (canTranslate()) {
if(canTranslate()) {
return (BlockVector) clone.clone().add(rotation.rotate(new BlockVector(x, y, z), sx, sy, sz));
}

View File

@@ -20,11 +20,9 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import jdk.jfr.Description;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -50,21 +48,21 @@ public class IrisOreGenerator {
private transient AtomicCache<CNG> chanceCache = new AtomicCache<>();
public BlockData generate(int x, int y, int z, RNG rng, IrisData data){
if(palette.getPalette().isEmpty()){
return null;
public BlockData generate(int x, int y, int z, RNG rng, IrisData data) {
if(palette.getPalette().isEmpty()) {
return null;
}
if(!range.contains(y)){
if(!range.contains(y)) {
return null;
}
CNG chance = chanceCache.aquire(() -> chanceStyle.create(rng, data));
if (chance.noise(x,y,z ) > threshold){
if(chance.noise(x, y, z) > threshold) {
return null;
}
return palette.get( rng, x,y,z, data);
return palette.get(rng, x, y, z, data);
}
}

View File

@@ -64,19 +64,19 @@ public class IrisPotionEffect {
{
PotionEffectType t = PotionEffectType.LUCK;
if (getPotionEffect().isEmpty()) {
if(getPotionEffect().isEmpty()) {
return t;
}
try {
for (PotionEffectType i : PotionEffectType.values()) {
if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
for(PotionEffectType i : PotionEffectType.values()) {
if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
t = i;
return t;
}
}
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -88,10 +88,10 @@ public class IrisPotionEffect {
}
public void apply(LivingEntity p) {
if (strength > -1) {
if (p.hasPotionEffect(getRealType())) {
if(strength > -1) {
if(p.hasPotionEffect(getRealType())) {
PotionEffect e = p.getPotionEffect(getRealType());
if (e.getAmplifier() > strength) {
if(e.getAmplifier() > strength) {
return;
}

View File

@@ -48,7 +48,7 @@ public class IrisPyramid implements IRare {
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)),
(int) baseWidth.get(rng, z, y, engine.getData()), true);
(int) baseWidth.get(rng, z, y, engine.getData()), true);
}
public double maxSize() {

View File

@@ -40,7 +40,7 @@ public class IrisRange {
private double max = 32;
public double get(RNG rng) {
if (min == max) {
if(min == max) {
return min;
}

View File

@@ -104,15 +104,15 @@ public class IrisRavine extends IrisRegistrant {
int highestWater = Math.max(waterHint, -1);
boolean water = false;
if (highestWater == -1) {
for (IrisPosition i : pos) {
if(highestWater == -1) {
for(IrisPosition i : pos) {
int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y;
int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), i.getX(), i.getZ()));
int surface = (int) Math.round(rsurface - depth * 0.45);
int yy = surface + depth;
int th = engine.getHeight(x, z, true);
if (yy > th && th < engine.getDimension().getFluidHeight()) {
if(yy > th && th < engine.getDimension().getFluidHeight()) {
highestWater = Math.max(highestWater, yy);
water = true;
break;
@@ -125,11 +125,11 @@ public class IrisRavine extends IrisRegistrant {
MatterCavern c = new MatterCavern(true, customBiome, (byte) (water ? 1 : 0));
MatterCavern l = new MatterCavern(true, customBiome, (byte) 2);
if (pos.size() < nodeThreshold) {
if(pos.size() < nodeThreshold) {
return;
}
for (IrisPosition p : pos) {
for(IrisPosition p : pos) {
int rsurface = y == -1 ? engine.getComplex().getHeightStream().get(x, z).intValue() : y;
int depth = (int) Math.round(dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ()));
int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), p.getX(), p.getZ()));
@@ -137,19 +137,19 @@ public class IrisRavine extends IrisRegistrant {
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface - depth, surface), p.getZ(), Math.max(highestWater, waterHint));
for (int i = surface + depth; i >= surface; i--) {
if (i % ribThickness == 0) {
for(int i = surface + depth; i >= surface; i--) {
if(i % ribThickness == 0) {
double v = width + ((((surface + depth) - i) * (angle / 360D)));
if (v <= 0.25) {
if(v <= 0.25) {
break;
}
if (i <= ribThickness + 2) {
if(i <= ribThickness + 2) {
break;
}
if (lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) {
if(lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) {
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, l);
} else {
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c);
@@ -157,19 +157,19 @@ public class IrisRavine extends IrisRegistrant {
}
}
for (int i = surface - depth; i <= surface; i++) {
if (i % ribThickness == 0) {
for(int i = surface - depth; i <= surface; i++) {
if(i % ribThickness == 0) {
double v = width - ((((surface - depth) - i) * (angle / 360D)));
if (v <= 0.25) {
if(v <= 0.25) {
break;
}
if (i <= ribThickness + 2) {
if(i <= ribThickness + 2) {
break;
}
if (lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) {
if(lavaLevel >= 0 && i <= lavaLevel + (surface - depthStyle.getMid())) {
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, l);
} else {
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, c);

View File

@@ -64,18 +64,18 @@ public class IrisRavinePlacer implements IRare {
}
public void generateRavine(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
if (fail.get()) {
if(fail.get()) {
return;
}
if (rng.nextInt(rarity) != 0) {
if(rng.nextInt(rarity) != 0) {
return;
}
IrisData data = engine.getData();
IrisRavine ravine = getRealRavine(data);
if (ravine == null) {
if(ravine == null) {
Iris.warn("Unable to locate ravine for generation!");
fail.set(true);
return;
@@ -85,7 +85,7 @@ public class IrisRavinePlacer implements IRare {
int xx = x + rng.nextInt(15);
int zz = z + rng.nextInt(15);
ravine.generate(mantle, rng, engine, xx, y, zz, waterHint);
} catch (Throwable e) {
} catch(Throwable e) {
e.printStackTrace();
fail.set(true);
}

View File

@@ -182,14 +182,14 @@ public class IrisRegion extends IrisRegistrant implements IRare {
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
if(ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
for(IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
b = i.generate(x, y, z, rng, data);
if(b != null) {
return b;
}
}
@@ -205,8 +205,8 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisObjectPlacement> o = getObjects().copy();
for (IrisObjectPlacement i : o.copy()) {
if (!i.getCarvingSupport().supportsSurface()) {
for(IrisObjectPlacement i : o.copy()) {
if(!i.getCarvingSupport().supportsSurface()) {
o.remove(i);
}
}
@@ -220,8 +220,8 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisObjectPlacement> o = getObjects().copy();
for (IrisObjectPlacement i : o.copy()) {
if (!i.getCarvingSupport().supportsCarving()) {
for(IrisObjectPlacement i : o.copy()) {
if(!i.getCarvingSupport().supportsCarving()) {
o.remove(i);
}
}
@@ -231,7 +231,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
}
public double getBiomeZoom(InferredType t) {
switch (t) {
switch(t) {
case CAVE:
return caveBiomeZoom;
case LAND:
@@ -249,7 +249,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
public CNG getShoreHeightGenerator() {
return shoreHeightGenerator.aquire(() ->
CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))));
CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))));
}
public double getShoreHeight(double x, double z) {
@@ -270,9 +270,9 @@ public class IrisRegion extends IrisRegistrant implements IRare {
KMap<String, IrisBiome> b = new KMap<>();
KSet<String> names = getAllBiomeIds();
while (!names.isEmpty()) {
for (String i : new KList<>(names)) {
if (b.containsKey(i)) {
while(!names.isEmpty()) {
for(String i : new KList<>(names)) {
if(b.containsKey(i)) {
names.remove(i);
continue;
}
@@ -280,7 +280,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
IrisBiome biome = g.getData().getBiomeLoader().load(i);
names.remove(i);
if (biome == null) {
if(biome == null) {
continue;
}
@@ -294,13 +294,13 @@ public class IrisRegion extends IrisRegistrant implements IRare {
}
public KList<IrisBiome> getBiomes(DataProvider g, InferredType type) {
if (type.equals(InferredType.LAND)) {
if(type.equals(InferredType.LAND)) {
return getRealLandBiomes(g);
} else if (type.equals(InferredType.SEA)) {
} else if(type.equals(InferredType.SEA)) {
return getRealSeaBiomes(g);
} else if (type.equals(InferredType.SHORE)) {
} else if(type.equals(InferredType.SHORE)) {
return getRealShoreBiomes(g);
} else if (type.equals(InferredType.CAVE)) {
} else if(type.equals(InferredType.CAVE)) {
return getRealCaveBiomes(g);
}
@@ -312,7 +312,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisBiome> realCaveBiomes = new KList<>();
for (String i : getCaveBiomes()) {
for(String i : getCaveBiomes()) {
realCaveBiomes.add(g.getData().getBiomeLoader().load(i));
}
@@ -325,7 +325,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisBiome> realShoreBiomes = new KList<>();
for (String i : getShoreBiomes()) {
for(String i : getShoreBiomes()) {
realShoreBiomes.add(g.getData().getBiomeLoader().load(i));
}
@@ -338,7 +338,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisBiome> realSeaBiomes = new KList<>();
for (String i : getSeaBiomes()) {
for(String i : getSeaBiomes()) {
realSeaBiomes.add(g.getData().getBiomeLoader().load(i));
}
@@ -351,7 +351,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
{
KList<IrisBiome> realLandBiomes = new KList<>();
for (String i : getLandBiomes()) {
for(String i : getLandBiomes()) {
realLandBiomes.add(g.getData().getBiomeLoader().load(i));
}
@@ -367,9 +367,9 @@ public class IrisRegion extends IrisRegistrant implements IRare {
names.addAll(seaBiomes);
names.addAll(shoreBiomes);
while (!names.isEmpty()) {
for (String i : new KList<>(names)) {
if (b.containsKey(i)) {
while(!names.isEmpty()) {
for(String i : new KList<>(names)) {
if(b.containsKey(i)) {
names.remove(i);
continue;
}
@@ -377,7 +377,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
IrisBiome biome = IrisData.loadAnyBiome(i);
names.remove(i);
if (biome == null) {
if(biome == null) {
continue;
}
@@ -392,17 +392,17 @@ public class IrisRegion extends IrisRegistrant implements IRare {
public Color getColor(DataProvider dataProvider, RenderType type) {
return this.cacheColor.aquire(() -> {
if (this.color == null) {
if(this.color == null) {
Random rand = new Random(getName().hashCode() + getAllBiomeIds().hashCode());
RandomColor randomColor = new RandomColor(rand);
KList<IrisBiome> biomes = getRealLandBiomes(dataProvider);
while (biomes.size() > 0) {
while(biomes.size() > 0) {
int index = rand.nextInt(biomes.size());
IrisBiome biome = biomes.get(index);
if (biome.getVanillaDerivative() != null) {
if(biome.getVanillaDerivative() != null) {
RandomColor.Color col = VanillaBiomeMap.getColorType(biome.getVanillaDerivative());
RandomColor.Luminosity lum = VanillaBiomeMap.getColorLuminosity(biome.getVanillaDerivative());
RandomColor.SaturationType sat = VanillaBiomeMap.getColorSaturatiom(biome.getVanillaDerivative());
@@ -419,7 +419,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
try {
return Color.decode(this.color);
} catch (NumberFormatException e) {
} catch(NumberFormatException e) {
Iris.warn("Could not parse color \"" + this.color + "\" for region " + getName());
return Color.WHITE;
}

View File

@@ -50,7 +50,7 @@ public class IrisSlopeClip {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isValid(double slope) {
if (isDefault()) {
if(isDefault()) {
return true;
}

View File

@@ -74,17 +74,17 @@ public class IrisSpawner extends IrisRegistrant {
private IrisSpawnGroup group = IrisSpawnGroup.NORMAL;
public boolean isValid(IrisBiome biome) {
return switch (group) {
case NORMAL -> switch (biome.getInferredType()) {
return switch(group) {
case NORMAL -> switch(biome.getInferredType()) {
case SHORE, SEA, CAVE, DEFER -> false;
case LAND -> true;
};
case CAVE -> true;
case UNDERWATER -> switch (biome.getInferredType()) {
case UNDERWATER -> switch(biome.getInferredType()) {
case SHORE, LAND, CAVE, DEFER -> false;
case SEA -> true;
};
case BEACH -> switch (biome.getInferredType()) {
case BEACH -> switch(biome.getInferredType()) {
case SHORE -> true;
case LAND, CAVE, SEA, DEFER -> false;
};

View File

@@ -47,11 +47,11 @@ public class IrisStyledRange {
private IrisGeneratorStyle style = new IrisGeneratorStyle(NoiseStyle.STATIC);
public double get(RNG rng, double x, double z, IrisData data) {
if (min == max) {
if(min == max) {
return min;
}
if (style.isFlat()) {
if(style.isFlat()) {
return M.lerp(min, max, 0.5);
}

View File

@@ -44,23 +44,24 @@ public enum IrisSurface {
/**
* Check if this Iris surface matches the blockstate provided
*
* @param state The blockstate
* @param state
* The blockstate
* @return True if it matches
*/
public boolean matches(Block state) {
Material type = state.getType();
if (type.isSolid()) {
if(type.isSolid()) {
return this == LAND || this == OVERWORLD || (this == ANIMAL
&& (type == Material.GRASS_BLOCK || type == Material.DIRT
|| type == Material.DIRT_PATH || type == Material.COARSE_DIRT
|| type == Material.ROOTED_DIRT || type == Material.PODZOL
|| type == Material.MYCELIUM || type == Material.SNOW_BLOCK));
&& (type == Material.GRASS_BLOCK || type == Material.DIRT
|| type == Material.DIRT_PATH || type == Material.COARSE_DIRT
|| type == Material.ROOTED_DIRT || type == Material.PODZOL
|| type == Material.MYCELIUM || type == Material.SNOW_BLOCK));
}
if (type == Material.LAVA) return this == LAVA;
if (type == Material.WATER || type == Material.SEAGRASS
|| type == Material.TALL_SEAGRASS || type == Material.KELP_PLANT
|| type == Material.KELP ||
(state instanceof Waterlogged && ((Waterlogged) state).isWaterlogged()))
if(type == Material.LAVA) return this == LAVA;
if(type == Material.WATER || type == Material.SEAGRASS
|| type == Material.TALL_SEAGRASS || type == Material.KELP_PLANT
|| type == Material.KELP ||
(state instanceof Waterlogged && ((Waterlogged) state).isWaterlogged()))
return this == WATER || this == OVERWORLD;
return false;

View File

@@ -38,11 +38,11 @@ public class IrisTimeBlock {
}
public boolean isWithin(double hour) {
if (startHour == endHour) {
if(startHour == endHour) {
return endHour != -1;
}
if (startHour > endHour) {
if(startHour > endHour) {
return hour >= startHour || hour <= endHour;
}

View File

@@ -53,7 +53,7 @@ public class IrisTree {
private boolean anySize;
public boolean matches(IrisTreeSize size, TreeType type) {
if (!matchesSize(size)) {
if(!matchesSize(size)) {
return false;
}
@@ -61,8 +61,8 @@ public class IrisTree {
}
private boolean matchesSize(IrisTreeSize size) {
for (IrisTreeSize i : getSizes()) {
if ((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) {
for(IrisTreeSize i : getSizes()) {
if((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) {
return true;
}
}

View File

@@ -45,7 +45,8 @@ public class IrisTreeSize {
/**
* Does the size match
*
* @param size the size to check match
* @param size
* the size to check match
* @return true if it matches (fits within width and depth)
*/
public boolean doesMatch(IrisTreeSize size) {

View File

@@ -41,27 +41,27 @@ import org.bukkit.inventory.ItemStack;
@EqualsAndHashCode(callSuper = false)
public class IrisVillagerOverride {
@Desc("""
Disable the trade altogether.
If a cartographer villager gets a new explorer map trade:
If this is enabled -> the trade is removed
If this is disabled -> the trade is replaced with the "override" setting below
Default is true, so if you omit this, trades will be removed.""")
Disable the trade altogether.
If a cartographer villager gets a new explorer map trade:
If this is enabled -> the trade is removed
If this is disabled -> the trade is replaced with the "override" setting below
Default is true, so if you omit this, trades will be removed.""")
private boolean disableTrade = true;
@DependsOn("disableTrade")
@Required
@Desc("""
The items to override the cartographer trade with.
By default, this is:
3 emeralds + 3 glass blocks -> 1 spyglass.
Can trade 3 to 5 times""")
The items to override the cartographer trade with.
By default, this is:
3 emeralds + 3 glass blocks -> 1 spyglass.
Can trade 3 to 5 times""")
@ArrayType(min = 1, type = IrisVillagerTrade.class)
private KList<IrisVillagerTrade> items = new KList<>(new IrisVillagerTrade()
.setIngredient1(new ItemStack(Material.EMERALD, 3))
.setIngredient2(new ItemStack(Material.GLASS, 3))
.setResult(new ItemStack(Material.SPYGLASS))
.setMinTrades(3)
.setMaxTrades(5));
.setIngredient1(new ItemStack(Material.EMERALD, 3))
.setIngredient2(new ItemStack(Material.GLASS, 3))
.setResult(new ItemStack(Material.SPYGLASS))
.setMinTrades(3)
.setMaxTrades(5));
public KList<IrisVillagerTrade> getValidItems() {
KList<IrisVillagerTrade> valid = new KList<>();

View File

@@ -81,39 +81,39 @@ public class IrisVillagerTrade {
*/
public boolean isValidItems() {
KList<String> warnings = new KList<>();
if (ingredient1 == null) {
if(ingredient1 == null) {
warnings.add("Ingredient 1 is null");
}
if (result == null) {
if(result == null) {
warnings.add("Result is null");
}
if (minTrades <= 0) {
if(minTrades <= 0) {
warnings.add("Negative minimal trades");
}
if (maxTrades <= 0) {
if(maxTrades <= 0) {
warnings.add("Negative maximal trades");
}
if (minTrades > maxTrades) {
if(minTrades > maxTrades) {
warnings.add("More minimal than maximal trades");
}
if (ingredient1 != null && !ingredient1.getType().isItem()) {
if(ingredient1 != null && !ingredient1.getType().isItem()) {
warnings.add("Ingredient 1 is not an item");
}
if (ingredient2 != null && !ingredient2.getType().isItem()) {
if(ingredient2 != null && !ingredient2.getType().isItem()) {
warnings.add("Ingredient 2 is not an item");
}
if (result != null && !result.getType().isItem()) {
if(result != null && !result.getType().isItem()) {
warnings.add("Result is not an item");
}
if (warnings.isEmpty()) {
if(warnings.isEmpty()) {
return true;
} else {
Iris.warn("Faulty item in cartographer item overrides: " + this);
@@ -128,7 +128,7 @@ public class IrisVillagerTrade {
* @return The list of 1 or 2 ingredients (depending on if ing2 is null)
*/
public List<ItemStack> getIngredients() {
if (!isValidItems()) {
if(!isValidItems()) {
return null;
}
return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2);

View File

@@ -36,7 +36,7 @@ public enum IrisWeather {
ANY;
public boolean is(World world) {
return switch (this) {
return switch(this) {
case NONE -> world.isClearWeather();
case DOWNFALL -> world.hasStorm();
case DOWNFALL_WITH_THUNDER -> world.hasStorm() && world.isThundering();

View File

@@ -60,11 +60,11 @@ public class IrisWorld {
private static IrisWorld bindWorld(IrisWorld iw, World world) {
return iw.name(world.getName())
.worldFolder(world.getWorldFolder())
.minHeight(world.getMinHeight())
.maxHeight(world.getMaxHeight())
.realWorld(world)
.environment(world.getEnvironment());
.worldFolder(world.getWorldFolder())
.minHeight(world.getMinHeight())
.maxHeight(world.getMaxHeight())
.realWorld(world)
.environment(world.getEnvironment());
}
public long getRawWorldSeed() {
@@ -76,13 +76,13 @@ public class IrisWorld {
}
public boolean tryGetRealWorld() {
if (hasRealWorld()) {
if(hasRealWorld()) {
return true;
}
World w = Bukkit.getWorld(name);
if (w != null) {
if(w != null) {
realWorld = w;
return true;
}
@@ -96,7 +96,7 @@ public class IrisWorld {
public List<Player> getPlayers() {
if (hasRealWorld()) {
if(hasRealWorld()) {
return realWorld().getPlayers();
}
@@ -104,13 +104,13 @@ public class IrisWorld {
}
public void evacuate() {
if (hasRealWorld()) {
if(hasRealWorld()) {
IrisToolbelt.evacuate(realWorld());
}
}
public void bind(World world) {
if (hasRealWorld()) {
if(hasRealWorld()) {
return;
}
@@ -118,7 +118,7 @@ public class IrisWorld {
}
public Location spawnLocation() {
if (hasRealWorld()) {
if(hasRealWorld()) {
return realWorld().getSpawnLocation();
}
@@ -127,7 +127,7 @@ public class IrisWorld {
}
public <T extends Entity> Collection<? extends T> getEntitiesByClass(Class<T> t) {
if (hasRealWorld()) {
if(hasRealWorld()) {
return realWorld().getEntitiesByClass(t);
}

View File

@@ -60,7 +60,7 @@ public class IrisWorm {
@Desc("The thickness of the worms. Each individual worm has the same thickness while traveling however, each spawned worm will vary in thickness.")
private IrisStyledRange girth = new IrisStyledRange().setMin(3).setMax(5)
.setStyle(new IrisGeneratorStyle(NoiseStyle.PERLIN));
.setStyle(new IrisGeneratorStyle(NoiseStyle.PERLIN));
public KList<IrisPosition> generate(RNG rng, IrisData data, MantleWriter writer, IrisRange verticalRange, int x, int y, int z, Consumer<IrisPosition> fork) {
int itr = maxIterations;
@@ -75,12 +75,12 @@ public class IrisWorm {
CNG gy = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data);
CNG gz = xStyle.getGenerator().createNoCache(new RNG(rng.lmax()), data);
while (itr-- > 0) {
while(itr-- > 0) {
IrisPosition current = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz));
fork.accept(current);
pos.add(current);
if (check != null) {
if(check != null) {
check.add(current);
}
@@ -92,19 +92,19 @@ public class IrisWorm {
cz += jz;
IrisPosition next = new IrisPosition(Math.round(cx), Math.round(cy), Math.round(cz));
if (verticalRange != null && !verticalRange.contains(next.getY())) {
if(verticalRange != null && !verticalRange.contains(next.getY())) {
break;
}
if (!writer.isWithin((int) Math.round(cx), verticalRange != null ? (int) Math.round(cy) : 5, (int) Math.round(cz))) {
if(!writer.isWithin((int) Math.round(cx), verticalRange != null ? (int) Math.round(cy) : 5, (int) Math.round(cz))) {
break;
}
if (next.isLongerThan(start, maxDistance)) {
if(next.isLongerThan(start, maxDistance)) {
break;
}
if (check != null && check.contains(next)) {
if(check != null && check.contains(next)) {
break;
}
}

View File

@@ -77,7 +77,7 @@ public class TileBanner implements TileData<Banner> {
out.writeShort(id);
out.writeByte(baseColor.ordinal());
out.writeByte(patterns.size());
for (Pattern p : patterns) {
for(Pattern p : patterns) {
out.writeByte(p.getColor().ordinal());
out.writeByte(p.getPattern().ordinal());
}
@@ -89,7 +89,7 @@ public class TileBanner implements TileData<Banner> {
int listSize = in.readByte();
patterns = new ArrayList<>();
for (int i = 0; i < listSize; i++) {
for(int i = 0; i < listSize; i++) {
DyeColor color = DyeColor.values()[in.readByte()];
PatternType type = PatternType.values()[in.readByte()];
patterns.add(new Pattern(color, type));
@@ -100,7 +100,7 @@ public class TileBanner implements TileData<Banner> {
@Override
public void toNBT(CompoundTag tag) {
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
for (Pattern p : patterns) {
for(Pattern p : patterns) {
CompoundTag pattern = new CompoundTag();
pattern.putString("Pattern", p.getPattern().getIdentifier());
pattern.putByte("Color", p.getColor().getDyeData());
@@ -110,7 +110,7 @@ public class TileBanner implements TileData<Banner> {
}
public boolean isBanner(Material material) {
return switch (material) {
return switch(material) {
case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER, YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER, LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER, CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER, BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER, PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER, PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER, LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER, GRAY_WALL_BANNER, BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER, BROWN_WALL_BANNER -> true;
default -> false;
};

View File

@@ -53,21 +53,21 @@ public interface TileData<T extends TileState> extends Cloneable {
}
static void setTileState(Block block, TileData<? extends TileState> data) {
if (data.isApplicable(block.getBlockData())) {
if(data.isApplicable(block.getBlockData())) {
data.toBukkitTry(block.getState());
}
}
static TileData<? extends TileState> getTileState(Block block) {
for (TileData<? extends TileState> i : registry) {
for(TileData<? extends TileState> i : registry) {
BlockData data = block.getBlockData();
if (i.isApplicable(data)) {
if(i.isApplicable(data)) {
try {
@SuppressWarnings("unchecked") TileData<? extends TileState> s = i.getClass().getConstructor().newInstance();
s.fromBukkitTry(block.getState());
return s;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -90,7 +90,7 @@ public interface TileData<T extends TileState> extends Cloneable {
//noinspection unchecked
toBukkit((T) t);
return true;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}
@@ -103,7 +103,7 @@ public interface TileData<T extends TileState> extends Cloneable {
//noinspection unchecked
fromBukkit((T) t);
return true;
} catch (Throwable e) {
} catch(Throwable e) {
Iris.reportError(e);
}