This commit is contained in:
Daniel Mills
2020-01-22 14:31:00 -05:00
parent c1971bffa8
commit 199a26afbc
8 changed files with 169 additions and 378 deletions

View File

@@ -1,6 +1,7 @@
package ninja.bytecode.iris.pack;
import java.lang.reflect.Field;
import java.util.Objects;
import org.bukkit.Material;
import org.bukkit.block.Biome;
@@ -25,7 +26,7 @@ import ninja.bytecode.shuriken.math.RNG;
public class IrisBiome
{
public static final double MAX_HEIGHT = 0.77768;
public static final double IDEAL_HEIGHT = 0.0527;
public static final double IDEAL_HEIGHT = 0.138;
public static final double MIN_HEIGHT = -0.0218;
private static final GMap<Biome, IrisBiome> map = build();
private String name;
@@ -33,6 +34,7 @@ public class IrisBiome
private Biome realBiome;
private double height;
private GList<MB> rock;
private MB fluid;
private int rockDepth;
private GList<MB> surface;
private GList<MB> dirt;
@@ -118,6 +120,7 @@ public class IrisBiome
this.name = name;
type = BiomeType.LAND;
cliffs = false;
fluid = MB.of(Material.STATIONARY_WATER);
genScale = 1;
rarity = 1;
genAmplifier = 0.35;
@@ -236,14 +239,15 @@ public class IrisBiome
type = BiomeType.valueOf(o.getString("type").toUpperCase().replaceAll(" ", "_"));
J.attempt(() -> region = o.getString("region"));
J.attempt(() -> parent = o.getString("parent"));
J.attempt(() -> height = o.getDouble("height"));
J.attempt(() -> height = o.getDouble("genHeight"));
J.attempt(() -> height(o.getDouble("height")));
J.attempt(() -> height(o.getDouble("genHeight")));
J.attempt(() -> genAmplifier = o.getDouble("genAmplifier"));
J.attempt(() -> genSwirl = o.getDouble("genSwirl"));
J.attempt(() -> genSwirlScale = o.getDouble("genSwirlScale"));
J.attempt(() -> genScale = o.getDouble("genScale"));
J.attempt(() -> snow = o.getDouble("snow"));
J.attempt(() -> rarity = o.getDouble("rarity"));
J.attempt(() -> fluid = MB.of(o.getString("fluid")));
J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth"));
J.attempt(() -> dirtDepth = o.getInt("dirtDepth"));
J.attempt(() -> rockDepth = o.getInt("rockDepth"));
@@ -298,6 +302,7 @@ public class IrisBiome
J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " ")));
J.attempt(() -> j.put("type", type.name().toLowerCase().replaceAll("_", " ")));
J.attempt(() -> j.put("rarity", rarity));
J.attempt(() -> j.put("fluid", fluid.toString()));
J.attempt(() -> j.put("genHeight", height));
J.attempt(() -> j.put("genScale", genScale));
J.attempt(() -> j.put("genSwirl", genSwirl));
@@ -479,7 +484,7 @@ public class IrisBiome
else
{
this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D));
this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, 1d - Math.abs(M.clip(height, -1D, 0D)));
}
return this;
@@ -635,7 +640,7 @@ public class IrisBiome
return false;
}
public String getRegion()
public String getRegionID()
{
return region;
}
@@ -1038,173 +1043,39 @@ public class IrisBiome
}
}
public MB getFluid()
{
return fluid;
}
public void setFluid(MB fluid)
{
this.fluid = fluid;
}
public void setRarity(double rarity)
{
this.rarity = rarity;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(cliffChance);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(cliffScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + (cliffs ? 1231 : 1237);
result = prime * result + (core ? 1231 : 1237);
result = prime * result + ((dirt == null) ? 0 : dirt.hashCode());
result = prime * result + dirtDepth;
temp = Double.doubleToLongBits(genAmplifier);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(genScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(genSwirl);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(genSwirlScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
temp = Double.doubleToLongBits(rarity);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((realBiome == null) ? 0 : realBiome.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((rock == null) ? 0 : rock.hashCode());
result = prime * result + rockDepth;
temp = Double.doubleToLongBits(rockScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((scatterChance == null) ? 0 : scatterChance.hashCode());
result = prime * result + (scatterSurface ? 1231 : 1237);
result = prime * result + (scatterSurfaceRock ? 1231 : 1237);
result = prime * result + (scatterSurfaceSub ? 1231 : 1237);
result = prime * result + ((schematicGroups == null) ? 0 : schematicGroups.hashCode());
result = prime * result + (simplexScatter ? 1231 : 1237);
result = prime * result + (simplexScatterRock ? 1231 : 1237);
result = prime * result + (simplexScatterSub ? 1231 : 1237);
temp = Double.doubleToLongBits(snow);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(subSurfaceScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((surface == null) ? 0 : surface.hashCode());
temp = Double.doubleToLongBits(surfaceScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
return Objects.hash(cliffChance, cliffScale, cliffs, core, dirt, dirtDepth, fluid, genAmplifier, genScale, genSwirl, genSwirlScale, height, name, parent, rarity, realBiome, region, rock, rockDepth, rockScale, scatterChance, scatterSurface, scatterSurfaceRock, scatterSurfaceSub, schematicGroups, simplexScatter, simplexScatterRock, simplexScatterSub, snow, subSurfaceScale, surface, surfaceScale, type);
}
@Override
public boolean equals(Object obj)
{
if(this == obj)
{
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
}
if(!(obj instanceof IrisBiome))
{
return false;
}
IrisBiome other = (IrisBiome) obj;
if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance))
return false;
if(Double.doubleToLongBits(cliffScale) != Double.doubleToLongBits(other.cliffScale))
return false;
if(cliffs != other.cliffs)
return false;
if(core != other.core)
return false;
if(dirt == null)
{
if(other.dirt != null)
return false;
}
else if(!dirt.equals(other.dirt))
return false;
if(dirtDepth != other.dirtDepth)
return false;
if(Double.doubleToLongBits(genAmplifier) != Double.doubleToLongBits(other.genAmplifier))
return false;
if(Double.doubleToLongBits(genScale) != Double.doubleToLongBits(other.genScale))
return false;
if(Double.doubleToLongBits(genSwirl) != Double.doubleToLongBits(other.genSwirl))
return false;
if(Double.doubleToLongBits(genSwirlScale) != Double.doubleToLongBits(other.genSwirlScale))
return false;
if(Double.doubleToLongBits(height) != Double.doubleToLongBits(other.height))
return false;
if(name == null)
{
if(other.name != null)
return false;
}
else if(!name.equals(other.name))
return false;
if(parent == null)
{
if(other.parent != null)
return false;
}
else if(!parent.equals(other.parent))
return false;
if(Double.doubleToLongBits(rarity) != Double.doubleToLongBits(other.rarity))
return false;
if(realBiome != other.realBiome)
return false;
if(region == null)
{
if(other.region != null)
return false;
}
else if(!region.equals(other.region))
return false;
if(rock == null)
{
if(other.rock != null)
return false;
}
else if(!rock.equals(other.rock))
return false;
if(rockDepth != other.rockDepth)
return false;
if(Double.doubleToLongBits(rockScale) != Double.doubleToLongBits(other.rockScale))
return false;
if(scatterChance == null)
{
if(other.scatterChance != null)
return false;
}
else if(!scatterChance.equals(other.scatterChance))
return false;
if(scatterSurface != other.scatterSurface)
return false;
if(scatterSurfaceRock != other.scatterSurfaceRock)
return false;
if(scatterSurfaceSub != other.scatterSurfaceSub)
return false;
if(schematicGroups == null)
{
if(other.schematicGroups != null)
return false;
}
else if(!schematicGroups.equals(other.schematicGroups))
return false;
if(simplexScatter != other.simplexScatter)
return false;
if(simplexScatterRock != other.simplexScatterRock)
return false;
if(simplexScatterSub != other.simplexScatterSub)
return false;
if(Double.doubleToLongBits(snow) != Double.doubleToLongBits(other.snow))
return false;
if(Double.doubleToLongBits(subSurfaceScale) != Double.doubleToLongBits(other.subSurfaceScale))
return false;
if(surface == null)
{
if(other.surface != null)
return false;
}
else if(!surface.equals(other.surface))
return false;
if(Double.doubleToLongBits(surfaceScale) != Double.doubleToLongBits(other.surfaceScale))
return false;
if(type != other.type)
return false;
return true;
return Double.doubleToLongBits(cliffChance) == Double.doubleToLongBits(other.cliffChance) && Double.doubleToLongBits(cliffScale) == Double.doubleToLongBits(other.cliffScale) && cliffs == other.cliffs && core == other.core && Objects.equals(dirt, other.dirt) && dirtDepth == other.dirtDepth && Objects.equals(fluid, other.fluid) && Double.doubleToLongBits(genAmplifier) == Double.doubleToLongBits(other.genAmplifier) && Double.doubleToLongBits(genScale) == Double.doubleToLongBits(other.genScale) && Double.doubleToLongBits(genSwirl) == Double.doubleToLongBits(other.genSwirl) && Double.doubleToLongBits(genSwirlScale) == Double.doubleToLongBits(other.genSwirlScale) && Double.doubleToLongBits(height) == Double.doubleToLongBits(other.height) && Objects.equals(name, other.name) && Objects.equals(parent, other.parent) && Double.doubleToLongBits(rarity) == Double.doubleToLongBits(other.rarity) && realBiome == other.realBiome && Objects.equals(region, other.region) && Objects.equals(rock, other.rock) && rockDepth == other.rockDepth && Double.doubleToLongBits(rockScale) == Double.doubleToLongBits(other.rockScale) && Objects.equals(scatterChance, other.scatterChance) && scatterSurface == other.scatterSurface && scatterSurfaceRock == other.scatterSurfaceRock && scatterSurfaceSub == other.scatterSurfaceSub && Objects.equals(schematicGroups, other.schematicGroups) && simplexScatter == other.simplexScatter && simplexScatterRock == other.simplexScatterRock && simplexScatterSub == other.simplexScatterSub && Double.doubleToLongBits(snow) == Double.doubleToLongBits(other.snow) && Double.doubleToLongBits(subSurfaceScale) == Double.doubleToLongBits(other.subSurfaceScale) && Objects.equals(surface, other.surface) && Double.doubleToLongBits(surfaceScale) == Double.doubleToLongBits(other.surfaceScale) && type == other.type;
}
}

View File

@@ -1,5 +1,7 @@
package ninja.bytecode.iris.pack;
import java.util.Objects;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.shuriken.collections.GList;
@@ -10,17 +12,21 @@ public class IrisRegion
{
private String name;
private GList<IrisBiome> biomes;
private double rarity;
private boolean frozen;
private IrisBiome ocean;
private IrisBiome lake;
private IrisBiome lakeBeach;
private IrisBiome channel;
private IrisBiome beach;
public IrisRegion(String name)
{
frozen = false;
this.name = name;
this.biomes = new GList<>();
rarity = 1;
beach = null;
ocean = null;
lake = null;
lakeBeach = null;
channel = null;
}
public void load()
@@ -28,10 +34,12 @@ public class IrisRegion
J.attempt(() ->
{
JSONObject o = Iris.getController(PackController.class).loadJSON("pack/regions/" + name + ".json");
J.attempt(() -> frozen = o.getBoolean("frozen"));
J.attempt(() -> name = o.getString("name"));
J.attempt(() -> rarity = o.getDouble("rarity"));
J.attempt(() -> ocean = Iris.getController(PackController.class).getBiomeById(o.getString("ocean")));
J.attempt(() -> beach = Iris.getController(PackController.class).getBiomeById(o.getString("beach")));
J.attempt(() -> lake = Iris.getController(PackController.class).getBiomeById(o.getString("lake")));
J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("lakeBeach")));
J.attempt(() -> channel = Iris.getController(PackController.class).getBiomeById(o.getString("channel")));
});
}
@@ -55,16 +63,6 @@ public class IrisRegion
this.biomes = biomes;
}
public double getRarity()
{
return rarity;
}
public void setRarity(double rarity)
{
this.rarity = rarity;
}
public IrisBiome getBeach()
{
return beach;
@@ -75,59 +73,44 @@ public class IrisRegion
this.beach = beach;
}
public IrisBiome getOcean()
{
return ocean;
}
public IrisBiome getLake()
{
return lake;
}
public IrisBiome getShore()
{
return lakeBeach;
}
public IrisBiome getChannel()
{
return channel;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((beach == null) ? 0 : beach.hashCode());
result = prime * result + ((biomes == null) ? 0 : biomes.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
long temp;
temp = Double.doubleToLongBits(rarity);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
return Objects.hash(beach, biomes, channel, lake, lakeBeach, name, ocean);
}
@Override
public boolean equals(Object obj)
{
if(this == obj)
{
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
}
if(!(obj instanceof IrisRegion))
{
return false;
}
IrisRegion other = (IrisRegion) obj;
if(beach == null)
{
if(other.beach != null)
return false;
}
else if(!beach.equals(other.beach))
return false;
if(biomes == null)
{
if(other.biomes != null)
return false;
}
else if(!biomes.equals(other.biomes))
return false;
if(name == null)
{
if(other.name != null)
return false;
}
else if(!name.equals(other.name))
return false;
if(Double.doubleToLongBits(rarity) != Double.doubleToLongBits(other.rarity))
return false;
return true;
}
public boolean isFrozen()
{
return frozen;
return Objects.equals(beach, other.beach) && Objects.equals(biomes, other.biomes) && Objects.equals(channel, other.channel) && Objects.equals(lake, other.lake) && Objects.equals(lakeBeach, other.lakeBeach) && Objects.equals(name, other.name) && Objects.equals(ocean, other.ocean);
}
}