Skip to content

Commit

Permalink
Adapt for 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpwnn committed Oct 16, 2019
1 parent b29ad7e commit d725182
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 503 deletions.
18 changes: 7 additions & 11 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,33 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
<exclusion>
<artifactId>json-simple</artifactId>
<groupId>com.googlecode.json-simple</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cb</groupId>
<artifactId>craftbukkit-1.12.2</artifactId>
<artifactId>craftbukkit-1.14.4</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath>
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
</dependency>
</dependencies>
<properties>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>craftbukkit-1.12.2</artifactId>
<artifactId>craftbukkit-1.14.4</artifactId>
<groupId>cb</groupId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath>
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
</dependency>
</dependencies>
</project>
13 changes: 10 additions & 3 deletions src/main/java/ninja/bytecode/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
public class Iris extends JavaPlugin implements Listener
{
public static TaskExecutor noisePool;
public static TaskExecutor blockPool;
public static IrisGenerator gen;
public static Settings settings;
public static Iris instance;

public void onEnable()
{
instance = this;
settings = new Settings();
gen = new IrisGenerator();
noisePool = new TaskExecutor(4, Thread.MIN_PRIORITY, "Iris Generator");
noisePool = new TaskExecutor(settings.performance.threadCount, settings.performance.threadPriority, "Iris Noise Generator");
blockPool = new TaskExecutor(1, Thread.MAX_PRIORITY, "Iris Decorator");
getServer().getPluginManager().registerEvents((Listener) this, this);

// Debug world regens
GSet<String> ws = new GSet<>();
World w = createIrisWorld();
Expand All @@ -38,7 +44,7 @@ public void onEnable()
i.setFlying(true);
i.setGameMode(GameMode.CREATIVE);
}

for(String i : ws)
{
Bukkit.unloadWorld(i, false);
Expand All @@ -48,6 +54,7 @@ public void onEnable()
public void onDisable()
{
noisePool.close();
blockPool.close();
}

@Override
Expand Down
166 changes: 143 additions & 23 deletions src/main/java/ninja/bytecode/iris/IrisGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Bisected.Half;
import org.bukkit.block.data.BlockData;

import ninja.bytecode.iris.gen.GenLayerBase;
import ninja.bytecode.iris.gen.GenLayerBiome;
import ninja.bytecode.iris.gen.GenLayerDeepOcean;
import ninja.bytecode.iris.gen.IGenLayer;
import ninja.bytecode.iris.util.RealBiome;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.math.M;
import ninja.bytecode.shuriken.math.RNG;

public class IrisGenerator extends ParallelChunkGenerator
{
private BlockData AIR = Material.AIR.createBlockData();
private BlockData WATER = Material.WATER.createBlockData();
private BlockData SAND = Material.SAND.createBlockData();
private BlockData BEDROCK = Material.BEDROCK.createBlockData();
private GList<IGenLayer> genLayers;
private GenLayerBiome glBiome;
private GenLayerBase glBase;
Expand All @@ -23,10 +32,11 @@ public class IrisGenerator extends ParallelChunkGenerator
@Override
public void onInit(World world, Random random)
{
RNG rng = new RNG(world.getSeed());
genLayers = new GList<>();
genLayers.add(glBiome = new GenLayerBiome(world, random, rng));
genLayers.add(glBase = new GenLayerBase(world, random, rng));
RNG rng = new RNG(world.getSeed());
genLayers.add(glBiome = new GenLayerBiome(world, random, rng.nextRNG()));
genLayers.add(glBase = new GenLayerBase(world, random, rng.nextRNG()));
genLayers.add(new GenLayerDeepOcean(world, random, rng.nextRNG()));
}

public int getHeight(double dx, double dz)
Expand All @@ -49,55 +59,165 @@ public int getHeight(double dx, double dz)
public Biome genColumn(int wx, int wz, int x, int z)
{
int height = getHeight(wx, wz);
double temp = glBiome.getTemperature(wx, wz);
double humidity = glBiome.getHumidity(wx, wz);
RealBiome b = glBiome.getBiome(wx, wz);
boolean underwater = height < waterLevel;

for(int i = 0; i < Math.max(height, waterLevel); i++)
// Change biome to ocean / deep ocean if underwater height
if(underwater)
{
MB mb = underwater ? new MB(Material.STATIONARY_WATER) : new MB(Material.AIR);

if(i > height && underwater)
if(waterLevel - height > 20)
{
mb = new MB(Material.STATIONARY_WATER);
}
if(temp <= 0.05)
{
b = RealBiome.of(Biome.DEEP_FROZEN_OCEAN);
}

else if(i == 0 || (i == 1 && glBase.scatterChance(wx, i, wz, 0.45)))
{
mb = new MB(Material.BEDROCK);
else if(temp <= 0.35)
{
b = RealBiome.of(Biome.DEEP_COLD_OCEAN);
}

else if(temp <= 0.55)
{
b = RealBiome.of(Biome.DEEP_OCEAN);
}

else if(temp <= 0.65)
{
b = RealBiome.of(Biome.DEEP_LUKEWARM_OCEAN);
}

else
{
b = RealBiome.of(Biome.DEEP_WARM_OCEAN);
}
}

else if(i == height - 1)
else
{
if(underwater)
if(temp <= 0.05)
{
b = RealBiome.of(Biome.FROZEN_OCEAN);
}

else if(temp <= 0.35)
{
mb = new MB(Material.SAND);
b = RealBiome.of(Biome.COLD_OCEAN);
}

else if(temp <= 0.55)
{
b = RealBiome.of(Biome.OCEAN);
}

else if(temp <= 0.65)
{
b = RealBiome.of(Biome.LUKEWARM_OCEAN);
}

else
{
mb = b.surface(wx, i, wz, glBase);
b = RealBiome.of(Biome.WARM_OCEAN);
}
}
}

if(height > 122 && height < 128 + (temp * 1.5) + (glBase.scatter(wx, wx * wz, wz) * 3.35))
{
b = RealBiome.of(Biome.BEACH);
}

for(int i = 0; i < Math.max(height, waterLevel); i++)
{
BlockData mb = AIR;

// Bedrockify
if(i == 0 || (!Iris.settings.gen.flatBedrock && ((i == 1 && glBase.scatterChance(wx, i, wz, 0.45)))))
{
mb = BEDROCK;
}

else if(i > height - glBase.scatterInt(wx, i, wz, 12))
// Surface blocks
else if(i == height - 1)
{
if(underwater)
if(temp > 0.6 && b.getBiome().equals(Biome.BEACH))
{
mb = new MB(Material.SAND);
if(humidity > 0.6)
{
mb = Material.YELLOW_CONCRETE_POWDER.createBlockData();
}

else
{
mb = Material.BLACK_CONCRETE_POWDER.createBlockData();
}
}


else if(temp < 0.4 && b.getBiome().equals(Biome.BEACH))
{
if(humidity > 0.6)
{
mb = Material.WHITE_CONCRETE_POWDER.createBlockData();
}

else
{
mb = Material.LIGHT_GRAY_CONCRETE_POWDER.createBlockData();
}
}

else
{
mb = b.dirt(wx, i, wz, glBase);
mb = b.surface(wx, i, wz, glBase);
}
}

// Dirt Blocks
else if(!underwater && i > height - glBase.scatterInt(wx, i, wz, 12))
{
mb = b.dirt(wx, i, wz, glBase);
}

// Create Water blocks
else if(i >= height && underwater)
{
mb = WATER;
}

// Below Dirt
else
{
mb = b.rock(wx, i, wz, glBase);
}

setBlock(x, i, z, mb.material, mb.data);
if(mb.getMaterial().equals(Material.AIR))
{
continue;
}

setBlock(x, i, z, mb);
}

BlockData v = b.getSurfaceDecoration();

if(v != null && underwater == b.isWater() && (underwater ? height < 125 : true))
{
if(v instanceof Bisected)
{
Bisected bs = (Bisected) v;
bs.setHalf(Half.BOTTOM);
setBlock(x, height, z, bs);
Bisected bst = (Bisected) bs.clone();
bst.setHalf(Half.TOP);
setBlock(x, height + 1, z, bst);
}

else
{
setBlock(x, height, z, v);
}
}

return b.getBiome();
Expand All @@ -108,7 +228,7 @@ public int pick(int max, double noise)
return (int) (noise * max);
}

public MB pick(MB[] array, double noise)
public BlockData pick(BlockData[] array, double noise)
{
return array[pick(array.length, noise)];
}
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/ninja/bytecode/iris/MB.java

This file was deleted.

Loading

0 comments on commit d725182

Please sign in to comment.