mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Merge branch 'master' of https://github.com/cyberpwnn/Iris into citizens
This commit is contained in:
commit
3ec70f9fb3
10
pom.xml
10
pom.xml
@ -1,10 +1,10 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>bytecode.ninja</groupId>
|
<groupId>bytecode.ninja</groupId>
|
||||||
<artifactId>Iris</artifactId>
|
<artifactId>Iris</artifactId>
|
||||||
<version>1.0.15</version>
|
<version>1.0.22</version>
|
||||||
<name>Iris</name>
|
<name>Iris</name>
|
||||||
<properties>
|
<properties>
|
||||||
<skip.copy>false</skip.copy>
|
<skip.copy>false</skip.copy>
|
||||||
@ -192,12 +192,6 @@
|
|||||||
<version>1.16.2</version>
|
<version>1.16.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit.craftbukkit</groupId>
|
|
||||||
<artifactId>cb-1.16.1</artifactId>
|
|
||||||
<version>1.16.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit.craftbukkit</groupId>
|
<groupId>org.bukkit.craftbukkit</groupId>
|
||||||
<artifactId>cb-1.15.1</artifactId>
|
<artifactId>cb-1.15.1</artifactId>
|
||||||
|
@ -20,8 +20,10 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import com.volmit.iris.command.CommandIris;
|
import com.volmit.iris.command.CommandIris;
|
||||||
import com.volmit.iris.command.PermissionIris;
|
import com.volmit.iris.command.PermissionIris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.nms.INMS;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
import com.volmit.iris.link.MultiverseCoreLink;
|
import com.volmit.iris.link.MultiverseCoreLink;
|
||||||
import com.volmit.iris.link.MythicMobsLink;
|
import com.volmit.iris.link.MythicMobsLink;
|
||||||
@ -61,7 +63,6 @@ public class Iris extends MortarPlugin
|
|||||||
public static StructureManager struct;
|
public static StructureManager struct;
|
||||||
public static EditManager edit;
|
public static EditManager edit;
|
||||||
public static IrisBoardManager board;
|
public static IrisBoardManager board;
|
||||||
public static String nmsTag = findNMSTag();
|
|
||||||
public static MultiverseCoreLink linkMultiverseCore;
|
public static MultiverseCoreLink linkMultiverseCore;
|
||||||
public static MythicMobsLink linkMythicMobs;
|
public static MythicMobsLink linkMythicMobs;
|
||||||
public static CitizensLink linkCitizens;
|
public static CitizensLink linkCitizens;
|
||||||
@ -81,6 +82,7 @@ public class Iris extends MortarPlugin
|
|||||||
|
|
||||||
public Iris()
|
public Iris()
|
||||||
{
|
{
|
||||||
|
INMS.get();
|
||||||
IO.delete(new File("iris"));
|
IO.delete(new File("iris"));
|
||||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
|
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
|
||||||
}
|
}
|
||||||
@ -99,22 +101,6 @@ public class Iris extends MortarPlugin
|
|||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String findNMSTag()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Bukkit.getServer().getClass().getCanonicalName().split("\\Q.\\E")[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
Iris.error("Failed to determine server nms version!");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "UNKNOWN NMS VERSION";
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProvisionBukkit createProvisionBukkit(IrisGenConfiguration config)
|
public ProvisionBukkit createProvisionBukkit(IrisGenConfiguration config)
|
||||||
{
|
{
|
||||||
return new ProvisionBukkit(createIrisProvider(config));
|
return new ProvisionBukkit(createIrisProvider(config));
|
||||||
@ -240,7 +226,7 @@ public class Iris extends MortarPlugin
|
|||||||
{
|
{
|
||||||
if(i.getGenerator() instanceof ProvisionBukkit)
|
if(i.getGenerator() instanceof ProvisionBukkit)
|
||||||
{
|
{
|
||||||
((IrisTerrainProvider) ((ProvisionBukkit) i.getGenerator()).getProvider()).close();
|
IrisWorlds.getProvider(i).close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +265,13 @@ public class Iris extends MortarPlugin
|
|||||||
public static void msg(String string)
|
public static void msg(String string)
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
if(instance == null)
|
||||||
|
{
|
||||||
|
System.out.println("[Iris]: " + string);
|
||||||
|
lock.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String msg = C.GREEN + "[Iris]: " + C.GRAY + string;
|
String msg = C.GREEN + "[Iris]: " + C.GRAY + string;
|
||||||
Bukkit.getConsoleSender().sendMessage(msg);
|
Bukkit.getConsoleSender().sendMessage(msg);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@ -440,11 +433,6 @@ public class Iris extends MortarPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String nmsTag()
|
|
||||||
{
|
|
||||||
return nmsTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void later(NastyRunnable object)
|
public static void later(NastyRunnable object)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,10 @@ public class IrisSettings
|
|||||||
@Desc("Useful information when creating iris worlds. Shows object loads & more.")
|
@Desc("Useful information when creating iris worlds. Shows object loads & more.")
|
||||||
public boolean verbose = false;
|
public boolean verbose = false;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("If true, will not use world edit even if its on the server")
|
||||||
|
public boolean ignoreWorldEdit = false;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("System Effects")
|
@Desc("System Effects")
|
||||||
public boolean systemEffects = true;
|
public boolean systemEffects = true;
|
||||||
@ -179,4 +183,12 @@ public class IrisSettings
|
|||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void invalidate()
|
||||||
|
{
|
||||||
|
synchronized(settings)
|
||||||
|
{
|
||||||
|
settings = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
import com.volmit.iris.util.MortarSender;
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class CommandIrisCTC extends MortarCommand
|
|||||||
sender.sendMessage("/iris ctc " + getArgsUsage());
|
sender.sendMessage("/iris ctc " + getArgsUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sender.isPlayer())
|
if(sender.isPlayer())
|
||||||
{
|
{
|
||||||
Player p = sender.player();
|
Player p = sender.player();
|
||||||
@ -39,7 +40,7 @@ public class CommandIrisCTC extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisTerrainProvider g = (IrisTerrainProvider) ((ProvisionBukkit) world.getGenerator()).getProvider();
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
int m = Math.min(Math.max(Integer.valueOf(args[0]), 2), 256);
|
int m = Math.min(Math.max(Integer.valueOf(args[0]), 2), 256);
|
||||||
g.changeThreadCount(m);
|
g.changeThreadCount(m);
|
||||||
sender.sendMessage("Thread count changed to " + m);
|
sender.sendMessage("Thread count changed to " + m);
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.WorldType;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.nms.NMSCreator;
|
import com.volmit.iris.gen.nms.INMS;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
@ -37,6 +37,7 @@ public class CommandIrisCreate extends MortarCommand
|
|||||||
if(args.length == 0)
|
if(args.length == 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage("/iris create <NAME> [type=overworld] [seed=1337] [pregen=5000] [-zip]");
|
sender.sendMessage("/iris create <NAME> [type=overworld] [seed=1337] [pregen=5000] [-zip]");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String worldName = args[0];
|
String worldName = args[0];
|
||||||
@ -109,7 +110,7 @@ public class CommandIrisCreate extends MortarCommand
|
|||||||
|
|
||||||
WorldCreator wc = new WorldCreator(worldName).seed(seed).generator(gen).type(WorldType.NORMAL).environment(dim.getEnvironment());
|
WorldCreator wc = new WorldCreator(worldName).seed(seed).generator(gen).type(WorldType.NORMAL).environment(dim.getEnvironment());
|
||||||
|
|
||||||
World world = NMSCreator.createWorld(wc, false);
|
World world = INMS.get().createWorld(wc, false);
|
||||||
|
|
||||||
done.set(true);
|
done.set(true);
|
||||||
sender.sendMessage(worldName + " Spawn Area generated.");
|
sender.sendMessage(worldName + " Spawn Area generated.");
|
||||||
|
@ -7,6 +7,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gen.scaffold.IrisMetrics;
|
import com.volmit.iris.gen.scaffold.IrisMetrics;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.util.C;
|
import com.volmit.iris.util.C;
|
||||||
import com.volmit.iris.util.Form;
|
import com.volmit.iris.util.Form;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
@ -35,7 +36,7 @@ public class CommandIrisMetrics extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisTerrainProvider g = (IrisTerrainProvider) ((ProvisionBukkit) world.getGenerator()).getProvider();
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
IrisMetrics m = g.getMetrics();
|
IrisMetrics m = g.getMetrics();
|
||||||
sender.sendMessage("Thread Count: " + C.BOLD + "" + C.WHITE + g.getThreads());
|
sender.sendMessage("Thread Count: " + C.BOLD + "" + C.WHITE + g.getThreads());
|
||||||
sender.sendMessage("Total : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTotal().getAverage(), 2));
|
sender.sendMessage("Total : " + C.BOLD + "" + C.WHITE + Form.duration(m.getTotal().getAverage(), 2));
|
||||||
|
@ -56,7 +56,7 @@ public class CommandIrisObjectPaste extends MortarCommand
|
|||||||
|
|
||||||
if(file == null || !file.exists())
|
if(file == null || !file.exists())
|
||||||
{
|
{
|
||||||
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.workspaceName + " folder");
|
sender.sendMessage("Can't find " + args[0] + " in the " + ProjectManager.WORKSPACE_NAME + " folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack wand = sender.player().getInventory().getItemInMainHand();
|
ItemStack wand = sender.player().getInventory().getItemInMainHand();
|
||||||
|
@ -35,11 +35,41 @@ public class CommandIrisPregen extends MortarCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("Stopped all pregens.");
|
sender.sendMessage("Stopped All Pregens.");
|
||||||
|
PregenJob.stop();
|
||||||
}
|
}
|
||||||
PregenJob.stop();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/* TODO: help
|
||||||
|
else if(args[0].equalsIgnoreCase("pause"))
|
||||||
|
{
|
||||||
|
if(PregenJob.task == -1)
|
||||||
|
{
|
||||||
|
sender.sendMessage("No Active Pregens");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (PregenJob.isPaused()) {
|
||||||
|
PregenJob.resume();
|
||||||
|
} else {
|
||||||
|
PregenJob.pause();
|
||||||
|
}
|
||||||
|
sender.sendMessage("Paused Active Pregen");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if(args[0].equalsIgnoreCase("resume")){
|
||||||
|
if(!PregenJob.isPaused())
|
||||||
|
{
|
||||||
|
sender.sendMessage("No Paused Pregens");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Resumed Paused Pregen");
|
||||||
|
PregenJob.resume();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if(sender.isPlayer())
|
if(sender.isPlayer())
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gen.scaffold.Provisioned;
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
@ -34,6 +35,13 @@ public class CommandIrisRegen extends MortarCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
Provisioned pr = (Provisioned) world.getGenerator();
|
Provisioned pr = (Provisioned) world.getGenerator();
|
||||||
|
|
||||||
|
if(((IrisTerrainProvider) pr.getProvider()).isFailing())
|
||||||
|
{
|
||||||
|
sender.sendMessage("This world is in a failed state! Cannot Regenerate!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
pr.clearRegeneratedLists();
|
pr.clearRegeneratedLists();
|
||||||
if(args.length == 0)
|
if(args.length == 0)
|
||||||
{
|
{
|
||||||
@ -53,6 +61,7 @@ public class CommandIrisRegen extends MortarCommand
|
|||||||
{
|
{
|
||||||
sender.sendMessage("/iris regen [SIZE]");
|
sender.sendMessage("/iris regen [SIZE]");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
src/main/java/com/volmit/iris/command/CommandIrisReload.java
Normal file
32
src/main/java/com/volmit/iris/command/CommandIrisReload.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisReload extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisReload()
|
||||||
|
{
|
||||||
|
super("reload", "rld");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setDescription("Reload configs");
|
||||||
|
setCategory("Studio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
IrisSettings.invalidate();
|
||||||
|
IrisSettings.get();
|
||||||
|
sender.sendMessage("settings.json Reloaded");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "<name> [-t/--trim]";
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,9 @@ public class CommandIrisStudio extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisStudioOpen open;
|
private CommandIrisStudioOpen open;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisStudioSummon summon;
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
private CommandIrisStudioClose close;
|
private CommandIrisStudioClose close;
|
||||||
|
|
||||||
@ -44,6 +47,9 @@ public class CommandIrisStudio extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisStudioLoot loot;
|
private CommandIrisStudioLoot loot;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisStudioTP tp;
|
||||||
|
|
||||||
public CommandIrisStudio()
|
public CommandIrisStudio()
|
||||||
{
|
{
|
||||||
super("studio", "std");
|
super("studio", "std");
|
||||||
|
@ -5,9 +5,9 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
import com.volmit.iris.util.MortarSender;
|
import com.volmit.iris.util.MortarSender;
|
||||||
@ -26,15 +26,9 @@ public class CommandIrisStudioGoto extends MortarCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(MortarSender sender, String[] args)
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if(!IrisSettings.get().isStudio())
|
|
||||||
{
|
|
||||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
{
|
{
|
||||||
sender.sendMessage("/iris world goto " + getArgsUsage());
|
sender.sendMessage("/iris std goto " + getArgsUsage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +43,7 @@ public class CommandIrisStudioGoto extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisTerrainProvider g = (IrisTerrainProvider) ((ProvisionBukkit) world.getGenerator()).getProvider();
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
int tries = 10000;
|
int tries = 10000;
|
||||||
boolean cave = false;
|
boolean cave = false;
|
||||||
IrisBiome biome2 = null;
|
IrisBiome biome2 = null;
|
||||||
|
@ -7,6 +7,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
import com.volmit.iris.util.MortarSender;
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class CommandIrisStudioHotload extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisTerrainProvider g = (IrisTerrainProvider) ((ProvisionBukkit) world.getGenerator()).getProvider();
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
g.onHotload();
|
g.onHotload();
|
||||||
sender.sendMessage("Hotloaded!");
|
sender.sendMessage("Hotloaded!");
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.object.InventorySlotType;
|
import com.volmit.iris.object.InventorySlotType;
|
||||||
import com.volmit.iris.object.IrisLootTable;
|
import com.volmit.iris.object.IrisLootTable;
|
||||||
@ -38,10 +39,44 @@ public class CommandIrisStudioLoot extends MortarCommand
|
|||||||
if(sender.isPlayer())
|
if(sender.isPlayer())
|
||||||
{
|
{
|
||||||
Player p = sender.player();
|
Player p = sender.player();
|
||||||
IrisWorlds.getProvider(sender.player().getWorld()).getPopulators();
|
IrisTerrainProvider prov = IrisWorlds.getProvider(sender.player().getWorld());
|
||||||
KList<IrisLootTable> tables = IrisWorlds.getProvider(sender.player().getWorld()).getGlUpdate().getLootTables(RNG.r, p.getLocation().getBlock());
|
|
||||||
|
if(prov == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(Iris.proj.getActiveProject().getActiveProvider().getGlUpdate() == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.initGLUpdate();
|
||||||
|
KList<IrisLootTable> tables = prov.getGlUpdate().getLootTables(RNG.r, p.getLocation().getBlock());
|
||||||
Inventory inv = Bukkit.createInventory(null, 27 * 2);
|
Inventory inv = Bukkit.createInventory(null, 27 * 2);
|
||||||
Iris.proj.getActiveProject().getActiveProvider().getGlUpdate().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Iris.proj.getActiveProject().getActiveProvider().getGlUpdate().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
sender.sendMessage("You can only use /iris loot in a studio world of iris.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
p.openInventory(inv);
|
p.openInventory(inv);
|
||||||
|
|
||||||
for(IrisLootTable i : tables)
|
for(IrisLootTable i : tables)
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
|
import com.volmit.iris.object.IrisEntity;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisStudioSummon extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisStudioSummon()
|
||||||
|
{
|
||||||
|
super("summon", "spawnmob");
|
||||||
|
setDescription("Spawn an Iris entity");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("Summon");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(!IrisSettings.get().isStudio())
|
||||||
|
{
|
||||||
|
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
Player p = sender.player();
|
||||||
|
World world = p.getWorld();
|
||||||
|
if(!(world.getGenerator() instanceof ProvisionBukkit))
|
||||||
|
{
|
||||||
|
sender.sendMessage("You must be in an iris world.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisTerrainProvider g = IrisWorlds.getProvider(world);
|
||||||
|
if(args.length == 0)
|
||||||
|
{
|
||||||
|
for(String i : g.getData().getEntityLoader().getPossibleKeys())
|
||||||
|
{
|
||||||
|
sender.sendMessage("- " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IrisEntity e = g.getData().getEntityLoader().load(args[0]);
|
||||||
|
|
||||||
|
if(e == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Couldnt find entity " + args[0] + ". Use '/iris std summon' to see a list of iris entities.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.spawn(g, sender.player().getLocation().clone().add(0, 3, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Players only.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.IrisSettings;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisStudioTP extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisStudioTP()
|
||||||
|
{
|
||||||
|
super("tp");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setDescription("Go to the spawn of the currently open studio world.");
|
||||||
|
setCategory("Studio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(!IrisSettings.get().isStudio())
|
||||||
|
{
|
||||||
|
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Iris.proj.isProjectOpen())
|
||||||
|
{
|
||||||
|
sender.sendMessage("There is not a studio currently loaded.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sender.sendMessage("Teleporting you to the active studio world.");
|
||||||
|
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getRealWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Failed to teleport to the studio world. Try re-opening the project.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,15 @@ public class CommandIrisStudioUpdate extends MortarCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
new IrisProject(Iris.proj.getWorkspaceFolder(args[0])).updateWorkspace();
|
if(new IrisProject(Iris.proj.getWorkspaceFolder(args[0])).updateWorkspace())
|
||||||
|
{
|
||||||
|
sender.sendMessage("Updated Code Workspace for " + args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Invalid project: " + args[0] + ". Try deleting the code-workspace file and try again.");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ public class CommandIrisWhat extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisWhatHand hand;
|
private CommandIrisWhatHand hand;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisWhatBiome biome;
|
||||||
|
|
||||||
public CommandIrisWhat()
|
public CommandIrisWhat()
|
||||||
{
|
{
|
||||||
super("what", "w", "?");
|
super("what", "w", "?");
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
|
import com.volmit.iris.object.IrisBiome;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisWhatBiome extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisWhatBiome()
|
||||||
|
{
|
||||||
|
super("biome", "bi");
|
||||||
|
setDescription("Get the biome data you are in.");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setCategory("Wut");
|
||||||
|
setDescription("What biome am i In");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
Player p = sender.player();
|
||||||
|
World w = p.getWorld();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
IrisTerrainProvider g = IrisWorlds.getProvider(w);
|
||||||
|
IrisBiome b = g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ());
|
||||||
|
sender.sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Non-Iris Biome: " + p.getLocation().getBlock().getBiome().name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Players only.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,9 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.B;
|
||||||
import com.volmit.iris.util.C;
|
import com.volmit.iris.util.C;
|
||||||
|
import com.volmit.iris.util.FastBlockData;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
import com.volmit.iris.util.MortarSender;
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
@ -27,9 +29,45 @@ public class CommandIrisWhatBlock extends MortarCommand
|
|||||||
{
|
{
|
||||||
Player p = sender.player();
|
Player p = sender.player();
|
||||||
BlockData bd = p.getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData();
|
BlockData bd = p.getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData();
|
||||||
if(bd != null) {
|
if(bd != null)
|
||||||
|
{
|
||||||
sender.sendMessage("Material: " + C.GREEN + bd.getMaterial().name());
|
sender.sendMessage("Material: " + C.GREEN + bd.getMaterial().name());
|
||||||
sender.sendMessage("Full: " + C.WHITE + bd.getAsString(true));
|
sender.sendMessage("Full: " + C.WHITE + bd.getAsString(true));
|
||||||
|
|
||||||
|
if(B.isStorage(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Storage Block (Loot Capable)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isLit(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Lit Block (Light Capable)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isFoliage(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Foliage Block");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isDecorant(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Decorant Block");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isFluid(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Fluid Block");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isFoliagePlantable(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Plantable Foliage Block");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isSolid(FastBlockData.of(bd)))
|
||||||
|
{
|
||||||
|
sender.sendMessage(C.YELLOW + "* Solid Block");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.gen.atomics.AtomicMulticache;
|
import com.volmit.iris.gen.atomics.AtomicMulticache;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.IrisContext;
|
import com.volmit.iris.gen.scaffold.IrisContext;
|
||||||
import com.volmit.iris.gen.scaffold.IrisMetrics;
|
import com.volmit.iris.gen.scaffold.IrisMetrics;
|
||||||
import com.volmit.iris.gen.scaffold.Provisioned;
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
@ -88,7 +89,7 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
tickLatch = new ChronoLatch(650);
|
tickLatch = new ChronoLatch(650);
|
||||||
perSecond = new ChronoLatch(1000);
|
perSecond = new ChronoLatch(1000);
|
||||||
hlast = M.ms();
|
hlast = M.ms();
|
||||||
cache = new AtomicMulticache((IrisTerrainProvider) this);
|
cache = new AtomicMulticache((SkyTerrainProvider) this);
|
||||||
CNG.creates = 0;
|
CNG.creates = 0;
|
||||||
generated = 0;
|
generated = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
@ -112,7 +113,7 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
warnings.add(warning);
|
warnings.add(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onGenerate(RNG masterRandom, int x, int z, TerrainChunk chunk);
|
protected abstract GeneratedChunk onGenerate(RNG masterRandom, int x, int z, TerrainChunk chunk);
|
||||||
|
|
||||||
protected abstract void onInit(RNG masterRandom);
|
protected abstract void onInit(RNG masterRandom);
|
||||||
|
|
||||||
@ -382,7 +383,7 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Random no, int x, int z, TerrainChunk terrain)
|
public GeneratedChunk generate(Random no, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
setHotloadable(false);
|
setHotloadable(false);
|
||||||
if(!isDev())
|
if(!isDev())
|
||||||
@ -394,20 +395,20 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
if(failing)
|
if(failing)
|
||||||
{
|
{
|
||||||
generateFailure(terrain);
|
generateFailure(terrain);
|
||||||
return;
|
return GeneratedChunk.builder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RNG random = new RNG(getTarget().getSeed());
|
RNG random = new RNG(getTarget().getSeed());
|
||||||
init(random.nextParallelRNG(0));
|
init(random.nextParallelRNG(0));
|
||||||
onGenerate(random, x, z, terrain);
|
GeneratedChunk c = onGenerate(random, x, z, terrain);
|
||||||
generated++;
|
generated++;
|
||||||
long hits = CNG.hits;
|
long hits = CNG.hits;
|
||||||
CNG.hits = 0;
|
CNG.hits = 0;
|
||||||
Iris.instance.hit(hits);
|
Iris.instance.hit(hits);
|
||||||
setHotloadable(true);
|
setHotloadable(true);
|
||||||
return;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
@ -417,6 +418,7 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
|
|
||||||
setHotloadable(true);
|
setHotloadable(true);
|
||||||
generateFailure(terrain);
|
generateFailure(terrain);
|
||||||
|
return GeneratedChunk.builder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCheckHotload()
|
private void doCheckHotload()
|
||||||
@ -468,7 +470,6 @@ public abstract class ContextualTerrainProvider implements TerrainProvider, List
|
|||||||
Iris.instance.imsg(i, C.DARK_RED + "Iris Generator has crashed!");
|
Iris.instance.imsg(i, C.DARK_RED + "Iris Generator has crashed!");
|
||||||
Iris.instance.imsg(i, C.RED + "- Check the console for the error.");
|
Iris.instance.imsg(i, C.RED + "- Check the console for the error.");
|
||||||
Iris.instance.imsg(i, C.RED + "- To Regen, use /iris std open <dim>");
|
Iris.instance.imsg(i, C.RED + "- To Regen, use /iris std open <dim>");
|
||||||
Iris.instance.imsg(i, C.RED + "- To Retry the chunk, use /iris world retry");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
public abstract class DimensionalTerrainProvider extends ContextualTerrainProvider
|
public abstract class DimensionalTerrainProvider extends ContextualTerrainProvider
|
||||||
{
|
{
|
||||||
private String dimensionName;
|
private String dimensionName;
|
||||||
|
private IrisDimension forceDimension;
|
||||||
protected static final FastBlockData AIR = FastBlockData.of(Material.AIR);
|
protected static final FastBlockData AIR = FastBlockData.of(Material.AIR);
|
||||||
protected static final FastBlockData CAVE_AIR = B.get("CAVE_AIR");
|
protected static final FastBlockData CAVE_AIR = B.get("CAVE_AIR");
|
||||||
protected static final FastBlockData BEDROCK = FastBlockData.of(Material.BEDROCK);
|
protected static final FastBlockData BEDROCK = FastBlockData.of(Material.BEDROCK);
|
||||||
@ -35,6 +36,7 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
|
|||||||
{
|
{
|
||||||
super(t);
|
super(t);
|
||||||
setDimensionName(dimensionName);
|
setDimensionName(dimensionName);
|
||||||
|
setForceDimension(null);
|
||||||
|
|
||||||
if(getDimensionName().isEmpty())
|
if(getDimensionName().isEmpty())
|
||||||
{
|
{
|
||||||
@ -99,6 +101,11 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void forceDimension(IrisDimension sky)
|
||||||
|
{
|
||||||
|
setForceDimension(sky);
|
||||||
|
}
|
||||||
|
|
||||||
protected void useDefaultDimensionSetupNOW()
|
protected void useDefaultDimensionSetupNOW()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -124,6 +131,11 @@ public abstract class DimensionalTerrainProvider extends ContextualTerrainProvid
|
|||||||
|
|
||||||
public IrisDimension getDimension()
|
public IrisDimension getDimension()
|
||||||
{
|
{
|
||||||
|
if(forceDimension != null)
|
||||||
|
{
|
||||||
|
return forceDimension;
|
||||||
|
}
|
||||||
|
|
||||||
IrisDimension d = loadDimension(getDimensionName());
|
IrisDimension d = loadDimension(getDimensionName());
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
@ -20,6 +20,7 @@ import org.bukkit.util.BlockVector;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.gen.atomics.AtomicRegionData;
|
import com.volmit.iris.gen.atomics.AtomicRegionData;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.IrisContext;
|
import com.volmit.iris.gen.scaffold.IrisContext;
|
||||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
@ -91,18 +92,19 @@ public class IrisTerrainProvider extends SkyTerrainProvider implements IrisConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Random no, int x, int z, TerrainChunk terrain)
|
public GeneratedChunk generate(Random no, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||||
super.generate(no, x, z, terrain);
|
GeneratedChunk c = super.generate(no, x, z, terrain);
|
||||||
s.end();
|
s.end();
|
||||||
getMetrics().getTotal().put(s.getMilliseconds());
|
getMetrics().getTotal().put(s.getMilliseconds());
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
protected GeneratedChunk onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
super.onGenerate(random, x, z, terrain);
|
return super.onGenerate(random, x, z, terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInit(RNG rng)
|
public void onInit(RNG rng)
|
||||||
@ -141,7 +143,15 @@ public class IrisTerrainProvider extends SkyTerrainProvider implements IrisConte
|
|||||||
{
|
{
|
||||||
spawnable = true;
|
spawnable = true;
|
||||||
super.onTick(ticks);
|
super.onTick(ticks);
|
||||||
tickEffects();
|
try
|
||||||
|
{
|
||||||
|
tickEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tickEffects()
|
protected void tickEffects()
|
||||||
@ -489,66 +499,79 @@ public class IrisTerrainProvider extends SkyTerrainProvider implements IrisConte
|
|||||||
@Override
|
@Override
|
||||||
protected void onSpawn(EntitySpawnEvent e)
|
protected void onSpawn(EntitySpawnEvent e)
|
||||||
{
|
{
|
||||||
if(isSpawnable())
|
if(getTarget().getRealWorld() == null || !getTarget().getRealWorld().equals(e.getEntity().getWorld()))
|
||||||
{
|
{
|
||||||
if(!IrisSettings.get().isSystemEntitySpawnOverrides())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(isSpawnable())
|
||||||
{
|
{
|
||||||
return;
|
if(!IrisSettings.get().isSystemEntitySpawnOverrides())
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x = e.getEntity().getLocation().getBlockX();
|
int x = e.getEntity().getLocation().getBlockX();
|
||||||
int y = e.getEntity().getLocation().getBlockY();
|
int y = e.getEntity().getLocation().getBlockY();
|
||||||
int z = e.getEntity().getLocation().getBlockZ();
|
int z = e.getEntity().getLocation().getBlockZ();
|
||||||
IrisDimension dim = getDimension();
|
IrisDimension dim = getDimension();
|
||||||
IrisRegion region = sampleRegion(x, z);
|
IrisRegion region = sampleRegion(x, z);
|
||||||
IrisBiome above = sampleTrueBiome(x, z);
|
IrisBiome above = sampleTrueBiome(x, z);
|
||||||
IrisBiome below = sampleTrueBiome(x, y, z);
|
IrisBiome below = sampleTrueBiome(x, y, z);
|
||||||
|
|
||||||
if(above.getLoadKey().equals(below.getLoadKey()))
|
if(above.getLoadKey().equals(below.getLoadKey()))
|
||||||
{
|
{
|
||||||
below = null;
|
below = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisStructureResult res = getStructure(x, y, z);
|
IrisStructureResult res = getStructure(x, y, z);
|
||||||
|
|
||||||
if(res != null && res.getTile() != null)
|
if(res != null && res.getTile() != null)
|
||||||
{
|
{
|
||||||
if(trySpawn(res.getTile().getEntitySpawnOverrides(), e))
|
if(trySpawn(res.getTile().getEntitySpawnOverrides(), e))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(res != null && res.getStructure() != null)
|
||||||
|
{
|
||||||
|
if(trySpawn(res.getStructure().getEntitySpawnOverrides(), e))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(below != null)
|
||||||
|
{
|
||||||
|
if(trySpawn(below.getEntitySpawnOverrides(), e))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trySpawn(above.getEntitySpawnOverrides(), e))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trySpawn(region.getEntitySpawnOverrides(), e))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trySpawn(dim.getEntitySpawnOverrides(), e))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(res != null && res.getStructure() != null)
|
catch(Throwable xe)
|
||||||
{
|
{
|
||||||
if(trySpawn(res.getStructure().getEntitySpawnOverrides(), e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(below != null)
|
|
||||||
{
|
|
||||||
if(trySpawn(below.getEntitySpawnOverrides(), e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(trySpawn(above.getEntitySpawnOverrides(), e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(trySpawn(region.getEntitySpawnOverrides(), e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(trySpawn(dim.getEntitySpawnOverrides(), e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +627,7 @@ public class IrisTerrainProvider extends SkyTerrainProvider implements IrisConte
|
|||||||
{
|
{
|
||||||
if(getDimension() == null)
|
if(getDimension() == null)
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDimension().isVanillaStructures();
|
return getDimension().isVanillaStructures();
|
||||||
|
@ -184,16 +184,19 @@ public abstract class ParallaxTerrainProvider extends TopographicTerrainProvider
|
|||||||
return new AtomicSliverMap();
|
return new AtomicSliverMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void initGLUpdate()
|
||||||
public List<BlockPopulator> getPopulators()
|
|
||||||
{
|
{
|
||||||
List<BlockPopulator> g = new KList<>();
|
|
||||||
|
|
||||||
if(getGlUpdate() == null)
|
if(getGlUpdate() == null)
|
||||||
{
|
{
|
||||||
setGlUpdate(new GenLayerUpdate(this));
|
setGlUpdate(new GenLayerUpdate(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockPopulator> getPopulators()
|
||||||
|
{
|
||||||
|
List<BlockPopulator> g = new KList<>();
|
||||||
|
initGLUpdate();
|
||||||
g.add(getGlUpdate());
|
g.add(getGlUpdate());
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
@ -447,11 +450,21 @@ public abstract class ParallaxTerrainProvider extends TopographicTerrainProvider
|
|||||||
{
|
{
|
||||||
for(IrisStructurePlacement k : r.getStructures())
|
for(IrisStructurePlacement k : r.getStructures())
|
||||||
{
|
{
|
||||||
|
if(k == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
k.place(this, random.nextParallelRNG(2228 * 2 * g++), i, j);
|
k.place(this, random.nextParallelRNG(2228 * 2 * g++), i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisStructurePlacement k : b.getStructures())
|
for(IrisStructurePlacement k : b.getStructures())
|
||||||
{
|
{
|
||||||
|
if(k == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
k.place(this, random.nextParallelRNG(-22228 * 4 * g++), i, j);
|
k.place(this, random.nextParallelRNG(-22228 * 4 * g++), i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.volmit.iris.gen;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||||
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
import com.volmit.iris.util.BiomeMap;
|
import com.volmit.iris.util.BiomeMap;
|
||||||
@ -44,7 +45,7 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
|||||||
Iris.info("Thread Count changed to " + getThreads());
|
Iris.info("Thread Count changed to " + getThreads());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled);
|
protected abstract int onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled);
|
||||||
|
|
||||||
protected void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap)
|
protected void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap)
|
||||||
{
|
{
|
||||||
@ -62,14 +63,14 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
|||||||
return onSampleColumnHeight(x >> 4, z >> 4, x, z, x & 15, z & 15);
|
return onSampleColumnHeight(x >> 4, z >> 4, x, z, x & 15, z & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
protected GeneratedChunk onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
AtomicSliverMap map = new AtomicSliverMap();
|
AtomicSliverMap map = new AtomicSliverMap();
|
||||||
HeightMap height = new HeightMap();
|
HeightMap height = new HeightMap();
|
||||||
String key = "c" + x + "," + z;
|
String key = "c" + x + "," + z;
|
||||||
BiomeMap biomeMap = new BiomeMap();
|
BiomeMap biomeMap = new BiomeMap();
|
||||||
int ii, jj;
|
int ii;
|
||||||
onPreGenerate(random, x, z, terrain, height, biomeMap, map);
|
onPreGenerate(random, x, z, terrain, height, biomeMap, map);
|
||||||
|
|
||||||
for(ii = 0; ii < 16; ii++)
|
for(ii = 0; ii < 16; ii++)
|
||||||
@ -77,14 +78,14 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
|||||||
int i = ii;
|
int i = ii;
|
||||||
int wx = (x * 16) + i;
|
int wx = (x * 16) + i;
|
||||||
|
|
||||||
for(jj = 0; jj < 16; jj++)
|
getAccelerant().queue(key, () ->
|
||||||
{
|
{
|
||||||
int j = jj;
|
for(int jj = 0; jj < 16; jj++)
|
||||||
int wz = (z * 16) + j;
|
|
||||||
AtomicSliver sliver = map.getSliver(i, j);
|
|
||||||
|
|
||||||
getAccelerant().queue(key, () ->
|
|
||||||
{
|
{
|
||||||
|
int j = jj;
|
||||||
|
int wz = (z * 16) + j;
|
||||||
|
AtomicSliver sliver = map.getSliver(i, j);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
onGenerateColumn(x, z, wx, wz, i, j, sliver, biomeMap);
|
onGenerateColumn(x, z, wx, wz, i, j, sliver, biomeMap);
|
||||||
@ -94,8 +95,8 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
|||||||
{
|
{
|
||||||
fail(e);
|
fail(e);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
accelerant.waitFor(key);
|
accelerant.waitFor(key);
|
||||||
@ -103,6 +104,14 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
|||||||
getMetrics().getTerrain().put(p.getMilliseconds());
|
getMetrics().getTerrain().put(p.getMilliseconds());
|
||||||
p = PrecisionStopwatch.start();
|
p = PrecisionStopwatch.start();
|
||||||
onPostGenerate(random, x, z, terrain, height, biomeMap, map);
|
onPostGenerate(random, x, z, terrain, height, biomeMap, map);
|
||||||
|
return GeneratedChunk.builder()
|
||||||
|
.biomeMap(biomeMap)
|
||||||
|
.sliverMap(map)
|
||||||
|
.height(height)
|
||||||
|
.terrain(terrain)
|
||||||
|
.x(x)
|
||||||
|
.z(z)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onClose()
|
protected void onClose()
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.generator.ChunkGenerator.ChunkData;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.post.PostMasterPatcher;
|
import com.volmit.iris.gen.post.PostMasterPatcher;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
import com.volmit.iris.util.CaveResult;
|
import com.volmit.iris.util.CaveResult;
|
||||||
@ -39,13 +40,13 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
protected GeneratedChunk onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
super.onGenerate(random, x, z, terrain);
|
GeneratedChunk map = super.onGenerate(random, x, z, terrain);
|
||||||
|
|
||||||
if(!getDimension().isPostProcessing())
|
if(!getDimension().isPostProcessing())
|
||||||
{
|
{
|
||||||
return;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rx, i;
|
int rx, i;
|
||||||
@ -74,6 +75,7 @@ public abstract class PostBlockTerrainProvider extends ParallaxTerrainProvider i
|
|||||||
|
|
||||||
p.end();
|
p.end();
|
||||||
getMetrics().getPost().put(p.getMilliseconds());
|
getMetrics().getPost().put(p.getMilliseconds());
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.volmit.iris.gen;
|
package com.volmit.iris.gen;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
@ -12,8 +13,9 @@ public abstract class SkyTerrainProvider extends PostBlockTerrainProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
protected GeneratedChunk onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
super.onGenerate(random, x, z, terrain);
|
GeneratedChunk gc = super.onGenerate(random, x, z, terrain);
|
||||||
|
return gc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.volmit.iris.gen.layer.GenLayerBiome;
|
|||||||
import com.volmit.iris.gen.layer.GenLayerCarve;
|
import com.volmit.iris.gen.layer.GenLayerCarve;
|
||||||
import com.volmit.iris.gen.layer.GenLayerCave;
|
import com.volmit.iris.gen.layer.GenLayerCave;
|
||||||
import com.volmit.iris.gen.layer.GenLayerRavine;
|
import com.volmit.iris.gen.layer.GenLayerRavine;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
import com.volmit.iris.noise.CNG;
|
import com.volmit.iris.noise.CNG;
|
||||||
@ -19,6 +20,7 @@ import com.volmit.iris.object.DecorationPart;
|
|||||||
import com.volmit.iris.object.InferredType;
|
import com.volmit.iris.object.InferredType;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.object.IrisBiomeDecorator;
|
import com.volmit.iris.object.IrisBiomeDecorator;
|
||||||
|
import com.volmit.iris.object.IrisCaveFluid;
|
||||||
import com.volmit.iris.object.IrisDepositGenerator;
|
import com.volmit.iris.object.IrisDepositGenerator;
|
||||||
import com.volmit.iris.object.IrisDimension;
|
import com.volmit.iris.object.IrisDimension;
|
||||||
import com.volmit.iris.object.IrisGenerator;
|
import com.volmit.iris.object.IrisGenerator;
|
||||||
@ -119,7 +121,7 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled)
|
protected int onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver, BiomeMap biomeMap, boolean sampled)
|
||||||
{
|
{
|
||||||
if(x > 15 || x < 0 || z > 15 || z < 0)
|
if(x > 15 || x < 0 || z > 15 || z < 0)
|
||||||
{
|
{
|
||||||
@ -141,6 +143,7 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
|
|||||||
IrisBiome biome = sampleTrueBiome(rx, rz);
|
IrisBiome biome = sampleTrueBiome(rx, rz);
|
||||||
IrisBiome carveBiome = null;
|
IrisBiome carveBiome = null;
|
||||||
Biome onlyBiome = Iris.biome3d ? null : biome.getGroundBiome(getMasterRandom(), rz, getDimension().getFluidHeight(), rx);
|
Biome onlyBiome = Iris.biome3d ? null : biome.getGroundBiome(getMasterRandom(), rz, getDimension().getFluidHeight(), rx);
|
||||||
|
IrisCaveFluid forceFluid = getDimension().getForceFluid().hasFluid(getData()) ? getDimension().getForceFluid() : null;
|
||||||
|
|
||||||
if(biome == null)
|
if(biome == null)
|
||||||
{
|
{
|
||||||
@ -281,6 +284,11 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
|
|||||||
|
|
||||||
decorateLand(crand, carveBiome, sliver, k, rx, rz, block);
|
decorateLand(crand, carveBiome, sliver, k, rx, rz, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(forceFluid != null && B.isAir(block) && (forceFluid.isInverseHeight() ? k >= forceFluid.getFluidHeight() : k <= forceFluid.getFluidHeight()))
|
||||||
|
{
|
||||||
|
sliver.set(k, forceFluid.getFluid(getData()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carve out biomes
|
// Carve out biomes
|
||||||
@ -339,17 +347,21 @@ public abstract class TopographicTerrainProvider extends ParallelTerrainProvider
|
|||||||
{
|
{
|
||||||
decorateLand(crand, biome, sliver, Math.max(height, fluidHeight), rx, rz, block);
|
decorateLand(crand, biome, sliver, Math.max(height, fluidHeight), rx, rz, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
protected GeneratedChunk onGenerate(RNG random, int x, int z, TerrainChunk terrain)
|
||||||
{
|
{
|
||||||
super.onGenerate(random, x, z, terrain);
|
GeneratedChunk map = super.onGenerate(random, x, z, terrain);
|
||||||
|
|
||||||
if(!getDimension().isVanillaCaves())
|
if(!getDimension().isVanillaCaves())
|
||||||
{
|
{
|
||||||
generateDeposits(random.nextParallelRNG(x * ((z * 39) + 10000)).nextParallelRNG(z + z - x), terrain, x, z);
|
generateDeposits(random.nextParallelRNG(x * ((z * 39) + 10000)).nextParallelRNG(z + z - x), terrain, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decorateLand(RNG rng, IrisBiome biome, AtomicSliver sliver, int k, int rx, int rz, FastBlockData block)
|
private void decorateLand(RNG rng, IrisBiome biome, AtomicSliver sliver, int k, int rx, int rz, FastBlockData block)
|
||||||
|
@ -3,7 +3,7 @@ package com.volmit.iris.gen.atomics;
|
|||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.SkyTerrainProvider;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
import com.volmit.iris.util.ChunkPosition;
|
import com.volmit.iris.util.ChunkPosition;
|
||||||
@ -18,7 +18,7 @@ public class AtomicMulticache
|
|||||||
private final LoadingCache<ChunkPosition, IrisBiome> rawBiome;
|
private final LoadingCache<ChunkPosition, IrisBiome> rawBiome;
|
||||||
private final LoadingCache<ChunkPosition, IrisRegion> region;
|
private final LoadingCache<ChunkPosition, IrisRegion> region;
|
||||||
|
|
||||||
public AtomicMulticache(IrisTerrainProvider gen)
|
public AtomicMulticache(SkyTerrainProvider gen)
|
||||||
{
|
{
|
||||||
height = Caffeine.newBuilder().maximumSize(getLimit()).build((c) -> gen.getNoiseHeight(c.getX(), c.getZ()) + gen.getFluidHeight());
|
height = Caffeine.newBuilder().maximumSize(getLimit()).build((c) -> gen.getNoiseHeight(c.getX(), c.getZ()) + gen.getFluidHeight());
|
||||||
carvedHeight = Caffeine.newBuilder().maximumSize(getLimit()).build((c) ->
|
carvedHeight = Caffeine.newBuilder().maximumSize(getLimit()).build((c) ->
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.volmit.iris.gen.layer;
|
package com.volmit.iris.gen.layer;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -196,24 +197,16 @@ public class GenLayerUpdate extends BlockPopulator
|
|||||||
{
|
{
|
||||||
KList<ItemStack> items = new KList<>();
|
KList<ItemStack> items = new KList<>();
|
||||||
|
|
||||||
for(int t = 0; t < gen.getDimension().getLootTries(); t++)
|
int b = 4;
|
||||||
|
for(IrisLootTable i : tables)
|
||||||
{
|
{
|
||||||
int b = 4;
|
b++;
|
||||||
for(IrisLootTable i : tables)
|
items.addAll(i.getLoot(debug, items.isEmpty(), rng.nextParallelRNG(345911), slot, x, y, z, b + b, mgf + b));
|
||||||
{
|
}
|
||||||
b++;
|
|
||||||
items.addAll(i.getLoot(debug, rng.nextParallelRNG(345911 * -t), slot, x, y, z, t + b + b, mgf + b));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(ItemStack i : items)
|
for(ItemStack i : items)
|
||||||
{
|
{
|
||||||
inv.addItem(i);
|
inv.addItem(i);
|
||||||
}
|
|
||||||
|
|
||||||
if(items.isNotEmpty())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scramble(inv, rng);
|
scramble(inv, rng);
|
||||||
@ -231,11 +224,12 @@ public class GenLayerUpdate extends BlockPopulator
|
|||||||
if(slot != null)
|
if(slot != null)
|
||||||
{
|
{
|
||||||
KList<IrisLootTable> tables = getLootTables(rng.nextParallelRNG(4568111), b);
|
KList<IrisLootTable> tables = getLootTables(rng.nextParallelRNG(4568111), b);
|
||||||
|
InventorySlotType slott = slot;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InventoryHolder m = (InventoryHolder) b.getState();
|
InventoryHolder m = (InventoryHolder) b.getState();
|
||||||
addItems(false, m.getInventory(), rng, tables, slot, rx, b.getY(), rz, 15);
|
addItems(false, m.getInventory(), rng, tables, slott, rx, b.getY(), rz, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable ignored)
|
catch(Throwable ignored)
|
||||||
@ -247,64 +241,49 @@ public class GenLayerUpdate extends BlockPopulator
|
|||||||
|
|
||||||
public void scramble(Inventory inventory, RNG rng)
|
public void scramble(Inventory inventory, RNG rng)
|
||||||
{
|
{
|
||||||
KList<ItemStack> v = new KList<>();
|
ItemStack[] items = inventory.getContents();
|
||||||
|
ItemStack[] nitems = new ItemStack[inventory.getSize()];
|
||||||
|
System.arraycopy(items, 0, nitems, 0, items.length);
|
||||||
|
boolean packedFull = false;
|
||||||
|
|
||||||
for(ItemStack i : inventory.getContents())
|
splitting: for(int i = 0; i < nitems.length; i++)
|
||||||
{
|
{
|
||||||
if(i == null)
|
ItemStack is = nitems[i];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
v.add(i);
|
if(is != null && is.getAmount() > 1 && !packedFull)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < nitems.length; j++)
|
||||||
|
{
|
||||||
|
if(nitems[j] == null)
|
||||||
|
{
|
||||||
|
int take = rng.nextInt(is.getAmount());
|
||||||
|
take = take == 0 ? 1 : take;
|
||||||
|
is.setAmount(is.getAmount() - take);
|
||||||
|
nitems[j] = is.clone();
|
||||||
|
nitems[j].setAmount(take);
|
||||||
|
continue splitting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
packedFull = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.clear();
|
for(int i = 0; i < 4; i++)
|
||||||
int sz = inventory.getSize();
|
|
||||||
int tr = 5;
|
|
||||||
|
|
||||||
while(v.isNotEmpty())
|
|
||||||
{
|
{
|
||||||
int slot = rng.i(0, sz - 1);
|
try
|
||||||
|
|
||||||
if(inventory.getItem(slot) == null)
|
|
||||||
{
|
|
||||||
tr = tr < 5 ? tr + 1 : tr;
|
|
||||||
int pick = rng.i(0, v.size() - 1);
|
|
||||||
ItemStack g = v.get(pick);
|
|
||||||
|
|
||||||
if(g.getAmount() == 1)
|
|
||||||
{
|
|
||||||
v.remove(pick);
|
|
||||||
inventory.setItem(pick, g);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int portion = rng.i(1, g.getAmount() - 1);
|
|
||||||
ItemStack port = g.clone();
|
|
||||||
port.setAmount(portion);
|
|
||||||
g.setAmount(g.getAmount() - portion);
|
|
||||||
v.add(g);
|
|
||||||
inventory.setItem(slot, port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tr--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tr <= 0)
|
|
||||||
{
|
{
|
||||||
|
Arrays.parallelSort(nitems, (a, b) -> rng.nextInt());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ItemStack i : v)
|
inventory.setContents(nitems);
|
||||||
{
|
|
||||||
inventory.addItem(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLight(Block b, FastBlockData data)
|
public void updateLight(Block b, FastBlockData data)
|
||||||
|
66
src/main/java/com/volmit/iris/gen/nms/INMS.java
Normal file
66
src/main/java/com/volmit/iris/gen/nms/INMS.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package com.volmit.iris.gen.nms;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.nms.v16_2.NMSBinding16_2;
|
||||||
|
import com.volmit.iris.gen.nms.v1X.NMSBinding1X;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
|
|
||||||
|
public class INMS
|
||||||
|
{
|
||||||
|
//@builder
|
||||||
|
private static final KMap<String, Class<? extends INMSBinding>> bindings = new KMap<String, Class<? extends INMSBinding>>()
|
||||||
|
.qput("v1_16_R2", NMSBinding16_2.class);
|
||||||
|
//@done
|
||||||
|
private static final INMSBinding binding = bind();
|
||||||
|
|
||||||
|
public static INMSBinding get()
|
||||||
|
{
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String getNMSTag()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Bukkit.getServer().getClass().getCanonicalName().split("\\Q.\\E")[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
Iris.error("Failed to determine server nms version!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "BUKKIT";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final INMSBinding bind()
|
||||||
|
{
|
||||||
|
String code = getNMSTag();
|
||||||
|
Iris.info("Locating NMS Binding for " + code);
|
||||||
|
|
||||||
|
if(bindings.containsKey(code))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
INMSBinding b = bindings.get(code).getConstructor().newInstance();
|
||||||
|
Iris.info("Craftbukkit " + code + " <-> " + b.getClass().getSimpleName() + " Successfully Bound");
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.info("Craftbukkit " + code + " <-> " + NMSBinding1X.class.getSimpleName() + " Successfully Bound");
|
||||||
|
Iris.warn("Note: Some features of Iris may not work the same since you are on an unsupported version of Minecraft.");
|
||||||
|
Iris.warn("Note: If this is a new version, expect an update soon.");
|
||||||
|
|
||||||
|
return new NMSBinding1X();
|
||||||
|
}
|
||||||
|
}
|
19
src/main/java/com/volmit/iris/gen/nms/INMSBinding.java
Normal file
19
src/main/java/com/volmit/iris/gen/nms/INMSBinding.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.volmit.iris.gen.nms;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
public interface INMSBinding
|
||||||
|
{
|
||||||
|
public INMSCreator getCreator();
|
||||||
|
|
||||||
|
default World createWorld(WorldCreator creator)
|
||||||
|
{
|
||||||
|
return getCreator().createWorld(creator);
|
||||||
|
}
|
||||||
|
|
||||||
|
default World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||||
|
{
|
||||||
|
return getCreator().createWorld(creator, loadSpawn);
|
||||||
|
}
|
||||||
|
}
|
14
src/main/java/com/volmit/iris/gen/nms/INMSCreator.java
Normal file
14
src/main/java/com/volmit/iris/gen/nms/INMSCreator.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.volmit.iris.gen.nms;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
public interface INMSCreator
|
||||||
|
{
|
||||||
|
default World createWorld(WorldCreator creator)
|
||||||
|
{
|
||||||
|
return createWorld(creator, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public World createWorld(WorldCreator creator, boolean loadSpawn);
|
||||||
|
}
|
@ -1,56 +0,0 @@
|
|||||||
package com.volmit.iris.gen.nms;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.IrisSettings;
|
|
||||||
|
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
|
|
||||||
public class NMSCreator
|
|
||||||
{
|
|
||||||
public static World createWorld(WorldCreator creator)
|
|
||||||
{
|
|
||||||
return createWorld(creator, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
|
||||||
{
|
|
||||||
if(IrisSettings.get().isSkipPrepareSpawnNMS())
|
|
||||||
{
|
|
||||||
if(!PaperLib.isPaper())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String code = Iris.nmsTag();
|
|
||||||
|
|
||||||
if(code.equals("v1_16_R2"))
|
|
||||||
{
|
|
||||||
return NMSCreator162.createWorld(creator, loadSpawn);
|
|
||||||
}
|
|
||||||
else if(code.equals("v1_16_R1"))
|
|
||||||
{
|
|
||||||
return NMSCreator161.createWorld(creator, loadSpawn);
|
|
||||||
}
|
|
||||||
else if(code.equals("v1_15_R1"))
|
|
||||||
{
|
|
||||||
return NMSCreator151.createWorld(creator, loadSpawn);
|
|
||||||
}
|
|
||||||
else if(code.equals("v1_14_R1"))
|
|
||||||
{
|
|
||||||
return NMSCreator141.createWorld(creator, loadSpawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Bukkit.createWorld(creator);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package com.volmit.iris.gen.nms;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.volmit.iris.util.V;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_14_R1.DedicatedServer;
|
|
||||||
import net.minecraft.server.v1_14_R1.DimensionManager;
|
|
||||||
import net.minecraft.server.v1_14_R1.EnumDifficulty;
|
|
||||||
import net.minecraft.server.v1_14_R1.EnumGamemode;
|
|
||||||
import net.minecraft.server.v1_14_R1.GameProfilerFiller;
|
|
||||||
import net.minecraft.server.v1_14_R1.MinecraftServer;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldData;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldNBTStorage;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldProvider;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
|
||||||
import net.minecraft.server.v1_14_R1.WorldSettings;
|
|
||||||
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
|
|
||||||
import net.minecraft.server.v1_14_R1.TicketType;
|
|
||||||
import net.minecraft.server.v1_14_R1.Unit;
|
|
||||||
|
|
||||||
public class NMSCreator141
|
|
||||||
{
|
|
||||||
public static void addStartTicket(Location center, int size)
|
|
||||||
{
|
|
||||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"resource", "deprecation"})
|
|
||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
|
||||||
{
|
|
||||||
CraftServer server = ((CraftServer) Bukkit.getServer());
|
|
||||||
Map<String, World> worlds = new V(server).get("worlds");
|
|
||||||
DedicatedServer console = new V(server).get("console");
|
|
||||||
WorldSettings worldSettings;
|
|
||||||
Preconditions.checkState((boolean) (!console.worldServer.isEmpty()), (Object) "Cannot create additional worlds on STARTUP");
|
|
||||||
Validate.notNull((Object) creator, (String) "Creator may not be null");
|
|
||||||
String name = creator.name();
|
|
||||||
ChunkGenerator generator = creator.generator();
|
|
||||||
File folder = new File(server.getWorldContainer(), name);
|
|
||||||
World world = server.getWorld(name);
|
|
||||||
net.minecraft.server.v1_14_R1.WorldType type = net.minecraft.server.v1_14_R1.WorldType.getType((String) creator.type().getName());
|
|
||||||
boolean generateStructures = creator.generateStructures();
|
|
||||||
if(world != null)
|
|
||||||
{
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
if(folder.exists() && !folder.isDirectory())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
|
||||||
}
|
|
||||||
if(generator == null)
|
|
||||||
{
|
|
||||||
generator = server.getGenerator(name);
|
|
||||||
}
|
|
||||||
console.convertWorld(name);
|
|
||||||
int dimension = 10 + console.worldServer.size();
|
|
||||||
boolean used = false;
|
|
||||||
block0: do
|
|
||||||
{
|
|
||||||
for(WorldServer ss : console.getWorlds())
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
boolean bl = used = ss.getWorldProvider().getDimensionManager().getDimensionID() == dimension;
|
|
||||||
if(!used)
|
|
||||||
continue;
|
|
||||||
++dimension;
|
|
||||||
continue block0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(used);
|
|
||||||
boolean hardcore = false;
|
|
||||||
WorldNBTStorage sdm = new WorldNBTStorage(server.getWorldContainer(), name, (MinecraftServer) server.getServer(), server.getHandle().getServer().dataConverterManager);
|
|
||||||
WorldData worlddata = sdm.getWorldData();
|
|
||||||
if(worlddata == null)
|
|
||||||
{
|
|
||||||
worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById((int) server.getDefaultGameMode().getValue()), generateStructures, hardcore, type);
|
|
||||||
JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings());
|
|
||||||
if(parsedSettings.isJsonObject())
|
|
||||||
{
|
|
||||||
worldSettings.setGeneratorSettings((JsonElement) parsedSettings.getAsJsonObject());
|
|
||||||
}
|
|
||||||
worlddata = new WorldData(worldSettings, name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
worlddata.setName(name);
|
|
||||||
worldSettings = new WorldSettings(worlddata);
|
|
||||||
}
|
|
||||||
DimensionManager actualDimension = DimensionManager.a((int) creator.environment().getId());
|
|
||||||
DimensionManager internalDimension = DimensionManager.register((String) name.toLowerCase(Locale.ENGLISH), (DimensionManager) new DimensionManager(dimension, actualDimension.getSuffix(), actualDimension.folder, (w, manager) -> (WorldProvider) manager.providerFactory.apply(w, manager), actualDimension.hasSkyLight(), actualDimension));
|
|
||||||
//@builder
|
|
||||||
WorldServer internal = new WorldServer(
|
|
||||||
(MinecraftServer)console,
|
|
||||||
console.executorService,
|
|
||||||
sdm,
|
|
||||||
worlddata,
|
|
||||||
internalDimension,
|
|
||||||
(GameProfilerFiller)console.getMethodProfiler(),
|
|
||||||
server.getServer().worldLoadListenerFactory.create(11),
|
|
||||||
creator.environment(),
|
|
||||||
generator);
|
|
||||||
//@done
|
|
||||||
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
console.initWorld(internal, worlddata, worldSettings);
|
|
||||||
internal.worldData.setDifficulty(EnumDifficulty.EASY);
|
|
||||||
internal.setSpawnFlags(true, true);
|
|
||||||
console.worldServer.put(internal.getWorldProvider().getDimensionManager(), internal);
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
|
|
||||||
|
|
||||||
if(loadSpawn)
|
|
||||||
{
|
|
||||||
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MinecraftServer.LOGGER.info("Preparing start region for dimens... Oh wait, We don't do that here anymore.");
|
|
||||||
}
|
|
||||||
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
|
|
||||||
return internal.getWorld();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package com.volmit.iris.gen.nms;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.volmit.iris.util.V;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.DedicatedServer;
|
|
||||||
import net.minecraft.server.v1_15_R1.DimensionManager;
|
|
||||||
import net.minecraft.server.v1_15_R1.EnumDifficulty;
|
|
||||||
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
|
||||||
import net.minecraft.server.v1_15_R1.GameProfilerFiller;
|
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldData;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldNBTStorage;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldProvider;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
|
||||||
import net.minecraft.server.v1_15_R1.WorldSettings;
|
|
||||||
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair;
|
|
||||||
import net.minecraft.server.v1_15_R1.TicketType;
|
|
||||||
import net.minecraft.server.v1_15_R1.Unit;
|
|
||||||
|
|
||||||
public class NMSCreator151
|
|
||||||
{
|
|
||||||
public static void addStartTicket(Location center, int size)
|
|
||||||
{
|
|
||||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"resource", "deprecation"})
|
|
||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
|
||||||
{
|
|
||||||
CraftServer server = ((CraftServer) Bukkit.getServer());
|
|
||||||
Map<String, World> worlds = new V(server).get("worlds");
|
|
||||||
DedicatedServer console = new V(server).get("console");
|
|
||||||
WorldSettings worldSettings;
|
|
||||||
Preconditions.checkState((boolean) (!console.worldServer.isEmpty()), (Object) "Cannot create additional worlds on STARTUP");
|
|
||||||
Validate.notNull((Object) creator, (String) "Creator may not be null");
|
|
||||||
String name = creator.name();
|
|
||||||
ChunkGenerator generator = creator.generator();
|
|
||||||
File folder = new File(server.getWorldContainer(), name);
|
|
||||||
World world = server.getWorld(name);
|
|
||||||
net.minecraft.server.v1_15_R1.WorldType type = net.minecraft.server.v1_15_R1.WorldType.getType((String) creator.type().getName());
|
|
||||||
boolean generateStructures = creator.generateStructures();
|
|
||||||
if(world != null)
|
|
||||||
{
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
if(folder.exists() && !folder.isDirectory())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
|
||||||
}
|
|
||||||
if(generator == null)
|
|
||||||
{
|
|
||||||
generator = server.getGenerator(name);
|
|
||||||
}
|
|
||||||
console.convertWorld(name);
|
|
||||||
int dimension = 10 + console.worldServer.size();
|
|
||||||
boolean used = false;
|
|
||||||
block0: do
|
|
||||||
{
|
|
||||||
for(WorldServer ss : console.getWorlds())
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
boolean bl = used = ss.getWorldProvider().getDimensionManager().getDimensionID() == dimension;
|
|
||||||
if(!used)
|
|
||||||
continue;
|
|
||||||
++dimension;
|
|
||||||
continue block0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while(used);
|
|
||||||
boolean hardcore = false;
|
|
||||||
WorldNBTStorage sdm = new WorldNBTStorage(server.getWorldContainer(), name, (MinecraftServer) server.getServer(), server.getHandle().getServer().dataConverterManager);
|
|
||||||
WorldData worlddata = sdm.getWorldData();
|
|
||||||
if(worlddata == null)
|
|
||||||
{
|
|
||||||
worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById((int) server.getDefaultGameMode().getValue()), generateStructures, hardcore, type);
|
|
||||||
JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings());
|
|
||||||
if(parsedSettings.isJsonObject())
|
|
||||||
{
|
|
||||||
worldSettings.setGeneratorSettings((JsonElement) parsedSettings.getAsJsonObject());
|
|
||||||
}
|
|
||||||
worlddata = new WorldData(worldSettings, name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
worlddata.setName(name);
|
|
||||||
worldSettings = new WorldSettings(worlddata);
|
|
||||||
}
|
|
||||||
DimensionManager actualDimension = DimensionManager.a((int) creator.environment().getId());
|
|
||||||
DimensionManager internalDimension = DimensionManager.register((String) name.toLowerCase(Locale.ENGLISH), (DimensionManager) new DimensionManager(dimension, actualDimension.getSuffix(), actualDimension.folder, (w, manager) -> (WorldProvider) manager.providerFactory.apply(w, manager), actualDimension.hasSkyLight(), actualDimension.getGenLayerZoomer(), actualDimension));
|
|
||||||
//@builder
|
|
||||||
WorldServer internal = new WorldServer(
|
|
||||||
(MinecraftServer)console,
|
|
||||||
console.executorService,
|
|
||||||
sdm,
|
|
||||||
worlddata,
|
|
||||||
internalDimension,
|
|
||||||
(GameProfilerFiller)console.getMethodProfiler(),
|
|
||||||
server.getServer().worldLoadListenerFactory.create(11),
|
|
||||||
creator.environment(),
|
|
||||||
generator);
|
|
||||||
//@done
|
|
||||||
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
console.initWorld(internal, worlddata, worldSettings);
|
|
||||||
internal.worldData.setDifficulty(EnumDifficulty.EASY);
|
|
||||||
internal.setSpawnFlags(true, true);
|
|
||||||
console.worldServer.put(internal.getWorldProvider().getDimensionManager(), internal);
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
|
|
||||||
|
|
||||||
if(loadSpawn)
|
|
||||||
{
|
|
||||||
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MinecraftServer.LOGGER.info("Preparing start region for dimens... Oh wait, We don't do that here anymore.");
|
|
||||||
}
|
|
||||||
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
|
|
||||||
return internal.getWorld();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,218 +0,0 @@
|
|||||||
package com.volmit.iris.gen.nms;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.mojang.serialization.DynamicOps;
|
|
||||||
import com.mojang.serialization.Lifecycle;
|
|
||||||
import com.volmit.iris.util.V;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_16_R1.BiomeManager;
|
|
||||||
import net.minecraft.server.v1_16_R1.Convertable;
|
|
||||||
import net.minecraft.server.v1_16_R1.DedicatedServer;
|
|
||||||
import net.minecraft.server.v1_16_R1.DimensionManager;
|
|
||||||
import net.minecraft.server.v1_16_R1.DynamicOpsNBT;
|
|
||||||
import net.minecraft.server.v1_16_R1.EnumDifficulty;
|
|
||||||
import net.minecraft.server.v1_16_R1.EnumGamemode;
|
|
||||||
import net.minecraft.server.v1_16_R1.GameRules;
|
|
||||||
import net.minecraft.server.v1_16_R1.GeneratorSettings;
|
|
||||||
import net.minecraft.server.v1_16_R1.IRegistry;
|
|
||||||
import net.minecraft.server.v1_16_R1.IWorldDataServer;
|
|
||||||
import net.minecraft.server.v1_16_R1.MinecraftKey;
|
|
||||||
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
|
||||||
import net.minecraft.server.v1_16_R1.MobSpawner;
|
|
||||||
import net.minecraft.server.v1_16_R1.MobSpawnerCat;
|
|
||||||
import net.minecraft.server.v1_16_R1.MobSpawnerPatrol;
|
|
||||||
import net.minecraft.server.v1_16_R1.MobSpawnerPhantom;
|
|
||||||
import net.minecraft.server.v1_16_R1.MobSpawnerTrader;
|
|
||||||
import net.minecraft.server.v1_16_R1.NBTBase;
|
|
||||||
import net.minecraft.server.v1_16_R1.RegistryMaterials;
|
|
||||||
import net.minecraft.server.v1_16_R1.RegistryReadOps;
|
|
||||||
import net.minecraft.server.v1_16_R1.ResourceKey;
|
|
||||||
import net.minecraft.server.v1_16_R1.SaveData;
|
|
||||||
import net.minecraft.server.v1_16_R1.VillageSiege;
|
|
||||||
import net.minecraft.server.v1_16_R1.WorldDataServer;
|
|
||||||
import net.minecraft.server.v1_16_R1.WorldDimension;
|
|
||||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
|
||||||
import net.minecraft.server.v1_16_R1.WorldSettings;
|
|
||||||
import net.minecraft.server.v1_16_R1.ChunkCoordIntPair;
|
|
||||||
import net.minecraft.server.v1_16_R1.TicketType;
|
|
||||||
import net.minecraft.server.v1_16_R1.Unit;
|
|
||||||
|
|
||||||
public class NMSCreator161
|
|
||||||
{
|
|
||||||
public static void addStartTicket(Location center, int size)
|
|
||||||
{
|
|
||||||
((CraftWorld) center.getWorld()).getHandle().getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(center.getBlockX() >> 4, center.getBlockZ() >> 4), size, Unit.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
|
|
||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
|
||||||
{
|
|
||||||
CraftServer server = ((CraftServer) Bukkit.getServer());
|
|
||||||
Map<String, World> worlds = new V(server).get("worlds");
|
|
||||||
DedicatedServer console = new V(server).get("console");
|
|
||||||
Preconditions.checkState(!console.worldServer.isEmpty(), (Object) "Cannot create additional worlds on STARTUP");
|
|
||||||
Validate.notNull((Object) creator, "Creator may not be null");
|
|
||||||
final String name = creator.name();
|
|
||||||
org.bukkit.generator.ChunkGenerator generator = creator.generator();
|
|
||||||
final File folder = new File(server.getWorldContainer(), name);
|
|
||||||
final World world = server.getWorld(name);
|
|
||||||
|
|
||||||
if(world != null)
|
|
||||||
{
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(folder.exists() && !folder.isDirectory())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(generator == null)
|
|
||||||
{
|
|
||||||
generator = server.getGenerator(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceKey<WorldDimension> actualDimension = null;
|
|
||||||
switch(creator.environment())
|
|
||||||
{
|
|
||||||
case NORMAL:
|
|
||||||
{
|
|
||||||
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.OVERWORLD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NETHER:
|
|
||||||
{
|
|
||||||
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_NETHER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case THE_END:
|
|
||||||
{
|
|
||||||
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_END;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Illegal dimension");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Convertable.ConversionSession worldSession;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, (ResourceKey) actualDimension);
|
|
||||||
}
|
|
||||||
catch(IOException ex)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
MinecraftServer.convertWorld(worldSession);
|
|
||||||
final boolean hardcore = creator.hardcore();
|
|
||||||
final RegistryReadOps<NBTBase> registryreadops = (RegistryReadOps<NBTBase>) RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), console.f);
|
|
||||||
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
|
|
||||||
if(worlddata == null)
|
|
||||||
{
|
|
||||||
final Properties properties = new Properties();
|
|
||||||
properties.put("generator-settings", Objects.toString(creator.generatorSettings()));
|
|
||||||
properties.put("level-seed", Objects.toString(creator.seed()));
|
|
||||||
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
|
|
||||||
properties.put("level-type", Objects.toString(creator.type().getName()));
|
|
||||||
GeneratorSettings generatorsettings = GeneratorSettings.a((Properties) properties);
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
final WorldSettings worldSettings = new WorldSettings(name, EnumGamemode.getById(server.getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
|
|
||||||
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
|
|
||||||
}
|
|
||||||
worlddata.checkName(name);
|
|
||||||
worlddata.a(console.getServerModName(), console.getModded().isPresent());
|
|
||||||
final long j = BiomeManager.a(creator.seed());
|
|
||||||
final List<MobSpawner> list = (List<MobSpawner>) ImmutableList.of((MobSpawner) new MobSpawnerPhantom(), (MobSpawner) new MobSpawnerPatrol(), (MobSpawner) new MobSpawnerCat(), (MobSpawner) new VillageSiege(), (MobSpawner) new MobSpawnerTrader((IWorldDataServer) worlddata));
|
|
||||||
RegistryMaterials registrymaterials = worlddata.getGeneratorSettings().e();
|
|
||||||
final WorldDimension worlddimension = (WorldDimension) registrymaterials.a((ResourceKey) actualDimension);
|
|
||||||
DimensionManager dimensionmanager;
|
|
||||||
net.minecraft.server.v1_16_R1.ChunkGenerator chunkgenerator;
|
|
||||||
|
|
||||||
if(worlddimension == null)
|
|
||||||
{
|
|
||||||
dimensionmanager = DimensionManager.a();
|
|
||||||
chunkgenerator = GeneratorSettings.a((long) new Random().nextLong());
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dimensionmanager = worlddimension.b();
|
|
||||||
chunkgenerator = worlddimension.c();
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceKey typeKey = (ResourceKey) console.f.a().c(dimensionmanager).orElseThrow(() -> new IllegalStateException("Unregistered dimension type: " + (Object) dimensionmanager));
|
|
||||||
ResourceKey worldKey = ResourceKey.a((ResourceKey) IRegistry.ae, (MinecraftKey) new MinecraftKey(name.toLowerCase(Locale.ENGLISH)));
|
|
||||||
|
|
||||||
//@builder
|
|
||||||
WorldServer internal = new WorldServer(
|
|
||||||
(MinecraftServer)console,
|
|
||||||
console.executorService,
|
|
||||||
worldSession,
|
|
||||||
(IWorldDataServer)worlddata,
|
|
||||||
worldKey,
|
|
||||||
typeKey,
|
|
||||||
dimensionmanager,
|
|
||||||
server.getServer().worldLoadListenerFactory.create(11),
|
|
||||||
chunkgenerator,
|
|
||||||
worlddata.getGeneratorSettings().isDebugWorld(),
|
|
||||||
j,
|
|
||||||
(List)(creator.environment() == World.Environment.NORMAL ? list : ImmutableList.of()),
|
|
||||||
true,
|
|
||||||
creator.environment(),
|
|
||||||
generator);
|
|
||||||
|
|
||||||
//@done
|
|
||||||
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
internal.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
console.initWorld(internal, (IWorldDataServer) worlddata, (SaveData) worlddata, worlddata.getGeneratorSettings());
|
|
||||||
internal.setSpawnFlags(true, true);
|
|
||||||
console.worldServer.put(internal.getDimensionKey(), internal);
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
|
|
||||||
if(loadSpawn)
|
|
||||||
{
|
|
||||||
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MinecraftServer.LOGGER.info("Preparing start region for dimens... Oh wait, We don't do that here anymore.");
|
|
||||||
}
|
|
||||||
|
|
||||||
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
|
|
||||||
return (World) internal.getWorld();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v16_2;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
|
import com.volmit.iris.gen.nms.INMSBinding;
|
||||||
|
import com.volmit.iris.gen.nms.INMSCreator;
|
||||||
|
|
||||||
|
public class NMSBinding16_2 implements INMSBinding
|
||||||
|
{
|
||||||
|
private final AtomicCache<INMSCreator> creator = new AtomicCache<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INMSCreator getCreator()
|
||||||
|
{
|
||||||
|
return creator.aquire(() -> new NMSCreator16_2());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,793 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v16_2;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeSettingsMobs;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockColumn;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Blocks;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGeneratorAbstract;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkSection;
|
||||||
|
import net.minecraft.server.v1_16_R2.EnumCreatureType;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorSettingBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.HeightMap;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.IChunkAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.MathHelper;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseGenerator3;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseGenerator3Handler;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseGeneratorOctaves;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseGeneratorPerlin;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseSettings;
|
||||||
|
import net.minecraft.server.v1_16_R2.ProtoChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.RegionLimitedWorldAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.ResourceKey;
|
||||||
|
import net.minecraft.server.v1_16_R2.SectionPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.SeededRandom;
|
||||||
|
import net.minecraft.server.v1_16_R2.SpawnerCreature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureBoundingBox;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructurePiece;
|
||||||
|
import net.minecraft.server.v1_16_R2.SystemUtils;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManagerTheEnd;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructureJigsawJunction;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructurePoolTemplate;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeaturePillagerOutpostPoolPiece;
|
||||||
|
|
||||||
|
public class NMSChunkGenerator16_2_BACKUP extends ChunkGenerator
|
||||||
|
{
|
||||||
|
//@builder
|
||||||
|
public static final Codec<NMSChunkGenerator16_2_BACKUP> d = RecordCodecBuilder.create((instance) -> {
|
||||||
|
return instance.group(WorldChunkManager.a.fieldOf("biome_source").forGetter((chunkgeneratorabstract) -> {
|
||||||
|
return chunkgeneratorabstract.b;
|
||||||
|
}), Codec.LONG.fieldOf("seed").stable().forGetter((chunkgeneratorabstract) -> {
|
||||||
|
return chunkgeneratorabstract.w;
|
||||||
|
}), GeneratorSettingBase.b.fieldOf("settings").forGetter((chunkgeneratorabstract) -> {
|
||||||
|
return chunkgeneratorabstract.h;
|
||||||
|
})).apply(instance, instance.stable(NMSChunkGenerator16_2_BACKUP::new));
|
||||||
|
});
|
||||||
|
//@done
|
||||||
|
|
||||||
|
private static final float[] i = SystemUtils.a((new float[13824]), (afloat) ->
|
||||||
|
{ // CraftBukkit - decompile error
|
||||||
|
for(int i = 0; i < 24; ++i)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < 24; ++j)
|
||||||
|
{
|
||||||
|
for(int k = 0; k < 24; ++k)
|
||||||
|
{
|
||||||
|
afloat[i * 24 * 24 + j * 24 + k] = (float) b(j - 12, k - 12, i - 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
private static final float[] j = SystemUtils.a((new float[25]), (afloat) ->
|
||||||
|
{ // CraftBukkit - decompile error
|
||||||
|
for(int i = -2; i <= 2; ++i)
|
||||||
|
{
|
||||||
|
for(int j = -2; j <= 2; ++j)
|
||||||
|
{
|
||||||
|
float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F);
|
||||||
|
|
||||||
|
afloat[i + 2 + (j + 2) * 5] = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
private static final IBlockData k = Blocks.AIR.getBlockData();
|
||||||
|
private final int l;
|
||||||
|
private final int m;
|
||||||
|
private final int n;
|
||||||
|
private final int o;
|
||||||
|
private final int p;
|
||||||
|
protected final SeededRandom e;
|
||||||
|
private final NoiseGeneratorOctaves q;
|
||||||
|
private final NoiseGeneratorOctaves r;
|
||||||
|
private final NoiseGeneratorOctaves s;
|
||||||
|
private final NoiseGenerator t;
|
||||||
|
private final NoiseGeneratorOctaves u;
|
||||||
|
private final NoiseGenerator3Handler v;
|
||||||
|
protected final IBlockData f;
|
||||||
|
protected final IBlockData g;
|
||||||
|
private final long w;
|
||||||
|
protected final Supplier<GeneratorSettingBase> h;
|
||||||
|
private final int x;
|
||||||
|
|
||||||
|
public NMSChunkGenerator16_2_BACKUP(WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
this(worldchunkmanager, worldchunkmanager, i, supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NMSChunkGenerator16_2_BACKUP(WorldChunkManager worldchunkmanager, WorldChunkManager worldchunkmanager1, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
super(worldchunkmanager, worldchunkmanager1, supplier.get().a(), i);
|
||||||
|
this.w = i;
|
||||||
|
GeneratorSettingBase generatorsettingbase = supplier.get();
|
||||||
|
|
||||||
|
this.h = supplier;
|
||||||
|
NoiseSettings noisesettings = generatorsettingbase.b();
|
||||||
|
|
||||||
|
this.x = noisesettings.a();
|
||||||
|
this.l = noisesettings.f() * 4;
|
||||||
|
this.m = noisesettings.e() * 4;
|
||||||
|
this.f = generatorsettingbase.c();
|
||||||
|
this.g = generatorsettingbase.d();
|
||||||
|
this.n = 16 / this.m;
|
||||||
|
this.o = noisesettings.a() / this.l;
|
||||||
|
this.p = 16 / this.m;
|
||||||
|
this.e = new SeededRandom(i);
|
||||||
|
this.q = new NoiseGeneratorOctaves(this.e, IntStream.rangeClosed(-15, 0));
|
||||||
|
this.r = new NoiseGeneratorOctaves(this.e, IntStream.rangeClosed(-15, 0));
|
||||||
|
this.s = new NoiseGeneratorOctaves(this.e, IntStream.rangeClosed(-7, 0));
|
||||||
|
this.t = (NoiseGenerator) (noisesettings.i() ? new NoiseGenerator3(this.e, IntStream.rangeClosed(-3, 0)) : new NoiseGeneratorOctaves(this.e, IntStream.rangeClosed(-3, 0)));
|
||||||
|
this.e.a(2620);
|
||||||
|
this.u = new NoiseGeneratorOctaves(this.e, IntStream.rangeClosed(-15, 0));
|
||||||
|
if(noisesettings.k())
|
||||||
|
{
|
||||||
|
SeededRandom seededrandom = new SeededRandom(i);
|
||||||
|
|
||||||
|
seededrandom.a(17292);
|
||||||
|
this.v = new NoiseGenerator3Handler(seededrandom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.v = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends ChunkGenerator> a()
|
||||||
|
{
|
||||||
|
return ChunkGeneratorAbstract.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean a(long i, ResourceKey<GeneratorSettingBase> resourcekey)
|
||||||
|
{
|
||||||
|
return this.w == i && this.h.get().a(resourcekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double a(int i, int j, int k, double d0, double d1, double d2, double d3)
|
||||||
|
{
|
||||||
|
double d4 = 0.0D;
|
||||||
|
double d5 = 0.0D;
|
||||||
|
double d6 = 0.0D;
|
||||||
|
double d7 = 1.0D;
|
||||||
|
|
||||||
|
for(int l = 0; l < 16; ++l)
|
||||||
|
{
|
||||||
|
double d8 = NoiseGeneratorOctaves.a((double) i * d0 * d7);
|
||||||
|
double d9 = NoiseGeneratorOctaves.a((double) j * d1 * d7);
|
||||||
|
double d10 = NoiseGeneratorOctaves.a((double) k * d0 * d7);
|
||||||
|
double d11 = d1 * d7;
|
||||||
|
NoiseGeneratorPerlin noisegeneratorperlin = this.q.a(l);
|
||||||
|
|
||||||
|
if(noisegeneratorperlin != null)
|
||||||
|
{
|
||||||
|
d4 += noisegeneratorperlin.a(d8, d9, d10, d11, (double) j * d11) / d7;
|
||||||
|
}
|
||||||
|
|
||||||
|
NoiseGeneratorPerlin noisegeneratorperlin1 = this.r.a(l);
|
||||||
|
|
||||||
|
if(noisegeneratorperlin1 != null)
|
||||||
|
{
|
||||||
|
d5 += noisegeneratorperlin1.a(d8, d9, d10, d11, (double) j * d11) / d7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l < 8)
|
||||||
|
{
|
||||||
|
NoiseGeneratorPerlin noisegeneratorperlin2 = this.s.a(l);
|
||||||
|
|
||||||
|
if(noisegeneratorperlin2 != null)
|
||||||
|
{
|
||||||
|
d6 += noisegeneratorperlin2.a(NoiseGeneratorOctaves.a((double) i * d2 * d7), NoiseGeneratorOctaves.a((double) j * d3 * d7), NoiseGeneratorOctaves.a((double) k * d2 * d7), d3 * d7, (double) j * d3 * d7) / d7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d7 /= 2.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MathHelper.b(d4 / 512.0D, d5 / 512.0D, (d6 / 10.0D + 1.0D) / 2.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double[] b(int i, int j)
|
||||||
|
{
|
||||||
|
double[] adouble = new double[this.o + 1];
|
||||||
|
|
||||||
|
this.a(adouble, i, j);
|
||||||
|
return adouble;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void a(double[] adouble, int i, int j)
|
||||||
|
{
|
||||||
|
NoiseSettings noisesettings = this.h.get().b();
|
||||||
|
double d0;
|
||||||
|
double d1;
|
||||||
|
double d2;
|
||||||
|
double d3;
|
||||||
|
|
||||||
|
if(this.v != null)
|
||||||
|
{
|
||||||
|
d0 = (double) (WorldChunkManagerTheEnd.a(this.v, i, j) - 8.0F);
|
||||||
|
if(d0 > 0.0D)
|
||||||
|
{
|
||||||
|
d1 = 0.25D;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d1 = 1.0D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float f = 0.0F;
|
||||||
|
float f1 = 0.0F;
|
||||||
|
float f2 = 0.0F;
|
||||||
|
int k = this.getSeaLevel();
|
||||||
|
float f3 = this.b.getBiome(i, k, j).h();
|
||||||
|
|
||||||
|
for(int l = -2; l <= 2; ++l)
|
||||||
|
{
|
||||||
|
for(int i1 = -2; i1 <= 2; ++i1)
|
||||||
|
{
|
||||||
|
BiomeBase biomebase = this.b.getBiome(i + l, k, j + i1);
|
||||||
|
float f4 = biomebase.h();
|
||||||
|
float f5 = biomebase.j();
|
||||||
|
float f6;
|
||||||
|
float f7;
|
||||||
|
|
||||||
|
if(noisesettings.l() && f4 > 0.0F)
|
||||||
|
{
|
||||||
|
f6 = 1.0F + f4 * 2.0F;
|
||||||
|
f7 = 1.0F + f5 * 4.0F;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f6 = f4;
|
||||||
|
f7 = f5;
|
||||||
|
}
|
||||||
|
// CraftBukkit start - fix MC-54738
|
||||||
|
if(f6 < -1.8F)
|
||||||
|
{
|
||||||
|
f6 = -1.8F;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
float f8 = f4 > f3 ? 0.5F : 1.0F;
|
||||||
|
float f9 = f8 * NMSChunkGenerator16_2_BACKUP.j[l + 2 + (i1 + 2) * 5] / (f6 + 2.0F);
|
||||||
|
|
||||||
|
f += f7 * f9;
|
||||||
|
f1 += f6 * f9;
|
||||||
|
f2 += f9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float f10 = f1 / f2;
|
||||||
|
float f11 = f / f2;
|
||||||
|
|
||||||
|
d2 = (double) (f10 * 0.5F - 0.125F);
|
||||||
|
d3 = (double) (f11 * 0.9F + 0.1F);
|
||||||
|
d0 = d2 * 0.265625D;
|
||||||
|
d1 = 96.0D / d3;
|
||||||
|
}
|
||||||
|
|
||||||
|
double d4 = 684.412D * noisesettings.b().a();
|
||||||
|
double d5 = 684.412D * noisesettings.b().b();
|
||||||
|
double d6 = d4 / noisesettings.b().c();
|
||||||
|
double d7 = d5 / noisesettings.b().d();
|
||||||
|
|
||||||
|
d2 = (double) noisesettings.c().a();
|
||||||
|
d3 = (double) noisesettings.c().b();
|
||||||
|
double d8 = (double) noisesettings.c().c();
|
||||||
|
double d9 = (double) noisesettings.d().a();
|
||||||
|
double d10 = (double) noisesettings.d().b();
|
||||||
|
double d11 = (double) noisesettings.d().c();
|
||||||
|
double d12 = noisesettings.j() ? this.c(i, j) : 0.0D;
|
||||||
|
double d13 = noisesettings.g();
|
||||||
|
double d14 = noisesettings.h();
|
||||||
|
|
||||||
|
for(int j1 = 0; j1 <= this.o; ++j1)
|
||||||
|
{
|
||||||
|
double d15 = this.a(i, j1, j, d4, d5, d6, d7);
|
||||||
|
double d16 = 1.0D - (double) j1 * 2.0D / (double) this.o + d12;
|
||||||
|
double d17 = d16 * d13 + d14;
|
||||||
|
double d18 = (d17 + d0) * d1;
|
||||||
|
|
||||||
|
if(d18 > 0.0D)
|
||||||
|
{
|
||||||
|
d15 += d18 * 4.0D;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d15 += d18;
|
||||||
|
}
|
||||||
|
|
||||||
|
double d19;
|
||||||
|
|
||||||
|
if(d3 > 0.0D)
|
||||||
|
{
|
||||||
|
d19 = ((double) (this.o - j1) - d8) / d3;
|
||||||
|
d15 = MathHelper.b(d2, d15, d19);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d10 > 0.0D)
|
||||||
|
{
|
||||||
|
d19 = ((double) j1 - d11) / d10;
|
||||||
|
d15 = MathHelper.b(d9, d15, d19);
|
||||||
|
}
|
||||||
|
|
||||||
|
adouble[j1] = d15;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private double c(int i, int j)
|
||||||
|
{
|
||||||
|
double d0 = this.u.a((double) (i * 200), 10.0D, (double) (j * 200), 1.0D, 0.0D, true);
|
||||||
|
double d1;
|
||||||
|
|
||||||
|
if(d0 < 0.0D)
|
||||||
|
{
|
||||||
|
d1 = -d0 * 0.3D;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d1 = d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double d2 = d1 * 24.575625D - 2.0D;
|
||||||
|
|
||||||
|
return d2 < 0.0D ? d2 * 0.009486607142857142D : Math.min(d2, 1.0D) * 0.006640625D;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type)
|
||||||
|
{
|
||||||
|
return this.a(i, j, (IBlockData[]) null, heightmap_type.e());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockAccess a(int i, int j)
|
||||||
|
{
|
||||||
|
IBlockData[] aiblockdata = new IBlockData[this.o * this.l];
|
||||||
|
|
||||||
|
this.a(i, j, aiblockdata, (Predicate<IBlockData>) null);
|
||||||
|
return new BlockColumn(aiblockdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int a(int i, int j, @Nullable IBlockData[] aiblockdata, @Nullable Predicate<IBlockData> predicate)
|
||||||
|
{
|
||||||
|
int k = Math.floorDiv(i, this.m);
|
||||||
|
int l = Math.floorDiv(j, this.m);
|
||||||
|
int i1 = Math.floorMod(i, this.m);
|
||||||
|
int j1 = Math.floorMod(j, this.m);
|
||||||
|
double d0 = (double) i1 / (double) this.m;
|
||||||
|
double d1 = (double) j1 / (double) this.m;
|
||||||
|
double[][] adouble = new double[][] {this.b(k, l), this.b(k, l + 1), this.b(k + 1, l), this.b(k + 1, l + 1)};
|
||||||
|
|
||||||
|
for(int k1 = this.o - 1; k1 >= 0; --k1)
|
||||||
|
{
|
||||||
|
double d2 = adouble[0][k1];
|
||||||
|
double d3 = adouble[1][k1];
|
||||||
|
double d4 = adouble[2][k1];
|
||||||
|
double d5 = adouble[3][k1];
|
||||||
|
double d6 = adouble[0][k1 + 1];
|
||||||
|
double d7 = adouble[1][k1 + 1];
|
||||||
|
double d8 = adouble[2][k1 + 1];
|
||||||
|
double d9 = adouble[3][k1 + 1];
|
||||||
|
|
||||||
|
for(int l1 = this.l - 1; l1 >= 0; --l1)
|
||||||
|
{
|
||||||
|
double d10 = (double) l1 / (double) this.l;
|
||||||
|
double d11 = MathHelper.a(d10, d0, d1, d2, d6, d4, d8, d3, d7, d5, d9);
|
||||||
|
int i2 = k1 * this.l + l1;
|
||||||
|
IBlockData iblockdata = this.a(d11, i2);
|
||||||
|
|
||||||
|
if(aiblockdata != null)
|
||||||
|
{
|
||||||
|
aiblockdata[i2] = iblockdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(predicate != null && predicate.test(iblockdata))
|
||||||
|
{
|
||||||
|
return i2 + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBlockData a(double d0, int i)
|
||||||
|
{
|
||||||
|
IBlockData iblockdata;
|
||||||
|
|
||||||
|
if(d0 > 0.0D)
|
||||||
|
{
|
||||||
|
iblockdata = this.f;
|
||||||
|
}
|
||||||
|
else if(i < this.getSeaLevel())
|
||||||
|
{
|
||||||
|
iblockdata = this.g;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iblockdata = NMSChunkGenerator16_2_BACKUP.k;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
int i = chunkcoordintpair.x;
|
||||||
|
int j = chunkcoordintpair.z;
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
|
||||||
|
seededrandom.a(i, j);
|
||||||
|
ChunkCoordIntPair chunkcoordintpair1 = ichunkaccess.getPos();
|
||||||
|
int k = chunkcoordintpair1.d();
|
||||||
|
int l = chunkcoordintpair1.e();
|
||||||
|
// double d0 = 0.0625D;
|
||||||
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||||
|
|
||||||
|
for(int i1 = 0; i1 < 16; ++i1)
|
||||||
|
{
|
||||||
|
for(int j1 = 0; j1 < 16; ++j1)
|
||||||
|
{
|
||||||
|
int k1 = k + i1;
|
||||||
|
int l1 = l + j1;
|
||||||
|
int i2 = ichunkaccess.getHighestBlock(HeightMap.Type.WORLD_SURFACE_WG, i1, j1) + 1;
|
||||||
|
double d1 = this.t.a((double) k1 * 0.0625D, (double) l1 * 0.0625D, 0.0625D, (double) i1 * 0.0625D) * 15.0D;
|
||||||
|
|
||||||
|
regionlimitedworldaccess.getBiome(blockposition_mutableblockposition.d(k + i1, i2, l + j1)).a(seededrandom, ichunkaccess, k1, l1, i2, d1, this.f, this.g, this.getSeaLevel(), regionlimitedworldaccess.getSeed());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.a(ichunkaccess, seededrandom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void a(IChunkAccess ichunkaccess, Random random)
|
||||||
|
{
|
||||||
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||||
|
int i = ichunkaccess.getPos().d();
|
||||||
|
int j = ichunkaccess.getPos().e();
|
||||||
|
GeneratorSettingBase generatorsettingbase = this.h.get();
|
||||||
|
int k = generatorsettingbase.f();
|
||||||
|
int l = this.x - 1 - generatorsettingbase.e();
|
||||||
|
boolean flag1 = l + 4 >= 0 && l < this.x;
|
||||||
|
boolean flag2 = k + 4 >= 0 && k < this.x;
|
||||||
|
|
||||||
|
if(flag1 || flag2)
|
||||||
|
{
|
||||||
|
Iterator<BlockPosition> iterator = BlockPosition.b(i, 0, j, i + 15, 0, j + 15).iterator();
|
||||||
|
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
BlockPosition blockposition = iterator.next();
|
||||||
|
int i1;
|
||||||
|
|
||||||
|
if(flag1)
|
||||||
|
{
|
||||||
|
for(i1 = 0; i1 < 5; ++i1)
|
||||||
|
{
|
||||||
|
if(i1 <= random.nextInt(5))
|
||||||
|
{
|
||||||
|
ichunkaccess.setType(blockposition_mutableblockposition.d(blockposition.getX(), l - i1, blockposition.getZ()), Blocks.BEDROCK.getBlockData(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag2)
|
||||||
|
{
|
||||||
|
for(i1 = 4; i1 >= 0; --i1)
|
||||||
|
{
|
||||||
|
if(i1 <= random.nextInt(5))
|
||||||
|
{
|
||||||
|
ichunkaccess.setType(blockposition_mutableblockposition.d(blockposition.getX(), k + i1, blockposition.getZ()), Blocks.BEDROCK.getBlockData(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
ObjectList<StructurePiece> objectlist = new ObjectArrayList<StructurePiece>(10);
|
||||||
|
ObjectList<WorldGenFeatureDefinedStructureJigsawJunction> objectlist1 = new ObjectArrayList<WorldGenFeatureDefinedStructureJigsawJunction>(32);
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
int i = chunkcoordintpair.x;
|
||||||
|
int j = chunkcoordintpair.z;
|
||||||
|
int k = i << 4;
|
||||||
|
int l = j << 4;
|
||||||
|
Iterator<?> iterator = StructureGenerator.t.iterator();
|
||||||
|
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
StructureGenerator<?> structuregenerator = (StructureGenerator<?>) iterator.next();
|
||||||
|
|
||||||
|
structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) ->
|
||||||
|
{
|
||||||
|
Iterator<?> iterator1 = structurestart.d().iterator();
|
||||||
|
|
||||||
|
while(iterator1.hasNext())
|
||||||
|
{
|
||||||
|
StructurePiece structurepiece = (StructurePiece) iterator1.next();
|
||||||
|
|
||||||
|
if(structurepiece.a(chunkcoordintpair, 12))
|
||||||
|
{
|
||||||
|
if(structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece)
|
||||||
|
{
|
||||||
|
WorldGenFeaturePillagerOutpostPoolPiece worldgenfeaturepillageroutpostpoolpiece = (WorldGenFeaturePillagerOutpostPoolPiece) structurepiece;
|
||||||
|
WorldGenFeatureDefinedStructurePoolTemplate.Matching worldgenfeaturedefinedstructurepooltemplate_matching = worldgenfeaturepillageroutpostpoolpiece.b().e();
|
||||||
|
|
||||||
|
if(worldgenfeaturedefinedstructurepooltemplate_matching == WorldGenFeatureDefinedStructurePoolTemplate.Matching.RIGID)
|
||||||
|
{
|
||||||
|
objectlist.add(worldgenfeaturepillageroutpostpoolpiece);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<?> iterator2 = worldgenfeaturepillageroutpostpoolpiece.e().iterator();
|
||||||
|
|
||||||
|
while(iterator2.hasNext())
|
||||||
|
{
|
||||||
|
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = (WorldGenFeatureDefinedStructureJigsawJunction) iterator2.next();
|
||||||
|
int i1 = worldgenfeaturedefinedstructurejigsawjunction.a();
|
||||||
|
int j1 = worldgenfeaturedefinedstructurejigsawjunction.c();
|
||||||
|
|
||||||
|
if(i1 > k - 12 && j1 > l - 12 && i1 < k + 15 + 12 && j1 < l + 15 + 12)
|
||||||
|
{
|
||||||
|
objectlist1.add(worldgenfeaturedefinedstructurejigsawjunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objectlist.add(structurepiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
double[][][] adouble = new double[2][this.p + 1][this.o + 1];
|
||||||
|
|
||||||
|
for(int i1 = 0; i1 < this.p + 1; ++i1)
|
||||||
|
{
|
||||||
|
adouble[0][i1] = new double[this.o + 1];
|
||||||
|
this.a(adouble[0][i1], i * this.n, j * this.p + i1);
|
||||||
|
adouble[1][i1] = new double[this.o + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
|
||||||
|
HeightMap heightmap = protochunk.a(HeightMap.Type.OCEAN_FLOOR_WG);
|
||||||
|
HeightMap heightmap1 = protochunk.a(HeightMap.Type.WORLD_SURFACE_WG);
|
||||||
|
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||||
|
ObjectListIterator<StructurePiece> objectlistiterator = objectlist.iterator();
|
||||||
|
ObjectListIterator<WorldGenFeatureDefinedStructureJigsawJunction> objectlistiterator1 = objectlist1.iterator();
|
||||||
|
|
||||||
|
for(int j1 = 0; j1 < this.n; ++j1)
|
||||||
|
{
|
||||||
|
int k1;
|
||||||
|
|
||||||
|
for(k1 = 0; k1 < this.p + 1; ++k1)
|
||||||
|
{
|
||||||
|
this.a(adouble[1][k1], i * this.n + j1 + 1, j * this.p + k1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(k1 = 0; k1 < this.p; ++k1)
|
||||||
|
{
|
||||||
|
ChunkSection chunksection = protochunk.a(15);
|
||||||
|
|
||||||
|
chunksection.a();
|
||||||
|
|
||||||
|
for(int l1 = this.o - 1; l1 >= 0; --l1)
|
||||||
|
{
|
||||||
|
double d0 = adouble[0][k1][l1];
|
||||||
|
double d1 = adouble[0][k1 + 1][l1];
|
||||||
|
double d2 = adouble[1][k1][l1];
|
||||||
|
double d3 = adouble[1][k1 + 1][l1];
|
||||||
|
double d4 = adouble[0][k1][l1 + 1];
|
||||||
|
double d5 = adouble[0][k1 + 1][l1 + 1];
|
||||||
|
double d6 = adouble[1][k1][l1 + 1];
|
||||||
|
double d7 = adouble[1][k1 + 1][l1 + 1];
|
||||||
|
|
||||||
|
for(int i2 = this.l - 1; i2 >= 0; --i2)
|
||||||
|
{
|
||||||
|
int j2 = l1 * this.l + i2;
|
||||||
|
int k2 = j2 & 15;
|
||||||
|
int l2 = j2 >> 4;
|
||||||
|
|
||||||
|
if(chunksection.getYPosition() >> 4 != l2)
|
||||||
|
{
|
||||||
|
chunksection.b();
|
||||||
|
chunksection = protochunk.a(l2);
|
||||||
|
chunksection.a();
|
||||||
|
}
|
||||||
|
|
||||||
|
double d8 = (double) i2 / (double) this.l;
|
||||||
|
double d9 = MathHelper.d(d8, d0, d4);
|
||||||
|
double d10 = MathHelper.d(d8, d2, d6);
|
||||||
|
double d11 = MathHelper.d(d8, d1, d5);
|
||||||
|
double d12 = MathHelper.d(d8, d3, d7);
|
||||||
|
|
||||||
|
for(int i3 = 0; i3 < this.m; ++i3)
|
||||||
|
{
|
||||||
|
int j3 = k + j1 * this.m + i3;
|
||||||
|
int k3 = j3 & 15;
|
||||||
|
double d13 = (double) i3 / (double) this.m;
|
||||||
|
double d14 = MathHelper.d(d13, d9, d10);
|
||||||
|
double d15 = MathHelper.d(d13, d11, d12);
|
||||||
|
|
||||||
|
for(int l3 = 0; l3 < this.m; ++l3)
|
||||||
|
{
|
||||||
|
int i4 = l + k1 * this.m + l3;
|
||||||
|
int j4 = i4 & 15;
|
||||||
|
double d16 = (double) l3 / (double) this.m;
|
||||||
|
double d17 = MathHelper.d(d16, d14, d15);
|
||||||
|
double d18 = MathHelper.a(d17 / 200.0D, -1.0D, 1.0D);
|
||||||
|
|
||||||
|
int k4;
|
||||||
|
int l4;
|
||||||
|
int i5;
|
||||||
|
|
||||||
|
for(d18 = d18 / 2.0D - d18 * d18 * d18 / 24.0D; objectlistiterator.hasNext(); d18 += a(k4, l4, i5) * 0.8D)
|
||||||
|
{
|
||||||
|
StructurePiece structurepiece = objectlistiterator.next();
|
||||||
|
StructureBoundingBox structureboundingbox = structurepiece.g();
|
||||||
|
|
||||||
|
k4 = Math.max(0, Math.max(structureboundingbox.a - j3, j3 - structureboundingbox.d));
|
||||||
|
l4 = j2 - (structureboundingbox.b + (structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece ? ((WorldGenFeaturePillagerOutpostPoolPiece) structurepiece).d() : 0));
|
||||||
|
i5 = Math.max(0, Math.max(structureboundingbox.c - i4, i4 - structureboundingbox.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
objectlistiterator.back(objectlist.size());
|
||||||
|
|
||||||
|
while(objectlistiterator1.hasNext())
|
||||||
|
{
|
||||||
|
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = objectlistiterator1.next();
|
||||||
|
int j5 = j3 - worldgenfeaturedefinedstructurejigsawjunction.a();
|
||||||
|
|
||||||
|
k4 = j2 - worldgenfeaturedefinedstructurejigsawjunction.b();
|
||||||
|
l4 = i4 - worldgenfeaturedefinedstructurejigsawjunction.c();
|
||||||
|
d18 += a(j5, k4, l4) * 0.4D;
|
||||||
|
}
|
||||||
|
|
||||||
|
objectlistiterator1.back(objectlist1.size());
|
||||||
|
IBlockData iblockdata = this.a(d18, j2);
|
||||||
|
|
||||||
|
if(iblockdata != NMSChunkGenerator16_2_BACKUP.k)
|
||||||
|
{
|
||||||
|
if(iblockdata.f() != 0)
|
||||||
|
{
|
||||||
|
blockposition_mutableblockposition.d(j3, j2, i4);
|
||||||
|
protochunk.k(blockposition_mutableblockposition);
|
||||||
|
}
|
||||||
|
|
||||||
|
chunksection.setType(k3, k2, j4, iblockdata, false);
|
||||||
|
heightmap.a(k3, j2, j4, iblockdata);
|
||||||
|
heightmap1.a(k3, j2, j4, iblockdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chunksection.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
double[][] adouble1 = adouble[0];
|
||||||
|
|
||||||
|
adouble[0] = adouble[1];
|
||||||
|
adouble[1] = adouble1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double a(int i, int j, int k)
|
||||||
|
{
|
||||||
|
int l = i + 12;
|
||||||
|
int i1 = j + 12;
|
||||||
|
int j1 = k + 12;
|
||||||
|
|
||||||
|
return l >= 0 && l < 24 ? (i1 >= 0 && i1 < 24 ? (j1 >= 0 && j1 < 24 ? (double) NMSChunkGenerator16_2_BACKUP.i[j1 * 24 * 24 + l * 24 + i1] : 0.0D) : 0.0D) : 0.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double b(int i, int j, int k)
|
||||||
|
{
|
||||||
|
double d0 = (double) (i * i + k * k);
|
||||||
|
double d1 = (double) j + 0.5D;
|
||||||
|
double d2 = d1 * d1;
|
||||||
|
double d3 = Math.pow(2.718281828459045D, -(d2 / 16.0D + d0 / 16.0D));
|
||||||
|
double d4 = -d1 * MathHelper.i(d2 / 2.0D + d0 / 2.0D) / 2.0D;
|
||||||
|
|
||||||
|
return d4 * d3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGenerationDepth()
|
||||||
|
{
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSeaLevel()
|
||||||
|
{
|
||||||
|
return this.h.get().g();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BiomeSettingsMobs.c> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.SWAMP_HUT).e())
|
||||||
|
{
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.CREATURE)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.j();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.PILLAGER_OUTPOST).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.PILLAGER_OUTPOST.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.MONUMENT).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.MONUMENT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.FORTRESS).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.FORTRESS.c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess)
|
||||||
|
{
|
||||||
|
int i = regionlimitedworldaccess.a();
|
||||||
|
int j = regionlimitedworldaccess.b();
|
||||||
|
BiomeBase biomebase = regionlimitedworldaccess.getBiome((new ChunkCoordIntPair(i, j)).l());
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
seededrandom.a(regionlimitedworldaccess.getSeed(), i << 4, j << 4);
|
||||||
|
SpawnerCreature.a(regionlimitedworldaccess, biomebase, i, j, seededrandom);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,730 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v16_2;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
|
import com.volmit.iris.gen.scaffold.ProvisionedHolder;
|
||||||
|
import com.volmit.iris.gen.scaffold.TerrainProvider;
|
||||||
|
import com.volmit.iris.util.O;
|
||||||
|
import com.volmit.iris.util.V;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeSettingsMobs;
|
||||||
|
import net.minecraft.server.v1_16_R2.Block;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockColumn;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Blocks;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGeneratorAbstract;
|
||||||
|
import net.minecraft.server.v1_16_R2.CrashReport;
|
||||||
|
import net.minecraft.server.v1_16_R2.CrashReportSystemDetails;
|
||||||
|
import net.minecraft.server.v1_16_R2.DefinedStructureManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.EnumCreatureType;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorAccessSeed;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorSettingBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.HeightMap;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.IChunkAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistryCustom;
|
||||||
|
import net.minecraft.server.v1_16_R2.IStructureAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseSettings;
|
||||||
|
import net.minecraft.server.v1_16_R2.PacketDebug;
|
||||||
|
import net.minecraft.server.v1_16_R2.ProtoChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.RegionLimitedWorldAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.ReportedException;
|
||||||
|
import net.minecraft.server.v1_16_R2.ResourceKey;
|
||||||
|
import net.minecraft.server.v1_16_R2.SectionPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.SeededRandom;
|
||||||
|
import net.minecraft.server.v1_16_R2.SpawnerCreature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureBoundingBox;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureFeature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureFeatures;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructurePiece;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureSettingsFeature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureStart;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructureJigsawJunction;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructurePoolTemplate;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeaturePillagerOutpostPoolPiece;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenStage;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class NMSChunkGenerator16_2_PAPER extends ChunkGenerator implements ProvisionedHolder
|
||||||
|
{
|
||||||
|
private static final IBlockData k = Blocks.AIR.getBlockData();
|
||||||
|
private final Provisioned provisioned;
|
||||||
|
private final int maxHeight;
|
||||||
|
private final int xzSize;
|
||||||
|
protected final IBlockData f;
|
||||||
|
protected final IBlockData g;
|
||||||
|
private final long w;
|
||||||
|
protected final Supplier<GeneratorSettingBase> h;
|
||||||
|
private final O<WorldServer> ws;
|
||||||
|
private BlockColumn BC;
|
||||||
|
|
||||||
|
public NMSChunkGenerator16_2_PAPER(Provisioned p, O<WorldServer> ws, WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
this(p, ws, worldchunkmanager, worldchunkmanager, i, supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NMSChunkGenerator16_2_PAPER(Provisioned p, O<WorldServer> ws, WorldChunkManager worldchunkmanager, WorldChunkManager worldchunkmanager1, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
super(worldchunkmanager, worldchunkmanager1, supplier.get().a(), i);
|
||||||
|
this.provisioned = p;
|
||||||
|
this.ws = ws;
|
||||||
|
this.w = i;
|
||||||
|
GeneratorSettingBase generatorsettingbase = supplier.get();
|
||||||
|
|
||||||
|
this.h = supplier;
|
||||||
|
NoiseSettings noisesettings = generatorsettingbase.b();
|
||||||
|
|
||||||
|
this.maxHeight = noisesettings.f() * 4;
|
||||||
|
this.f = generatorsettingbase.c();
|
||||||
|
this.g = generatorsettingbase.d();
|
||||||
|
this.xzSize = noisesettings.a() / this.maxHeight;
|
||||||
|
BC = new BlockColumn(new IBlockData[this.xzSize * this.maxHeight]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpawnHeight()
|
||||||
|
{
|
||||||
|
return getSeaLevel() + 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldChunkManager getWorldChunkManager()
|
||||||
|
{
|
||||||
|
return this.c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGenerationDepth()
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doCarving(long i, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features)
|
||||||
|
{
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).getDimension().isVanillaCaves())
|
||||||
|
{
|
||||||
|
super.doCarving(i, biomemanager, ichunkaccess, worldgenstage_features);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends ChunkGenerator> a()
|
||||||
|
{
|
||||||
|
return ChunkGeneratorAbstract.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean a(long i, ResourceKey<GeneratorSettingBase> resourcekey)
|
||||||
|
{
|
||||||
|
return this.w == i && this.h.get().a(resourcekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type)
|
||||||
|
{
|
||||||
|
return 63;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockAccess a(int x, int z)
|
||||||
|
{
|
||||||
|
return BC;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBlockData a(double d0, int i)
|
||||||
|
{
|
||||||
|
IBlockData iblockdata;
|
||||||
|
|
||||||
|
if(d0 > 0.0D)
|
||||||
|
{
|
||||||
|
iblockdata = this.f;
|
||||||
|
}
|
||||||
|
else if(i < this.getSeaLevel())
|
||||||
|
{
|
||||||
|
iblockdata = this.g;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iblockdata = NMSChunkGenerator16_2_PAPER.k;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
ObjectList<StructurePiece> objectlist = new ObjectArrayList<StructurePiece>(10);
|
||||||
|
ObjectList<WorldGenFeatureDefinedStructureJigsawJunction> objectlist1 = new ObjectArrayList<WorldGenFeatureDefinedStructureJigsawJunction>(32);
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
int i = chunkcoordintpair.x;
|
||||||
|
int j = chunkcoordintpair.z;
|
||||||
|
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
int k = i << 4;
|
||||||
|
int l = j << 4;
|
||||||
|
Iterator<?> iterator = StructureGenerator.t.iterator();
|
||||||
|
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
StructureGenerator<?> structuregenerator = (StructureGenerator<?>) iterator.next();
|
||||||
|
|
||||||
|
structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) ->
|
||||||
|
{
|
||||||
|
Iterator<?> iterator1 = structurestart.d().iterator();
|
||||||
|
|
||||||
|
while(iterator1.hasNext())
|
||||||
|
{
|
||||||
|
StructurePiece structurepiece = (StructurePiece) iterator1.next();
|
||||||
|
|
||||||
|
if(structurepiece.a(chunkcoordintpair, 12))
|
||||||
|
{
|
||||||
|
if(structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece)
|
||||||
|
{
|
||||||
|
WorldGenFeaturePillagerOutpostPoolPiece worldgenfeaturepillageroutpostpoolpiece = (WorldGenFeaturePillagerOutpostPoolPiece) structurepiece;
|
||||||
|
WorldGenFeatureDefinedStructurePoolTemplate.Matching worldgenfeaturedefinedstructurepooltemplate_matching = worldgenfeaturepillageroutpostpoolpiece.b().e();
|
||||||
|
|
||||||
|
if(worldgenfeaturedefinedstructurepooltemplate_matching == WorldGenFeatureDefinedStructurePoolTemplate.Matching.RIGID)
|
||||||
|
{
|
||||||
|
objectlist.add(worldgenfeaturepillageroutpostpoolpiece);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<?> iterator2 = worldgenfeaturepillageroutpostpoolpiece.e().iterator();
|
||||||
|
|
||||||
|
while(iterator2.hasNext())
|
||||||
|
{
|
||||||
|
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = (WorldGenFeatureDefinedStructureJigsawJunction) iterator2.next();
|
||||||
|
int i1 = worldgenfeaturedefinedstructurejigsawjunction.a();
|
||||||
|
int j1 = worldgenfeaturedefinedstructurejigsawjunction.c();
|
||||||
|
|
||||||
|
if(i1 > k - 12 && j1 > l - 12 && i1 < k + 15 + 12 && j1 < l + 15 + 12)
|
||||||
|
{
|
||||||
|
objectlist1.add(worldgenfeaturedefinedstructurejigsawjunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objectlist.add(structurepiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
|
||||||
|
HeightMap heightmap = protochunk.a(HeightMap.Type.OCEAN_FLOOR_WG);
|
||||||
|
HeightMap heightmap1 = protochunk.a(HeightMap.Type.WORLD_SURFACE_WG);
|
||||||
|
GeneratedChunk gc = ((ProvisionBukkit) provisioned).generateNMSChunkData(ws.get().getWorld(), new Random(i + j), i, j, new ChunkData()
|
||||||
|
{
|
||||||
|
public int getMaxHeight()
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, Material material)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, material.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, MaterialData material)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, CraftMagicNumbers.getBlock((MaterialData) material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, BlockData blockData)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, ((CraftBlockData) blockData).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock((MaterialData) material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getType(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.getMaterial((Block) this.getTypeId(x, y, z).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialData getTypeAndData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.getMaterial((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftBlockData.fromData((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type)
|
||||||
|
{
|
||||||
|
if(xMin > 15 || yMin >= getMaxHeight() || zMin > 15)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(xMin < 0)
|
||||||
|
{
|
||||||
|
xMin = 0;
|
||||||
|
}
|
||||||
|
if(yMin < 0)
|
||||||
|
{
|
||||||
|
yMin = 0;
|
||||||
|
}
|
||||||
|
if(zMin < 0)
|
||||||
|
{
|
||||||
|
zMin = 0;
|
||||||
|
}
|
||||||
|
if(xMax > 16)
|
||||||
|
{
|
||||||
|
xMax = 16;
|
||||||
|
}
|
||||||
|
if(yMax > getMaxHeight())
|
||||||
|
{
|
||||||
|
yMax = getMaxHeight();
|
||||||
|
}
|
||||||
|
if(zMax > 16)
|
||||||
|
{
|
||||||
|
zMax = 16;
|
||||||
|
}
|
||||||
|
if(xMin >= xMax || yMin >= yMax || zMin >= zMax)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int y = yMin;
|
||||||
|
while(y < yMax)
|
||||||
|
{
|
||||||
|
int x = xMin;
|
||||||
|
while(x < xMax)
|
||||||
|
{
|
||||||
|
int z = zMin;
|
||||||
|
while(z < zMax)
|
||||||
|
{
|
||||||
|
protochunk.setType(new BlockPosition(x, y, z), type, false);
|
||||||
|
++z;
|
||||||
|
}
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
++y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockData getTypeId(int x, int y, int z)
|
||||||
|
{
|
||||||
|
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
|
||||||
|
{
|
||||||
|
return Blocks.AIR.getBlockData();
|
||||||
|
}
|
||||||
|
return protochunk.getType(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.toLegacyData((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBlock(int x, int y, int z, IBlockData type)
|
||||||
|
{
|
||||||
|
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protochunk.setType(new BlockPosition(x, y, z), type, false);
|
||||||
|
|
||||||
|
if(type.getBlock().isTileEntity())
|
||||||
|
{
|
||||||
|
// if (this.tiles == null) {
|
||||||
|
// this.tiles = new HashSet<BlockPosition>();
|
||||||
|
// }
|
||||||
|
// this.tiles.add(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new BiomeGrid()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int y, int z, Biome bio)
|
||||||
|
{
|
||||||
|
protochunk.getBiomeIndex().setBiome(x, y, z, CraftBlock.biomeToBiomeBase(ws.get().r().b(IRegistry.ay), bio));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int z, Biome bio)
|
||||||
|
{
|
||||||
|
protochunk.getBiomeIndex().setBiome(x, 0, z, CraftBlock.biomeToBiomeBase(ws.get().r().b(IRegistry.ay), bio));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int z)
|
||||||
|
{
|
||||||
|
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, 0, z));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for(int xx = 0; xx < 16; xx++)
|
||||||
|
{
|
||||||
|
for(int zz = 0; zz < 16; zz++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int y = gc.getHeight().getHeight(xx, zz);
|
||||||
|
if(y < getSeaLevel())
|
||||||
|
{
|
||||||
|
heightmap.a(xx, y, zz, Blocks.STONE.getBlockData());
|
||||||
|
}
|
||||||
|
heightmap1.a(xx, Math.max(y, getSeaLevel()), zz, Blocks.STONE.getBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager)
|
||||||
|
{
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
int i = regionlimitedworldaccess.a();
|
||||||
|
int j = regionlimitedworldaccess.b();
|
||||||
|
int k = i * 16;
|
||||||
|
int l = j * 16;
|
||||||
|
BlockPosition blockposition = new BlockPosition(k, 0, l);
|
||||||
|
BiomeBase biomebase = this.b.getBiome((i << 2) + 2, 2, (j << 2) + 2);
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
long i1 = seededrandom.a(regionlimitedworldaccess.getSeed(), k, l);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
a(biomebase, structuremanager, this, regionlimitedworldaccess, i1, seededrandom, blockposition);
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(BiomeBase bbase, StructureManager var0, ChunkGenerator var1, RegionLimitedWorldAccess var2, long var3, SeededRandom var5, BlockPosition var6)
|
||||||
|
{
|
||||||
|
if(!((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stages = WorldGenStage.Decoration.values().length;
|
||||||
|
for(int stage = 0; stage < stages; ++stage)
|
||||||
|
{
|
||||||
|
WorldGenStage.Decoration st = WorldGenStage.Decoration.values()[stage];
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.LAKES))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.LOCAL_MODIFICATIONS))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.RAW_GENERATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.TOP_LAYER_MODIFICATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_DECORATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_ORES))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.VEGETAL_DECORATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StructureGenerator<?> var13;
|
||||||
|
int var10 = 0;
|
||||||
|
if(var0.a())
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<StructureGenerator<?>> structureGenerators = ((Map<Integer, List<StructureGenerator<?>>>) new V(bbase).get("g")).getOrDefault(stage, Collections.emptyList());
|
||||||
|
Iterator<StructureGenerator<?>> iterator = structureGenerators.iterator();
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
var13 = (StructureGenerator<?>) iterator.next();
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.VILLAGE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.JUNGLE_PYRAMID))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.IGLOO))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.NETHER_FOSSIL))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.SHIPWRECK))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.SHIPWRECK))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.MONUMENT))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.BASTION_REMNANT))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var5.b(var3, var10, stage);
|
||||||
|
int var14 = var6.getX() >> 4;
|
||||||
|
int var15 = var6.getZ() >> 4;
|
||||||
|
int var16 = var14 << 4;
|
||||||
|
int var17 = var15 << 4;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var0.a(SectionPosition.a((BlockPosition) var6), var13).forEach(var8 -> var8.a((GeneratorAccessSeed) var2, var0, var1, (Random) var5, new StructureBoundingBox(var16, var17, var16 + 15, var17 + 15), new ChunkCoordIntPair(var14, var15)));
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Exception var18)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
++var10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSeaLevel()
|
||||||
|
{
|
||||||
|
return ((IrisTerrainProvider) provisioned.getProvider()).getFluidHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BiomeSettingsMobs.c> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.SWAMP_HUT).e())
|
||||||
|
{
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.CREATURE)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.j();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.PILLAGER_OUTPOST).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.PILLAGER_OUTPOST.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.MONUMENT).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.MONUMENT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.FORTRESS).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.FORTRESS.c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess)
|
||||||
|
{
|
||||||
|
int i = regionlimitedworldaccess.a();
|
||||||
|
int j = regionlimitedworldaccess.b();
|
||||||
|
BiomeBase biomebase = regionlimitedworldaccess.getBiome((new ChunkCoordIntPair(i, j)).l());
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
seededrandom.a(regionlimitedworldaccess.getSeed(), i << 4, j << 4);
|
||||||
|
SpawnerCreature.a(regionlimitedworldaccess, biomebase, i, j, seededrandom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i)
|
||||||
|
{
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
BiomeBase biomebase = this.b.getBiome((chunkcoordintpair.x << 2) + 2, 0, (chunkcoordintpair.z << 2) + 2);
|
||||||
|
this.a(StructureFeatures.k, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
for(Supplier<StructureFeature<?, ?>> supplier : biomebase.e().a())
|
||||||
|
{
|
||||||
|
StructureFeature<?, ?> structurefeature = (StructureFeature<?, ?>) supplier.get();
|
||||||
|
if(StructureFeature.c == StructureGenerator.STRONGHOLD)
|
||||||
|
{
|
||||||
|
StructureFeature<?, ?> structureFeature = structurefeature;
|
||||||
|
synchronized(structureFeature)
|
||||||
|
{
|
||||||
|
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void a(StructureFeature<?, ?> structurefeature, IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i, ChunkCoordIntPair chunkcoordintpair, BiomeBase biomebase)
|
||||||
|
{
|
||||||
|
StructureStart<?> structurestart = structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, (IStructureAccess) ichunkaccess);
|
||||||
|
int j = structurestart != null ? structurestart.j() : 0;
|
||||||
|
StructureSettingsFeature structuresettingsfeature = getSettings().a(structurefeature.d);
|
||||||
|
if(structuresettingsfeature != null)
|
||||||
|
{
|
||||||
|
StructureStart<?> structurestart1 = structurefeature.a(iregistrycustom, this, this.b, definedstructuremanager, i, chunkcoordintpair, biomebase, j, structuresettingsfeature);
|
||||||
|
structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, structurestart1, (IStructureAccess) ichunkaccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
int i = ichunkaccess.getPos().x;
|
||||||
|
int j = ichunkaccess.getPos().z;
|
||||||
|
int k = i << 4;
|
||||||
|
int l = j << 4;
|
||||||
|
SectionPosition sectionposition = SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0);
|
||||||
|
int i1 = i - 8;
|
||||||
|
while(i1 <= i + 8)
|
||||||
|
{
|
||||||
|
int j1 = j - 8;
|
||||||
|
while(j1 <= j + 8)
|
||||||
|
{
|
||||||
|
long k1 = ChunkCoordIntPair.pair((int) i1, (int) j1);
|
||||||
|
for(StructureStart<?> structurestart : generatoraccessseed.getChunkAt(i1, j1).h().values())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(structurestart == StructureStart.a || !structurestart.c().a(k, l, k + 15, l + 15))
|
||||||
|
continue;
|
||||||
|
structuremanager.a(sectionposition, structurestart.l(), k1, (IStructureAccess) ichunkaccess);
|
||||||
|
PacketDebug.a((GeneratorAccessSeed) generatoraccessseed, (StructureStart<?>) structurestart);
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
CrashReport crashreport = CrashReport.a((Throwable) exception, (String) "Generating structure reference");
|
||||||
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Structure");
|
||||||
|
crashreportsystemdetails.a("Name", () -> structurestart.l().i());
|
||||||
|
crashreportsystemdetails.a("Class", () -> structurestart.l().getClass().getCanonicalName());
|
||||||
|
throw new ReportedException(crashreport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++j1;
|
||||||
|
}
|
||||||
|
++i1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Provisioned getProvisioned()
|
||||||
|
{
|
||||||
|
return provisioned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearRegeneratedLists()
|
||||||
|
{
|
||||||
|
getProvisioned().clearRegeneratedLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TerrainProvider getProvider()
|
||||||
|
{
|
||||||
|
return getProvisioned().getProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regenerate(int x, int z)
|
||||||
|
{
|
||||||
|
getProvisioned().regenerate(x, z);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,722 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v16_2;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
|
import com.volmit.iris.gen.scaffold.ProvisionedHolder;
|
||||||
|
import com.volmit.iris.gen.scaffold.TerrainProvider;
|
||||||
|
import com.volmit.iris.util.O;
|
||||||
|
import com.volmit.iris.util.V;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.BiomeSettingsMobs;
|
||||||
|
import net.minecraft.server.v1_16_R2.Block;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockColumn;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Blocks;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.ChunkGeneratorAbstract;
|
||||||
|
import net.minecraft.server.v1_16_R2.CrashReport;
|
||||||
|
import net.minecraft.server.v1_16_R2.CrashReportSystemDetails;
|
||||||
|
import net.minecraft.server.v1_16_R2.DefinedStructureManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.EnumCreatureType;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorAccessSeed;
|
||||||
|
import net.minecraft.server.v1_16_R2.GeneratorSettingBase;
|
||||||
|
import net.minecraft.server.v1_16_R2.HeightMap;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.IChunkAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistryCustom;
|
||||||
|
import net.minecraft.server.v1_16_R2.IStructureAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.NoiseSettings;
|
||||||
|
import net.minecraft.server.v1_16_R2.PacketDebug;
|
||||||
|
import net.minecraft.server.v1_16_R2.ProtoChunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.RegionLimitedWorldAccess;
|
||||||
|
import net.minecraft.server.v1_16_R2.ReportedException;
|
||||||
|
import net.minecraft.server.v1_16_R2.ResourceKey;
|
||||||
|
import net.minecraft.server.v1_16_R2.SectionPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.SeededRandom;
|
||||||
|
import net.minecraft.server.v1_16_R2.SpawnerCreature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureBoundingBox;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureFeature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureFeatures;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureGenerator;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructurePiece;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureSettingsFeature;
|
||||||
|
import net.minecraft.server.v1_16_R2.StructureStart;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructureJigsawJunction;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeatureDefinedStructurePoolTemplate;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenFeaturePillagerOutpostPoolPiece;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldGenStage;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class NMSChunkGenerator16_2_SPIGOT extends ChunkGenerator implements ProvisionedHolder
|
||||||
|
{
|
||||||
|
private static final IBlockData k = Blocks.AIR.getBlockData();
|
||||||
|
private final Provisioned provisioned;
|
||||||
|
private final int maxHeight;
|
||||||
|
private final int xzSize;
|
||||||
|
protected final IBlockData f;
|
||||||
|
protected final IBlockData g;
|
||||||
|
private final long w;
|
||||||
|
protected final Supplier<GeneratorSettingBase> h;
|
||||||
|
private final O<WorldServer> ws;
|
||||||
|
private BlockColumn BC;
|
||||||
|
|
||||||
|
public NMSChunkGenerator16_2_SPIGOT(Provisioned p, O<WorldServer> ws, WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
this(p, ws, worldchunkmanager, worldchunkmanager, i, supplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NMSChunkGenerator16_2_SPIGOT(Provisioned p, O<WorldServer> ws, WorldChunkManager worldchunkmanager, WorldChunkManager worldchunkmanager1, long i, Supplier<GeneratorSettingBase> supplier)
|
||||||
|
{
|
||||||
|
super(worldchunkmanager, worldchunkmanager1, supplier.get().a(), i);
|
||||||
|
this.provisioned = p;
|
||||||
|
this.ws = ws;
|
||||||
|
this.w = i;
|
||||||
|
GeneratorSettingBase generatorsettingbase = supplier.get();
|
||||||
|
|
||||||
|
this.h = supplier;
|
||||||
|
NoiseSettings noisesettings = generatorsettingbase.b();
|
||||||
|
|
||||||
|
this.maxHeight = noisesettings.f() * 4;
|
||||||
|
this.f = generatorsettingbase.c();
|
||||||
|
this.g = generatorsettingbase.d();
|
||||||
|
this.xzSize = noisesettings.a() / this.maxHeight;
|
||||||
|
BC = new BlockColumn(new IBlockData[this.xzSize * this.maxHeight]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpawnHeight()
|
||||||
|
{
|
||||||
|
return getSeaLevel() + 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldChunkManager getWorldChunkManager()
|
||||||
|
{
|
||||||
|
return this.c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGenerationDepth()
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doCarving(long i, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features)
|
||||||
|
{
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).getDimension().isVanillaCaves())
|
||||||
|
{
|
||||||
|
super.doCarving(i, biomemanager, ichunkaccess, worldgenstage_features);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends ChunkGenerator> a()
|
||||||
|
{
|
||||||
|
return ChunkGeneratorAbstract.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean a(long i, ResourceKey<GeneratorSettingBase> resourcekey)
|
||||||
|
{
|
||||||
|
return this.w == i && this.h.get().a(resourcekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type)
|
||||||
|
{
|
||||||
|
return 63;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockAccess a(int x, int z)
|
||||||
|
{
|
||||||
|
return BC;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBlockData a(double d0, int i)
|
||||||
|
{
|
||||||
|
IBlockData iblockdata;
|
||||||
|
|
||||||
|
if(d0 > 0.0D)
|
||||||
|
{
|
||||||
|
iblockdata = this.f;
|
||||||
|
}
|
||||||
|
else if(i < this.getSeaLevel())
|
||||||
|
{
|
||||||
|
iblockdata = this.g;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iblockdata = NMSChunkGenerator16_2_SPIGOT.k;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iblockdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
ObjectList<StructurePiece> objectlist = new ObjectArrayList<StructurePiece>(10);
|
||||||
|
ObjectList<WorldGenFeatureDefinedStructureJigsawJunction> objectlist1 = new ObjectArrayList<WorldGenFeatureDefinedStructureJigsawJunction>(32);
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
int i = chunkcoordintpair.x;
|
||||||
|
int j = chunkcoordintpair.z;
|
||||||
|
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
int k = i << 4;
|
||||||
|
int l = j << 4;
|
||||||
|
Iterator<?> iterator = StructureGenerator.t.iterator();
|
||||||
|
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
StructureGenerator<?> structuregenerator = (StructureGenerator<?>) iterator.next();
|
||||||
|
|
||||||
|
structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) ->
|
||||||
|
{
|
||||||
|
Iterator<?> iterator1 = structurestart.d().iterator();
|
||||||
|
|
||||||
|
while(iterator1.hasNext())
|
||||||
|
{
|
||||||
|
StructurePiece structurepiece = (StructurePiece) iterator1.next();
|
||||||
|
|
||||||
|
if(structurepiece.a(chunkcoordintpair, 12))
|
||||||
|
{
|
||||||
|
if(structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece)
|
||||||
|
{
|
||||||
|
WorldGenFeaturePillagerOutpostPoolPiece worldgenfeaturepillageroutpostpoolpiece = (WorldGenFeaturePillagerOutpostPoolPiece) structurepiece;
|
||||||
|
WorldGenFeatureDefinedStructurePoolTemplate.Matching worldgenfeaturedefinedstructurepooltemplate_matching = worldgenfeaturepillageroutpostpoolpiece.b().e();
|
||||||
|
|
||||||
|
if(worldgenfeaturedefinedstructurepooltemplate_matching == WorldGenFeatureDefinedStructurePoolTemplate.Matching.RIGID)
|
||||||
|
{
|
||||||
|
objectlist.add(worldgenfeaturepillageroutpostpoolpiece);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<?> iterator2 = worldgenfeaturepillageroutpostpoolpiece.e().iterator();
|
||||||
|
|
||||||
|
while(iterator2.hasNext())
|
||||||
|
{
|
||||||
|
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = (WorldGenFeatureDefinedStructureJigsawJunction) iterator2.next();
|
||||||
|
int i1 = worldgenfeaturedefinedstructurejigsawjunction.a();
|
||||||
|
int j1 = worldgenfeaturedefinedstructurejigsawjunction.c();
|
||||||
|
|
||||||
|
if(i1 > k - 12 && j1 > l - 12 && i1 < k + 15 + 12 && j1 < l + 15 + 12)
|
||||||
|
{
|
||||||
|
objectlist1.add(worldgenfeaturedefinedstructurejigsawjunction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objectlist.add(structurepiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
|
||||||
|
HeightMap heightmap = protochunk.a(HeightMap.Type.OCEAN_FLOOR_WG);
|
||||||
|
HeightMap heightmap1 = protochunk.a(HeightMap.Type.WORLD_SURFACE_WG);
|
||||||
|
GeneratedChunk gc = ((ProvisionBukkit) provisioned).generateNMSChunkData(ws.get().getWorld(), new Random(i + j), i, j, new ChunkData()
|
||||||
|
{
|
||||||
|
public int getMaxHeight()
|
||||||
|
{
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, Material material)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, material.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, MaterialData material)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, CraftMagicNumbers.getBlock((MaterialData) material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, int z, BlockData blockData)
|
||||||
|
{
|
||||||
|
this.setBlock(x, y, z, ((CraftBlockData) blockData).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock((MaterialData) material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
|
||||||
|
{
|
||||||
|
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getType(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.getMaterial((Block) this.getTypeId(x, y, z).getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialData getTypeAndData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.getMaterial((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftBlockData.fromData((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type)
|
||||||
|
{
|
||||||
|
if(xMin > 15 || yMin >= getMaxHeight() || zMin > 15)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(xMin < 0)
|
||||||
|
{
|
||||||
|
xMin = 0;
|
||||||
|
}
|
||||||
|
if(yMin < 0)
|
||||||
|
{
|
||||||
|
yMin = 0;
|
||||||
|
}
|
||||||
|
if(zMin < 0)
|
||||||
|
{
|
||||||
|
zMin = 0;
|
||||||
|
}
|
||||||
|
if(xMax > 16)
|
||||||
|
{
|
||||||
|
xMax = 16;
|
||||||
|
}
|
||||||
|
if(yMax > getMaxHeight())
|
||||||
|
{
|
||||||
|
yMax = getMaxHeight();
|
||||||
|
}
|
||||||
|
if(zMax > 16)
|
||||||
|
{
|
||||||
|
zMax = 16;
|
||||||
|
}
|
||||||
|
if(xMin >= xMax || yMin >= yMax || zMin >= zMax)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int y = yMin;
|
||||||
|
while(y < yMax)
|
||||||
|
{
|
||||||
|
int x = xMin;
|
||||||
|
while(x < xMax)
|
||||||
|
{
|
||||||
|
int z = zMin;
|
||||||
|
while(z < zMax)
|
||||||
|
{
|
||||||
|
protochunk.setType(new BlockPosition(x, y, z), type, false);
|
||||||
|
++z;
|
||||||
|
}
|
||||||
|
++x;
|
||||||
|
}
|
||||||
|
++y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBlockData getTypeId(int x, int y, int z)
|
||||||
|
{
|
||||||
|
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
|
||||||
|
{
|
||||||
|
return Blocks.AIR.getBlockData();
|
||||||
|
}
|
||||||
|
return protochunk.getType(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftMagicNumbers.toLegacyData((IBlockData) this.getTypeId(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBlock(int x, int y, int z, IBlockData type)
|
||||||
|
{
|
||||||
|
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protochunk.setType(new BlockPosition(x, y, z), type, false);
|
||||||
|
|
||||||
|
if(type.getBlock().isTileEntity())
|
||||||
|
{
|
||||||
|
// if (this.tiles == null) {
|
||||||
|
// this.tiles = new HashSet<BlockPosition>();
|
||||||
|
// }
|
||||||
|
// this.tiles.add(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new BiomeGrid()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int y, int z, Biome bio)
|
||||||
|
{
|
||||||
|
protochunk.getBiomeIndex().setBiome(x, y, z, CraftBlock.biomeToBiomeBase(ws.get().r().b(IRegistry.ay), bio));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int z, Biome bio)
|
||||||
|
{
|
||||||
|
protochunk.getBiomeIndex().setBiome(x, 0, z, CraftBlock.biomeToBiomeBase(ws.get().r().b(IRegistry.ay), bio));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int z)
|
||||||
|
{
|
||||||
|
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, 0, z));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for(int xx = 0; xx < 16; xx++)
|
||||||
|
{
|
||||||
|
for(int zz = 0; zz < 16; zz++)
|
||||||
|
{
|
||||||
|
int y = gc.getHeight().getHeight(xx, zz);
|
||||||
|
if(y < getSeaLevel())
|
||||||
|
{
|
||||||
|
heightmap.a(xx, y, zz, Blocks.STONE.getBlockData());
|
||||||
|
}
|
||||||
|
heightmap1.a(xx, Math.max(y, getSeaLevel()), zz, Blocks.STONE.getBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager)
|
||||||
|
{
|
||||||
|
if(((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
int i = regionlimitedworldaccess.a();
|
||||||
|
int j = regionlimitedworldaccess.b();
|
||||||
|
int k = i * 16;
|
||||||
|
int l = j * 16;
|
||||||
|
BlockPosition blockposition = new BlockPosition(k, 0, l);
|
||||||
|
BiomeBase biomebase = this.b.getBiome((i << 2) + 2, 2, (j << 2) + 2);
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
long i1 = seededrandom.a(regionlimitedworldaccess.getSeed(), k, l);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
a(biomebase, structuremanager, this, regionlimitedworldaccess, i1, seededrandom, blockposition);
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(BiomeBase bbase, StructureManager var0, ChunkGenerator var1, RegionLimitedWorldAccess var2, long var3, SeededRandom var5, BlockPosition var6)
|
||||||
|
{
|
||||||
|
if(!((IrisTerrainProvider) provisioned.getProvider()).shouldGenerateVanillaStructures())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stages = WorldGenStage.Decoration.values().length;
|
||||||
|
for(int stage = 0; stage < stages; ++stage)
|
||||||
|
{
|
||||||
|
WorldGenStage.Decoration st = WorldGenStage.Decoration.values()[stage];
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.LAKES))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.LOCAL_MODIFICATIONS))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.RAW_GENERATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.TOP_LAYER_MODIFICATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_DECORATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_ORES))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(st.equals(WorldGenStage.Decoration.VEGETAL_DECORATION))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StructureGenerator<?> var13;
|
||||||
|
int var10 = 0;
|
||||||
|
if(var0.a())
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<StructureGenerator<?>> structureGenerators = ((Map<Integer, List<StructureGenerator<?>>>) new V(bbase).get("g")).getOrDefault(stage, Collections.emptyList());
|
||||||
|
Iterator<StructureGenerator<?>> iterator = structureGenerators.iterator();
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
var13 = (StructureGenerator<?>) iterator.next();
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.VILLAGE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.JUNGLE_PYRAMID))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.IGLOO))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.NETHER_FOSSIL))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.SHIPWRECK))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.SHIPWRECK))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.MONUMENT))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var13.equals(StructureGenerator.BASTION_REMNANT))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var5.b(var3, var10, stage);
|
||||||
|
int var14 = var6.getX() >> 4;
|
||||||
|
int var15 = var6.getZ() >> 4;
|
||||||
|
int var16 = var14 << 4;
|
||||||
|
int var17 = var15 << 4;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var0.a(SectionPosition.a((BlockPosition) var6), var13).forEach(var8 -> var8.a((GeneratorAccessSeed) var2, var0, var1, (Random) var5, new StructureBoundingBox(var16, var17, var16 + 15, var17 + 15), new ChunkCoordIntPair(var14, var15)));
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Exception var18)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
++var10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSeaLevel()
|
||||||
|
{
|
||||||
|
return ((IrisTerrainProvider) provisioned.getProvider()).getFluidHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BiomeSettingsMobs.c> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.SWAMP_HUT).e())
|
||||||
|
{
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.CREATURE)
|
||||||
|
{
|
||||||
|
return StructureGenerator.SWAMP_HUT.j();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(enumcreaturetype == EnumCreatureType.MONSTER)
|
||||||
|
{
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.PILLAGER_OUTPOST).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.PILLAGER_OUTPOST.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, false, StructureGenerator.MONUMENT).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.MONUMENT.c();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(structuremanager.a(blockposition, true, StructureGenerator.FORTRESS).e())
|
||||||
|
{
|
||||||
|
return StructureGenerator.FORTRESS.c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess)
|
||||||
|
{
|
||||||
|
int i = regionlimitedworldaccess.a();
|
||||||
|
int j = regionlimitedworldaccess.b();
|
||||||
|
BiomeBase biomebase = regionlimitedworldaccess.getBiome((new ChunkCoordIntPair(i, j)).l());
|
||||||
|
SeededRandom seededrandom = new SeededRandom();
|
||||||
|
seededrandom.a(regionlimitedworldaccess.getSeed(), i << 4, j << 4);
|
||||||
|
SpawnerCreature.a(regionlimitedworldaccess, biomebase, i, j, seededrandom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i)
|
||||||
|
{
|
||||||
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
BiomeBase biomebase = this.b.getBiome((chunkcoordintpair.x << 2) + 2, 0, (chunkcoordintpair.z << 2) + 2);
|
||||||
|
this.a(StructureFeatures.k, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
for(Supplier<StructureFeature<?, ?>> supplier : biomebase.e().a())
|
||||||
|
{
|
||||||
|
StructureFeature<?, ?> structurefeature = (StructureFeature<?, ?>) supplier.get();
|
||||||
|
if(StructureFeature.c == StructureGenerator.STRONGHOLD)
|
||||||
|
{
|
||||||
|
StructureFeature<?, ?> structureFeature = structurefeature;
|
||||||
|
synchronized(structureFeature)
|
||||||
|
{
|
||||||
|
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void a(StructureFeature<?, ?> structurefeature, IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i, ChunkCoordIntPair chunkcoordintpair, BiomeBase biomebase)
|
||||||
|
{
|
||||||
|
StructureStart<?> structurestart = structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, (IStructureAccess) ichunkaccess);
|
||||||
|
int j = structurestart != null ? structurestart.j() : 0;
|
||||||
|
StructureSettingsFeature structuresettingsfeature = getSettings().a(structurefeature.d);
|
||||||
|
if(structuresettingsfeature != null)
|
||||||
|
{
|
||||||
|
StructureStart<?> structurestart1 = structurefeature.a(iregistrycustom, this, this.b, definedstructuremanager, i, chunkcoordintpair, biomebase, j, structuresettingsfeature);
|
||||||
|
structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, structurestart1, (IStructureAccess) ichunkaccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess)
|
||||||
|
{
|
||||||
|
int i = ichunkaccess.getPos().x;
|
||||||
|
int j = ichunkaccess.getPos().z;
|
||||||
|
int k = i << 4;
|
||||||
|
int l = j << 4;
|
||||||
|
SectionPosition sectionposition = SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0);
|
||||||
|
int i1 = i - 8;
|
||||||
|
while(i1 <= i + 8)
|
||||||
|
{
|
||||||
|
int j1 = j - 8;
|
||||||
|
while(j1 <= j + 8)
|
||||||
|
{
|
||||||
|
long k1 = ChunkCoordIntPair.pair((int) i1, (int) j1);
|
||||||
|
for(StructureStart<?> structurestart : generatoraccessseed.getChunkAt(i1, j1).h().values())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(structurestart == StructureStart.a || !structurestart.c().a(k, l, k + 15, l + 15))
|
||||||
|
continue;
|
||||||
|
structuremanager.a(sectionposition, structurestart.l(), k1, (IStructureAccess) ichunkaccess);
|
||||||
|
PacketDebug.a((GeneratorAccessSeed) generatoraccessseed, (StructureStart<?>) structurestart);
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
|
{
|
||||||
|
CrashReport crashreport = CrashReport.a((Throwable) exception, (String) "Generating structure reference");
|
||||||
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Structure");
|
||||||
|
crashreportsystemdetails.a("Name", () -> structurestart.l().i());
|
||||||
|
crashreportsystemdetails.a("Class", () -> structurestart.l().getClass().getCanonicalName());
|
||||||
|
throw new ReportedException(crashreport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++j1;
|
||||||
|
}
|
||||||
|
++i1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Provisioned getProvisioned()
|
||||||
|
{
|
||||||
|
return provisioned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearRegeneratedLists()
|
||||||
|
{
|
||||||
|
getProvisioned().clearRegeneratedLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TerrainProvider getProvider()
|
||||||
|
{
|
||||||
|
return getProvisioned().getProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regenerate(int x, int z)
|
||||||
|
{
|
||||||
|
getProvisioned().regenerate(x, z);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.volmit.iris.gen.nms;
|
package com.volmit.iris.gen.nms.v16_2;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -7,7 +7,6 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,8 +22,13 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.mojang.serialization.DynamicOps;
|
import com.mojang.serialization.DynamicOps;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
|
import com.volmit.iris.gen.nms.INMSCreator;
|
||||||
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
|
import com.volmit.iris.util.O;
|
||||||
import com.volmit.iris.util.V;
|
import com.volmit.iris.util.V;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.server.v1_16_R2.BiomeBase;
|
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||||
import net.minecraft.server.v1_16_R2.BiomeManager;
|
import net.minecraft.server.v1_16_R2.BiomeManager;
|
||||||
import net.minecraft.server.v1_16_R2.Convertable;
|
import net.minecraft.server.v1_16_R2.Convertable;
|
||||||
@ -38,6 +42,7 @@ import net.minecraft.server.v1_16_R2.GameRules;
|
|||||||
import net.minecraft.server.v1_16_R2.GeneratorSettingBase;
|
import net.minecraft.server.v1_16_R2.GeneratorSettingBase;
|
||||||
import net.minecraft.server.v1_16_R2.GeneratorSettings;
|
import net.minecraft.server.v1_16_R2.GeneratorSettings;
|
||||||
import net.minecraft.server.v1_16_R2.IRegistry;
|
import net.minecraft.server.v1_16_R2.IRegistry;
|
||||||
|
import net.minecraft.server.v1_16_R2.IRegistryCustom.Dimension;
|
||||||
import net.minecraft.server.v1_16_R2.IWorldDataServer;
|
import net.minecraft.server.v1_16_R2.IWorldDataServer;
|
||||||
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
import net.minecraft.server.v1_16_R2.MinecraftKey;
|
||||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||||
@ -47,21 +52,23 @@ import net.minecraft.server.v1_16_R2.MobSpawnerPatrol;
|
|||||||
import net.minecraft.server.v1_16_R2.MobSpawnerPhantom;
|
import net.minecraft.server.v1_16_R2.MobSpawnerPhantom;
|
||||||
import net.minecraft.server.v1_16_R2.MobSpawnerTrader;
|
import net.minecraft.server.v1_16_R2.MobSpawnerTrader;
|
||||||
import net.minecraft.server.v1_16_R2.NBTBase;
|
import net.minecraft.server.v1_16_R2.NBTBase;
|
||||||
import net.minecraft.server.v1_16_R2.RegistryMaterials;
|
|
||||||
import net.minecraft.server.v1_16_R2.RegistryReadOps;
|
import net.minecraft.server.v1_16_R2.RegistryReadOps;
|
||||||
import net.minecraft.server.v1_16_R2.ResourceKey;
|
import net.minecraft.server.v1_16_R2.ResourceKey;
|
||||||
import net.minecraft.server.v1_16_R2.SaveData;
|
import net.minecraft.server.v1_16_R2.SaveData;
|
||||||
import net.minecraft.server.v1_16_R2.VillageSiege;
|
import net.minecraft.server.v1_16_R2.VillageSiege;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManager;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldChunkManagerOverworld;
|
||||||
import net.minecraft.server.v1_16_R2.WorldDataServer;
|
import net.minecraft.server.v1_16_R2.WorldDataServer;
|
||||||
import net.minecraft.server.v1_16_R2.WorldDimension;
|
import net.minecraft.server.v1_16_R2.WorldDimension;
|
||||||
import net.minecraft.server.v1_16_R2.WorldServer;
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
import net.minecraft.server.v1_16_R2.WorldSettings;
|
import net.minecraft.server.v1_16_R2.WorldSettings;
|
||||||
|
|
||||||
public class NMSCreator162
|
class NMSCreator16_2 implements INMSCreator
|
||||||
{
|
{
|
||||||
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
|
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
|
||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
public World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||||
{
|
{
|
||||||
|
Provisioned pro = (Provisioned) creator.generator();
|
||||||
CraftServer server = ((CraftServer) Bukkit.getServer());
|
CraftServer server = ((CraftServer) Bukkit.getServer());
|
||||||
Map<String, World> worlds = new V(server).get("worlds");
|
Map<String, World> worlds = new V(server).get("worlds");
|
||||||
DedicatedServer console = new V(server).get("console");
|
DedicatedServer console = new V(server).get("console");
|
||||||
@ -121,7 +128,7 @@ public class NMSCreator162
|
|||||||
}
|
}
|
||||||
MinecraftServer.convertWorld(worldSession);
|
MinecraftServer.convertWorld(worldSession);
|
||||||
final boolean hardcore = creator.hardcore();
|
final boolean hardcore = creator.hardcore();
|
||||||
final RegistryReadOps<NBTBase> registryreadops = (RegistryReadOps<NBTBase>) RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), console.f);
|
final RegistryReadOps<NBTBase> registryreadops = (RegistryReadOps<NBTBase>) RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), getConsoleDimension(console));
|
||||||
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
|
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
|
||||||
if(worlddata == null)
|
if(worlddata == null)
|
||||||
{
|
{
|
||||||
@ -130,7 +137,7 @@ public class NMSCreator162
|
|||||||
properties.put("level-seed", Objects.toString(creator.seed()));
|
properties.put("level-seed", Objects.toString(creator.seed()));
|
||||||
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
|
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
|
||||||
properties.put("level-type", Objects.toString(creator.type().getName()));
|
properties.put("level-type", Objects.toString(creator.type().getName()));
|
||||||
final GeneratorSettings generatorsettings = GeneratorSettings.a(console.aX(), properties);
|
final GeneratorSettings generatorsettings = GeneratorSettings.a(getConsoleDimension(console), properties);
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final WorldSettings worldSettings = new WorldSettings(name, EnumGamemode.getById(server.getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
|
final WorldSettings worldSettings = new WorldSettings(name, EnumGamemode.getById(server.getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
|
||||||
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
|
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
|
||||||
@ -143,22 +150,12 @@ public class NMSCreator162
|
|||||||
}
|
}
|
||||||
final long j = BiomeManager.a(creator.seed());
|
final long j = BiomeManager.a(creator.seed());
|
||||||
final List<MobSpawner> list = (List<MobSpawner>) ImmutableList.of((MobSpawner) new MobSpawnerPhantom(), (MobSpawner) new MobSpawnerPatrol(), (MobSpawner) new MobSpawnerCat(), (MobSpawner) new VillageSiege(), (MobSpawner) new MobSpawnerTrader((IWorldDataServer) worlddata));
|
final List<MobSpawner> list = (List<MobSpawner>) ImmutableList.of((MobSpawner) new MobSpawnerPhantom(), (MobSpawner) new MobSpawnerPatrol(), (MobSpawner) new MobSpawnerCat(), (MobSpawner) new VillageSiege(), (MobSpawner) new MobSpawnerTrader((IWorldDataServer) worlddata));
|
||||||
final RegistryMaterials<WorldDimension> registrymaterials = (RegistryMaterials<WorldDimension>) worlddata.getGeneratorSettings().d();
|
|
||||||
final WorldDimension worlddimension = (WorldDimension) registrymaterials.a((ResourceKey) actualDimension);
|
|
||||||
DimensionManager dimensionmanager;
|
DimensionManager dimensionmanager;
|
||||||
net.minecraft.server.v1_16_R2.ChunkGenerator chunkgenerator;
|
net.minecraft.server.v1_16_R2.ChunkGenerator chunkgenerator;
|
||||||
|
long ll = creator.seed();
|
||||||
if(worlddimension == null)
|
dimensionmanager = (DimensionManager) getConsoleDimension(console).a().d(DimensionManager.OVERWORLD);
|
||||||
{
|
O<WorldServer> ws = new O<WorldServer>();
|
||||||
dimensionmanager = (DimensionManager) console.f.a().d(DimensionManager.OVERWORLD);
|
chunkgenerator = PaperLib.isPaper() ? new NMSChunkGenerator16_2_PAPER(pro, ws, (WorldChunkManager) new WorldChunkManagerOverworld(ll, false, false, (IRegistry<BiomeBase>) getConsoleDimension(console).b(IRegistry.ay)), ll, () -> (GeneratorSettingBase) getConsoleDimension(console).b(IRegistry.ar).d(GeneratorSettingBase.c)) : new NMSChunkGenerator16_2_SPIGOT(pro, ws, (WorldChunkManager) new WorldChunkManagerOverworld(ll, false, false, (IRegistry<BiomeBase>) getConsoleDimension(console).b(IRegistry.ay)), ll, () -> (GeneratorSettingBase) getConsoleDimension(console).b(IRegistry.ar).d(GeneratorSettingBase.c));
|
||||||
chunkgenerator = (net.minecraft.server.v1_16_R2.ChunkGenerator) GeneratorSettings.a((IRegistry<BiomeBase>) console.f.b(IRegistry.ay), (IRegistry<GeneratorSettingBase>) console.f.b(IRegistry.ar), new Random().nextLong());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dimensionmanager = worlddimension.b();
|
|
||||||
chunkgenerator = worlddimension.c();
|
|
||||||
}
|
|
||||||
|
|
||||||
final ResourceKey<net.minecraft.server.v1_16_R2.World> worldKey = (ResourceKey<net.minecraft.server.v1_16_R2.World>) ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(Locale.ENGLISH)));
|
final ResourceKey<net.minecraft.server.v1_16_R2.World> worldKey = (ResourceKey<net.minecraft.server.v1_16_R2.World>) ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(Locale.ENGLISH)));
|
||||||
//@builder
|
//@builder
|
||||||
final WorldServer internal = new WorldServer((MinecraftServer) console,
|
final WorldServer internal = new WorldServer((MinecraftServer) console,
|
||||||
@ -173,8 +170,10 @@ public class NMSCreator162
|
|||||||
(List) ((creator.environment() == World.Environment.NORMAL) ? list : ImmutableList.of()),
|
(List) ((creator.environment() == World.Environment.NORMAL) ? list : ImmutableList.of()),
|
||||||
true,
|
true,
|
||||||
creator.environment(),
|
creator.environment(),
|
||||||
generator);
|
server.getGenerator(name));
|
||||||
//@done
|
//@done
|
||||||
|
IrisWorlds.register(internal.getWorld(), pro);
|
||||||
|
ws.set(internal);
|
||||||
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -189,10 +188,12 @@ public class NMSCreator162
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.initWorld(internal, (IWorldDataServer) worlddata, (SaveData) worlddata, worlddata.getGeneratorSettings());
|
console.initWorld(internal, (IWorldDataServer) worlddata, (SaveData) worlddata, worlddata.getGeneratorSettings());
|
||||||
internal.setSpawnFlags(true, true);
|
internal.setSpawnFlags(true, true);
|
||||||
console.worldServer.put(internal.getDimensionKey(), internal);
|
console.worldServer.put(internal.getDimensionKey(), internal);
|
||||||
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
|
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
|
||||||
|
|
||||||
if(loadSpawn)
|
if(loadSpawn)
|
||||||
{
|
{
|
||||||
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
|
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
|
||||||
@ -206,4 +207,14 @@ public class NMSCreator162
|
|||||||
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
|
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
|
||||||
return (World) internal.getWorld();
|
return (World) internal.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dimension getConsoleDimension(DedicatedServer console)
|
||||||
|
{
|
||||||
|
if(PaperLib.isPaper())
|
||||||
|
{
|
||||||
|
return new V((MinecraftServer) console, true).get("customRegistry");
|
||||||
|
}
|
||||||
|
|
||||||
|
return console.f;
|
||||||
|
}
|
||||||
}
|
}
|
16
src/main/java/com/volmit/iris/gen/nms/v1X/NMSBinding1X.java
Normal file
16
src/main/java/com/volmit/iris/gen/nms/v1X/NMSBinding1X.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v1X;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
|
import com.volmit.iris.gen.nms.INMSBinding;
|
||||||
|
import com.volmit.iris.gen.nms.INMSCreator;
|
||||||
|
|
||||||
|
public class NMSBinding1X implements INMSBinding
|
||||||
|
{
|
||||||
|
private final AtomicCache<INMSCreator> creator = new AtomicCache<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INMSCreator getCreator()
|
||||||
|
{
|
||||||
|
return creator.aquire(() -> new NMSCreator1X());
|
||||||
|
}
|
||||||
|
}
|
14
src/main/java/com/volmit/iris/gen/nms/v1X/NMSCreator1X.java
Normal file
14
src/main/java/com/volmit/iris/gen/nms/v1X/NMSCreator1X.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.volmit.iris.gen.nms.v1X;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.nms.INMSCreator;
|
||||||
|
|
||||||
|
class NMSCreator1X implements INMSCreator
|
||||||
|
{
|
||||||
|
public World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||||
|
{
|
||||||
|
return creator.createWorld();
|
||||||
|
}
|
||||||
|
}
|
@ -388,7 +388,7 @@ public class PostMasterPatcher extends IrisPostBlockFilter
|
|||||||
|
|
||||||
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
|
if(!cancel && isAirOrWater(x, c, z, currentPostX, currentPostZ, currentData))
|
||||||
{
|
{
|
||||||
Slab slab = (Slab) d.getBlockData();
|
Slab slab = (Slab) d.getBlockData().clone();
|
||||||
slab.setType(Type.TOP);
|
slab.setType(Type.TOP);
|
||||||
setPostBlock(x, c, z, d, currentPostX, currentPostZ, currentData);
|
setPostBlock(x, c, z, d, currentPostX, currentPostZ, currentData);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.scaffold.GeneratedChunk;
|
||||||
import com.volmit.iris.gen.scaffold.HeightedFakeWorld;
|
import com.volmit.iris.gen.scaffold.HeightedFakeWorld;
|
||||||
import com.volmit.iris.gen.scaffold.Provisioned;
|
import com.volmit.iris.gen.scaffold.Provisioned;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||||
@ -198,17 +199,7 @@ public class ProvisionBukkit extends ChunkGenerator implements Provisioned
|
|||||||
@Override
|
@Override
|
||||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||||
{
|
{
|
||||||
cachedWorld = world;
|
cacheWorld(world);
|
||||||
if(!worldSet)
|
|
||||||
{
|
|
||||||
worldSet = true;
|
|
||||||
provider.getTarget().setRealWorld(world);
|
|
||||||
|
|
||||||
if(world.getSpawnLocation().getY() == 0 && world.getSpawnLocation().getZ() == 0 && world.getSpawnLocation().getX() == 0)
|
|
||||||
{
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> fixSpawn(world));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(precache.size() > 0)
|
if(precache.size() > 0)
|
||||||
{
|
{
|
||||||
@ -226,6 +217,28 @@ public class ProvisionBukkit extends ChunkGenerator implements Provisioned
|
|||||||
return terrain.getRaw();
|
return terrain.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GeneratedChunk generateNMSChunkData(World world, Random random, int x, int z, ChunkData nmsData, BiomeGrid biome)
|
||||||
|
{
|
||||||
|
cacheWorld(world);
|
||||||
|
TerrainChunk terrain = TerrainChunk.create(nmsData, biome);
|
||||||
|
return getProvider().generate(getRNG(world, x, z), x, z, terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheWorld(World world)
|
||||||
|
{
|
||||||
|
cachedWorld = world;
|
||||||
|
if(!worldSet)
|
||||||
|
{
|
||||||
|
worldSet = true;
|
||||||
|
provider.getTarget().setRealWorld(world);
|
||||||
|
|
||||||
|
if(world.getSpawnLocation().getY() == 0 && world.getSpawnLocation().getZ() == 0 && world.getSpawnLocation().getX() == 0)
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> fixSpawn(world));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Random getRNG(World world, int x, int z)
|
private Random getRNG(World world, int x, int z)
|
||||||
{
|
{
|
||||||
cachedWorld = world;
|
cachedWorld = world;
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.volmit.iris.gen.scaffold;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicSliverMap;
|
||||||
|
import com.volmit.iris.util.BiomeMap;
|
||||||
|
import com.volmit.iris.util.HeightMap;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Data
|
||||||
|
public class GeneratedChunk
|
||||||
|
{
|
||||||
|
private int x;
|
||||||
|
private int z;
|
||||||
|
private TerrainChunk terrain;
|
||||||
|
private HeightMap height;
|
||||||
|
private AtomicSliverMap sliverMap;
|
||||||
|
private BiomeMap biomeMap;
|
||||||
|
}
|
@ -3,19 +3,53 @@ package com.volmit.iris.gen.scaffold;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
|
import com.volmit.iris.util.KMap;
|
||||||
|
|
||||||
public class IrisWorlds
|
public class IrisWorlds
|
||||||
{
|
{
|
||||||
|
private static final KMap<String, Provisioned> provisioned = new KMap<>();
|
||||||
|
|
||||||
|
public static void register(World w, Provisioned p)
|
||||||
|
{
|
||||||
|
provisioned.put(w.getUID().toString(), p);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isIrisWorld(World world)
|
public static boolean isIrisWorld(World world)
|
||||||
{
|
{
|
||||||
return world.getGenerator() instanceof Provisioned;
|
if(provisioned.containsKey(world.getUID().toString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return world.getGenerator() instanceof Provisioned || world.getGenerator() instanceof ProvisionedHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IrisTerrainProvider getProvider(World world)
|
public static IrisTerrainProvider getProvider(World world)
|
||||||
{
|
{
|
||||||
if(isIrisWorld(world))
|
if(isIrisWorld(world))
|
||||||
{
|
{
|
||||||
return (IrisTerrainProvider) ((Provisioned) world.getGenerator()).getProvider();
|
return (IrisTerrainProvider) getProvisioned(world).getProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProvisionBukkit getProvisioned(World world)
|
||||||
|
{
|
||||||
|
if(isIrisWorld(world))
|
||||||
|
{
|
||||||
|
if(provisioned.containsKey(world.getUID().toString()))
|
||||||
|
{
|
||||||
|
return (ProvisionBukkit) provisioned.get(world.getUID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(world.getGenerator() instanceof ProvisionedHolder)
|
||||||
|
{
|
||||||
|
return (ProvisionBukkit) ((ProvisionedHolder) world.getGenerator()).getProvisioned();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((ProvisionBukkit) world.getGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -23,6 +23,14 @@ public class LinkedTerrainChunk implements TerrainChunk
|
|||||||
this(null, maxHeight);
|
this(null, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedTerrainChunk(BiomeGrid storage, ChunkData data)
|
||||||
|
{
|
||||||
|
this.storage = storage;
|
||||||
|
rawChunkData = data;
|
||||||
|
biome2D = storage != null ? null : Iris.biome3d ? null : new Biome[256];
|
||||||
|
biome3D = storage != null ? null : Iris.biome3d ? new IrisBiomeStorage() : null;
|
||||||
|
}
|
||||||
|
|
||||||
public LinkedTerrainChunk(BiomeGrid storage, int maxHeight)
|
public LinkedTerrainChunk(BiomeGrid storage, int maxHeight)
|
||||||
{
|
{
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.volmit.iris.gen.scaffold;
|
||||||
|
|
||||||
|
public interface ProvisionedHolder extends Provisioned
|
||||||
|
{
|
||||||
|
public Provisioned getProvisioned();
|
||||||
|
}
|
@ -23,6 +23,11 @@ public interface TerrainChunk extends BiomeGrid, ChunkData
|
|||||||
return create(world.getMaxHeight(), grid);
|
return create(world.getMaxHeight(), grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TerrainChunk create(ChunkData raw, BiomeGrid grid)
|
||||||
|
{
|
||||||
|
return new LinkedTerrainChunk(grid, raw);
|
||||||
|
}
|
||||||
|
|
||||||
public static TerrainChunk create(int maxHeight, BiomeGrid grid)
|
public static TerrainChunk create(int maxHeight, BiomeGrid grid)
|
||||||
{
|
{
|
||||||
return new LinkedTerrainChunk(grid, maxHeight);
|
return new LinkedTerrainChunk(grid, maxHeight);
|
||||||
|
@ -17,7 +17,7 @@ public interface TerrainProvider
|
|||||||
|
|
||||||
public BlockVector computeSpawn(Function<BlockVector, Boolean> allowed);
|
public BlockVector computeSpawn(Function<BlockVector, Boolean> allowed);
|
||||||
|
|
||||||
public void generate(Random random, int x, int z, TerrainChunk chunk);
|
public GeneratedChunk generate(Random random, int x, int z, TerrainChunk chunk);
|
||||||
|
|
||||||
public boolean canSpawn(int x, int z);
|
public boolean canSpawn(int x, int z);
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.volmit.iris.generator;
|
||||||
|
|
||||||
|
public class IrisTerrainProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
218
src/main/java/com/volmit/iris/generator/atomics/Hunk.java
Normal file
218
src/main/java/com/volmit/iris/generator/atomics/Hunk.java
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
package com.volmit.iris.generator.atomics;
|
||||||
|
|
||||||
|
import org.bouncycastle.util.Arrays;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Hunk<T>
|
||||||
|
{
|
||||||
|
protected final int w;
|
||||||
|
protected final int h;
|
||||||
|
protected final int d;
|
||||||
|
protected final T[] data;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Hunk(int w, int h, int d)
|
||||||
|
{
|
||||||
|
this.w = w;
|
||||||
|
this.h = h;
|
||||||
|
this.d = d;
|
||||||
|
data = (T[]) new Object[w * h * d];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new hunk from a section of this hunk.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param x1
|
||||||
|
* The min x (inclusive)
|
||||||
|
* @param y1
|
||||||
|
* The min y (inclusive)
|
||||||
|
* @param z1
|
||||||
|
* The min z (inclusive)
|
||||||
|
* @param x2
|
||||||
|
* The max x (exclusive)
|
||||||
|
* @param y2
|
||||||
|
* The max y (exclusive)
|
||||||
|
* @param z2
|
||||||
|
* The max z (exclusive)
|
||||||
|
* @return the new hunk (x2-x1, y2-y1, z2-z1)
|
||||||
|
*/
|
||||||
|
public Hunk<T> crop(int x1, int y1, int z1, int x2, int y2, int z2)
|
||||||
|
{
|
||||||
|
Hunk<T> h = new Hunk<T>(x2 - x1, y2 - y1, z2 - z1);
|
||||||
|
|
||||||
|
for(int i = x1; i < x2; i++)
|
||||||
|
{
|
||||||
|
for(int j = y1; j < y2; j++)
|
||||||
|
{
|
||||||
|
for(int k = z1; k < z2; k++)
|
||||||
|
{
|
||||||
|
h.set(i - x1, j - y1, k - z1, get(i, j, k));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a hunk into this one with an offset the inserted hunk
|
||||||
|
*
|
||||||
|
* @param offX
|
||||||
|
* the offset from zero for x
|
||||||
|
* @param offY
|
||||||
|
* the offset from zero for y
|
||||||
|
* @param offZ
|
||||||
|
* the offset from zero for z
|
||||||
|
* @param hunk
|
||||||
|
* the hunk to insert
|
||||||
|
*/
|
||||||
|
public void insert(int offX, int offY, int offZ, Hunk<T> hunk)
|
||||||
|
{
|
||||||
|
insert(offX, offY, offZ, hunk, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a hunk into this one
|
||||||
|
*
|
||||||
|
* @param hunk
|
||||||
|
* the hunk to insert
|
||||||
|
*/
|
||||||
|
public void insert(Hunk<T> hunk)
|
||||||
|
{
|
||||||
|
insert(0, 0, 0, hunk, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a hunk into this one
|
||||||
|
*
|
||||||
|
* @param hunk
|
||||||
|
* the hunk to insert
|
||||||
|
* @param inverted
|
||||||
|
* invert the inserted hunk or not
|
||||||
|
*/
|
||||||
|
public void insert(Hunk<T> hunk, boolean inverted)
|
||||||
|
{
|
||||||
|
insert(0, 0, 0, hunk, inverted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a hunk into this one with an offset and possibly inverting the y of
|
||||||
|
* the inserted hunk
|
||||||
|
*
|
||||||
|
* @param offX
|
||||||
|
* the offset from zero for x
|
||||||
|
* @param offY
|
||||||
|
* the offset from zero for y
|
||||||
|
* @param offZ
|
||||||
|
* the offset from zero for z
|
||||||
|
* @param hunk
|
||||||
|
* the hunk to insert
|
||||||
|
* @param invertY
|
||||||
|
* should the inserted hunk be inverted
|
||||||
|
*/
|
||||||
|
public void insert(int offX, int offY, int offZ, Hunk<T> hunk, boolean invertY)
|
||||||
|
{
|
||||||
|
if(offX + (hunk.getW() - 1) >= w || offY + (hunk.getH() - 1) >= h || offZ + (hunk.getD() - 1) >= d || offX < 0 || offY < 0 || offZ < 0)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Cannot insert hunk " + hunk.getW() + "," + hunk.getH() + "," + hunk.getD() + " into Hunk " + w + "," + h + "," + d + " with offset " + offZ + "," + offY + "," + offZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = offX; i < offX + hunk.getW(); i++)
|
||||||
|
{
|
||||||
|
for(int j = offY; j < offY + hunk.getH(); j++)
|
||||||
|
{
|
||||||
|
for(int k = offZ; k < offZ + hunk.getD(); k++)
|
||||||
|
{
|
||||||
|
set(i, j, k, hunk.get(i - offX, j - offY, k - offZ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(int x, int y, int z, T t)
|
||||||
|
{
|
||||||
|
data[index(x, y, z)] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return data[index(x, y, z)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvertedY(int x, int y, int z, T t)
|
||||||
|
{
|
||||||
|
data[index(x, h - y, z)] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getInvertedY(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return data[index(x, h - y, z)];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int index(int x, int y, int z)
|
||||||
|
{
|
||||||
|
if(x >= w || y >= h || z >= d)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(x + " " + y + " " + z + " is out of the bounds 0,0,0 - " + (w - 1) + "," + (h - 1) + "," + (d - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (z * w * h) + (y * w) + x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fill(T t)
|
||||||
|
{
|
||||||
|
Arrays.fill(data, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> Hunk<T> combined(T defaultNode, Hunk<T>... hunks)
|
||||||
|
{
|
||||||
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
|
for(Hunk<T> i : hunks)
|
||||||
|
{
|
||||||
|
w = Math.max(w, i.getW());
|
||||||
|
h = Math.max(h, i.getH());
|
||||||
|
d = Math.max(d, i.getD());
|
||||||
|
}
|
||||||
|
|
||||||
|
Hunk<T> b = new Hunk<T>(w, h, d);
|
||||||
|
b.fill(defaultNode);
|
||||||
|
|
||||||
|
for(Hunk<T> i : hunks)
|
||||||
|
{
|
||||||
|
b.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public static <T> Hunk<T> combined(Hunk<T>... hunks)
|
||||||
|
{
|
||||||
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
|
for(Hunk<T> i : hunks)
|
||||||
|
{
|
||||||
|
w = Math.max(w, i.getW());
|
||||||
|
h = Math.max(h, i.getH());
|
||||||
|
d = Math.max(d, i.getD());
|
||||||
|
}
|
||||||
|
|
||||||
|
Hunk<T> b = new Hunk<T>(w, h, d);
|
||||||
|
|
||||||
|
for(Hunk<T> i : hunks)
|
||||||
|
{
|
||||||
|
b.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
204
src/main/java/com/volmit/iris/generator/atomics/TerrainHunk.java
Normal file
204
src/main/java/com/volmit/iris/generator/atomics/TerrainHunk.java
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
package com.volmit.iris.generator.atomics;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkData
|
||||||
|
{
|
||||||
|
public TerrainHunk(int w, int h, int d)
|
||||||
|
{
|
||||||
|
super(w, h, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHeight()
|
||||||
|
{
|
||||||
|
return getH();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(int x, int y, int z, BlockData block)
|
||||||
|
{
|
||||||
|
TerrainNode n = get(x, y, z);
|
||||||
|
|
||||||
|
if(n == null)
|
||||||
|
{
|
||||||
|
n = new TerrainNode(Biome.THE_VOID, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n = n.setBlockData(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
set(x, y, z, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set(int x, int y, int z, Biome biome)
|
||||||
|
{
|
||||||
|
TerrainNode n = get(x, y, z);
|
||||||
|
|
||||||
|
if(n == null)
|
||||||
|
{
|
||||||
|
n = new TerrainNode(biome, Material.AIR.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n = n.setBiome(biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
set(x, y, z, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, Material material)
|
||||||
|
{
|
||||||
|
set(x, y, z, material.createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, MaterialData material)
|
||||||
|
{
|
||||||
|
set(x, y, z, material.getItemType().createBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, BlockData blockData)
|
||||||
|
{
|
||||||
|
set(x, y, z, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material getType(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return getBlockData(x, y, z).getMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaterialData getTypeAndData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
return new MaterialData(getBlockData(x, y, z).getMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockData getBlockData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
TerrainNode n = get(x, y, z);
|
||||||
|
|
||||||
|
if(n == null)
|
||||||
|
{
|
||||||
|
return Material.STONE.createBlockData();
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.getBlockData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte getData(int x, int y, int z)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int z)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getBiome(int x, int y, int z)
|
||||||
|
{
|
||||||
|
TerrainNode n = get(x, y, z);
|
||||||
|
|
||||||
|
if(n == null)
|
||||||
|
{
|
||||||
|
return Biome.THE_VOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.getBiome();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int z, Biome bio)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Not Supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(int x, int y, int z, Biome bio)
|
||||||
|
{
|
||||||
|
set(x, y, z, bio);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public static TerrainHunk combined(TerrainNode defaultNode, TerrainHunk... hunks)
|
||||||
|
{
|
||||||
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
|
for(TerrainHunk i : hunks)
|
||||||
|
{
|
||||||
|
w = Math.max(w, i.getW());
|
||||||
|
h = Math.max(h, i.getH());
|
||||||
|
d = Math.max(d, i.getD());
|
||||||
|
}
|
||||||
|
|
||||||
|
TerrainHunk b = new TerrainHunk(w, h, d);
|
||||||
|
b.fill(defaultNode);
|
||||||
|
|
||||||
|
for(TerrainHunk i : hunks)
|
||||||
|
{
|
||||||
|
b.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
public static TerrainHunk combined(TerrainHunk... hunks)
|
||||||
|
{
|
||||||
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
|
for(TerrainHunk i : hunks)
|
||||||
|
{
|
||||||
|
w = Math.max(w, i.getW());
|
||||||
|
h = Math.max(h, i.getH());
|
||||||
|
d = Math.max(d, i.getD());
|
||||||
|
}
|
||||||
|
|
||||||
|
TerrainHunk b = new TerrainHunk(w, h, d);
|
||||||
|
|
||||||
|
for(TerrainHunk i : hunks)
|
||||||
|
{
|
||||||
|
b.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.volmit.iris.generator.atomics;
|
||||||
|
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.KList;
|
||||||
|
|
||||||
|
public class TerrainNode
|
||||||
|
{
|
||||||
|
private static final KList<BlockData> blockDataPalette = new KList<BlockData>();
|
||||||
|
|
||||||
|
private final byte biome;
|
||||||
|
private final short block;
|
||||||
|
|
||||||
|
private TerrainNode(byte biome, short block)
|
||||||
|
{
|
||||||
|
this.biome = biome;
|
||||||
|
this.block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerrainNode(Biome biome, BlockData block)
|
||||||
|
{
|
||||||
|
this((byte) (biome.ordinal() + Byte.MIN_VALUE), (short) (paletteOf(block) + Short.MIN_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerrainNode setBlockData(BlockData block)
|
||||||
|
{
|
||||||
|
return new TerrainNode(biome, (short) (paletteOf(block) + Short.MIN_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerrainNode setBiome(Biome biome)
|
||||||
|
{
|
||||||
|
return new TerrainNode((byte) (biome.ordinal() + Byte.MIN_VALUE), block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockData getBlockData()
|
||||||
|
{
|
||||||
|
return blockDataPalette.get(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Biome getBiome()
|
||||||
|
{
|
||||||
|
return Biome.values()[biome];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int paletteOf(BlockData b)
|
||||||
|
{
|
||||||
|
synchronized(blockDataPalette)
|
||||||
|
{
|
||||||
|
int v = blockDataPalette.indexOf(b);
|
||||||
|
|
||||||
|
if(v >= 0)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataPalette.add(b);
|
||||||
|
return blockDataPalette.size() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.volmit.iris.generator.scaffold;
|
||||||
|
|
||||||
|
import com.volmit.iris.generator.atomics.TerrainHunk;
|
||||||
|
|
||||||
|
public class IrisTerrainStream implements TerrainStream
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public TerrainHunk generate(int x1, int z1, int x2, int z2)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TerrainHunk generate(int x, int z)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.volmit.iris.generator.scaffold;
|
||||||
|
|
||||||
|
import com.volmit.iris.generator.atomics.TerrainHunk;
|
||||||
|
|
||||||
|
public interface TerrainStream
|
||||||
|
{
|
||||||
|
public TerrainHunk generate(int x1, int z1, int x2, int z2);
|
||||||
|
|
||||||
|
public TerrainHunk generate(int x, int z);
|
||||||
|
}
|
@ -8,6 +8,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.edit.BlockEditor;
|
import com.volmit.iris.edit.BlockEditor;
|
||||||
import com.volmit.iris.edit.BukkitBlockEditor;
|
import com.volmit.iris.edit.BukkitBlockEditor;
|
||||||
import com.volmit.iris.edit.WEBlockEditor;
|
import com.volmit.iris.edit.WEBlockEditor;
|
||||||
@ -15,6 +16,8 @@ import com.volmit.iris.util.FastBlockData;
|
|||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import com.volmit.iris.util.M;
|
import com.volmit.iris.util.M;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
public class EditManager implements Listener
|
public class EditManager implements Listener
|
||||||
{
|
{
|
||||||
private KMap<World, BlockEditor> editors;
|
private KMap<World, BlockEditor> editors;
|
||||||
@ -85,7 +88,7 @@ public class EditManager implements Listener
|
|||||||
|
|
||||||
BlockEditor e = null;
|
BlockEditor e = null;
|
||||||
|
|
||||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
|
if(Bukkit.getPluginManager().isPluginEnabled("WorldEdit") && !PaperLib.isPaper() && !IrisSettings.get().isIgnoreWorldEdit())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.noise.CNG;
|
import com.volmit.iris.noise.CNG;
|
||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.util.BoardManager;
|
import com.volmit.iris.util.BoardManager;
|
||||||
@ -56,7 +56,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
|||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
private boolean isIrisWorld(World w)
|
private boolean isIrisWorld(World w)
|
||||||
{
|
{
|
||||||
return (w.getGenerator() instanceof ProvisionBukkit) && ((IrisTerrainProvider) ((ProvisionBukkit) w.getGenerator()).getProvider()).isDev();
|
return IrisWorlds.isIrisWorld(w) && IrisWorlds.getProvider(w).isDev();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePlayer(Player p)
|
public void updatePlayer(Player p)
|
||||||
@ -90,7 +90,7 @@ public class IrisBoardManager implements BoardProvider, Listener
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisTerrainProvider g = (IrisTerrainProvider) ((ProvisionBukkit) player.getWorld().getGenerator()).getProvider();
|
IrisTerrainProvider g = IrisWorlds.getProvider(player.getWorld());
|
||||||
|
|
||||||
if(cl.flip())
|
if(cl.flip())
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ public class IrisDataManager
|
|||||||
public IrisDataManager(File dataFolder)
|
public IrisDataManager(File dataFolder)
|
||||||
{
|
{
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.packs = new File(dataFolder, ProjectManager.workspaceName);
|
this.packs = new File(dataFolder, ProjectManager.WORKSPACE_NAME);
|
||||||
boolean pr = false;
|
boolean pr = false;
|
||||||
if(!packs.exists())
|
if(!packs.exists())
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ public class IrisDataManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File packs = this.packs.getName().equals(ProjectManager.workspaceName) ? this.packs : dataFolder;
|
File packs = this.packs.getName().equals(ProjectManager.WORKSPACE_NAME) ? this.packs : dataFolder;
|
||||||
packs.mkdirs();
|
packs.mkdirs();
|
||||||
this.lootLoader = new ResourceLoader<>(packs, "loot", "Loot", IrisLootTable.class);
|
this.lootLoader = new ResourceLoader<>(packs, "loot", "Loot", IrisLootTable.class);
|
||||||
this.entityLoader = new ResourceLoader<>(packs, "entities", "Entity", IrisEntity.class);
|
this.entityLoader = new ResourceLoader<>(packs, "entities", "Entity", IrisEntity.class);
|
||||||
@ -77,7 +77,7 @@ public class IrisDataManager
|
|||||||
this.blockLoader = new ResourceLoader<>(packs, "blocks", "Block", IrisBlockData.class);
|
this.blockLoader = new ResourceLoader<>(packs, "blocks", "Block", IrisBlockData.class);
|
||||||
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
this.objectLoader = new ObjectResourceLoader(packs, "objects", "Object");
|
||||||
|
|
||||||
if(packs.getName().equals(ProjectManager.workspaceName))
|
if(packs.getName().equals(ProjectManager.WORKSPACE_NAME))
|
||||||
{
|
{
|
||||||
writeExamples();
|
writeExamples();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import com.google.gson.Gson;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.nms.NMSCreator;
|
import com.volmit.iris.gen.nms.INMS;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||||
@ -191,7 +191,7 @@ public class IrisProject
|
|||||||
});
|
});
|
||||||
|
|
||||||
//@builder
|
//@builder
|
||||||
World world = NMSCreator.createWorld(new WorldCreator(wfp)
|
World world = INMS.get().createWorld(new WorldCreator(wfp)
|
||||||
.seed(1337)
|
.seed(1337)
|
||||||
.generator(gen)
|
.generator(gen)
|
||||||
.generateStructures(d.isVanillaStructures())
|
.generateStructures(d.isVanillaStructures())
|
||||||
@ -238,7 +238,7 @@ public class IrisProject
|
|||||||
return new File(path, getName() + ".code-workspace");
|
return new File(path, getName() + ".code-workspace");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWorkspace()
|
public boolean updateWorkspace()
|
||||||
{
|
{
|
||||||
getPath().mkdirs();
|
getPath().mkdirs();
|
||||||
File ws = getCodeWorkspaceFile();
|
File ws = getCodeWorkspaceFile();
|
||||||
@ -251,6 +251,7 @@ public class IrisProject
|
|||||||
IO.writeAll(ws, j.toString(4));
|
IO.writeAll(ws, j.toString(4));
|
||||||
p.end();
|
p.end();
|
||||||
Iris.info("Updated Workspace: " + ws.getPath() + " in " + Form.duration(p.getMilliseconds(), 2));
|
Iris.info("Updated Workspace: " + ws.getPath() + " in " + Form.duration(p.getMilliseconds(), 2));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
@ -267,6 +268,8 @@ public class IrisProject
|
|||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject createCodeWorkspaceConfig()
|
public JSONObject createCodeWorkspaceConfig()
|
||||||
|
@ -27,7 +27,8 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class ProjectManager
|
public class ProjectManager
|
||||||
{
|
{
|
||||||
public static final String workspaceName = "packs";
|
public static final String LISTING = "https://raw.githubusercontent.com/IrisDimensions/_listing/main/listing.json";
|
||||||
|
public static final String WORKSPACE_NAME = "packs";
|
||||||
private KMap<String, String> cacheListing = null;
|
private KMap<String, String> cacheListing = null;
|
||||||
private IrisProject activeProject;
|
private IrisProject activeProject;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class ProjectManager
|
|||||||
{
|
{
|
||||||
if(i.isFile() && i.getName().equals(type + ".iris"))
|
if(i.isFile() && i.getName().equals(type + ".iris"))
|
||||||
{
|
{
|
||||||
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.workspaceName + " folder");
|
sender.sendMessage("Found " + type + ".iris in " + ProjectManager.WORKSPACE_NAME + " folder");
|
||||||
ZipUtil.unpack(i, iris);
|
ZipUtil.unpack(i, iris);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -80,7 +81,7 @@ public class ProjectManager
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.workspaceName + " folder. Repackaging");
|
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.WORKSPACE_NAME + " folder. Repackaging");
|
||||||
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
|
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -90,7 +91,7 @@ public class ProjectManager
|
|||||||
|
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,12 +278,12 @@ public class ProjectManager
|
|||||||
|
|
||||||
if(cached)
|
if(cached)
|
||||||
{
|
{
|
||||||
a = new JSONArray(Iris.getCached("cachedlisting", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/listing.json"));
|
a = new JSONArray(Iris.getCached("cachedlisting", LISTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a = new JSONArray(Iris.getNonCached(!cached + "listing", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/listing.json"));
|
a = new JSONArray(Iris.getNonCached(!cached + "listing", LISTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
KMap<String, String> l = new KMap<>();
|
KMap<String, String> l = new KMap<>();
|
||||||
@ -331,12 +332,12 @@ public class ProjectManager
|
|||||||
|
|
||||||
public File getWorkspaceFolder(String... sub)
|
public File getWorkspaceFolder(String... sub)
|
||||||
{
|
{
|
||||||
return Iris.instance.getDataFolderList(workspaceName, sub);
|
return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getWorkspaceFile(String... sub)
|
public File getWorkspaceFile(String... sub)
|
||||||
{
|
{
|
||||||
return Iris.instance.getDataFileList(workspaceName, sub);
|
return Iris.instance.getDataFileList(WORKSPACE_NAME, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close()
|
||||||
|
@ -155,24 +155,32 @@ public class WandManager implements Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerInteractEvent e)
|
public void on(PlayerInteractEvent e)
|
||||||
{
|
{
|
||||||
if(e.getHand().equals(EquipmentSlot.HAND) && isWand(e.getPlayer().getInventory().getItemInMainHand()))
|
try
|
||||||
{
|
{
|
||||||
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
if(e.getHand().equals(EquipmentSlot.HAND) && isWand(e.getPlayer().getInventory().getItemInMainHand()))
|
||||||
{
|
{
|
||||||
e.setCancelled(true);
|
if(e.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||||
e.getPlayer().getInventory().setItemInMainHand(update(true, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
{
|
||||||
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f);
|
e.setCancelled(true);
|
||||||
e.getPlayer().updateInventory();
|
e.getPlayer().getInventory().setItemInMainHand(update(true, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
||||||
}
|
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 0.67f);
|
||||||
|
e.getPlayer().updateInventory();
|
||||||
|
}
|
||||||
|
|
||||||
else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
else if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||||
{
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getPlayer().getInventory().setItemInMainHand(update(false, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
e.getPlayer().getInventory().setItemInMainHand(update(false, e.getClickedBlock().getLocation(), e.getPlayer().getInventory().getItemInMainHand()));
|
||||||
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f);
|
e.getPlayer().playSound(e.getClickedBlock().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1f, 1.17f);
|
||||||
e.getPlayer().updateInventory();
|
e.getPlayer().updateInventory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(Throwable ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pasteSchematic(IrisObject s, Location at)
|
public static void pasteSchematic(IrisObject s, Location at)
|
||||||
|
@ -285,6 +285,7 @@ public class CNG
|
|||||||
{
|
{
|
||||||
Iris.error("Failed to sample noise into array " + v.size() + " nodes");
|
Iris.error("Failed to sample noise into array " + v.size() + " nodes");
|
||||||
Iris.error("Noise Source: " + generator.getClass().getSimpleName());
|
Iris.error("Noise Source: " + generator.getClass().getSimpleName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.get(0);
|
return v.get(0);
|
||||||
|
2369
src/main/java/com/volmit/iris/noise/FastNoise.java
Normal file
2369
src/main/java/com/volmit/iris/noise/FastNoise.java
Normal file
File diff suppressed because one or more lines are too long
@ -4,16 +4,16 @@ import com.volmit.iris.util.RNG;
|
|||||||
|
|
||||||
public class WhiteNoise implements NoiseGenerator
|
public class WhiteNoise implements NoiseGenerator
|
||||||
{
|
{
|
||||||
private final FastNoiseDouble n;
|
private final FastNoise n;
|
||||||
|
|
||||||
public WhiteNoise(long seed)
|
public WhiteNoise(long seed)
|
||||||
{
|
{
|
||||||
n = new FastNoiseDouble(new RNG(seed).lmax());
|
n = new FastNoise(new RNG(seed).imax());
|
||||||
}
|
}
|
||||||
|
|
||||||
private double f(double m)
|
private double f(double m)
|
||||||
{
|
{
|
||||||
return m;
|
return (m % 8192) * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,12 +22,11 @@ import lombok.experimental.Accessors;
|
|||||||
@Data
|
@Data
|
||||||
public class IrisCaveFluid
|
public class IrisCaveFluid
|
||||||
{
|
{
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@MaxNumber(255)
|
@MaxNumber(255)
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The cave zoom. Higher values makes caves spread out further and branch less often, but are thicker.")
|
@Desc("The fluid height of the cave")
|
||||||
private int fluidHeight = 35;
|
private int fluidHeight = 35;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
|
@ -94,8 +94,16 @@ public class IrisCompat
|
|||||||
return txf;
|
return txf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nomore = 64;
|
||||||
|
|
||||||
searching: while(true)
|
searching: while(true)
|
||||||
{
|
{
|
||||||
|
if(nomore < 0)
|
||||||
|
{
|
||||||
|
return B.parseBlockDataOrNull("STONE").getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
nomore--;
|
||||||
if(err-- <= 0)
|
if(err-- <= 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -127,9 +135,17 @@ public class IrisCompat
|
|||||||
{
|
{
|
||||||
return tx.getType();
|
return tx.getType();
|
||||||
}
|
}
|
||||||
|
nomore = 64;
|
||||||
|
|
||||||
searching: while(true)
|
searching: while(true)
|
||||||
{
|
{
|
||||||
|
if(nomore < 0)
|
||||||
|
{
|
||||||
|
return B.parseBlockDataOrNull("STONE").getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
nomore--;
|
||||||
|
|
||||||
if(err-- <= 0)
|
if(err-- <= 0)
|
||||||
{
|
{
|
||||||
return B.parseBlockDataOrNull("STONE").getType();
|
return B.parseBlockDataOrNull("STONE").getType();
|
||||||
|
@ -82,11 +82,6 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
@Desc("Reference loot tables in this area")
|
@Desc("Reference loot tables in this area")
|
||||||
private IrisLootReference loot = new IrisLootReference();
|
private IrisLootReference loot = new IrisLootReference();
|
||||||
|
|
||||||
@DontObfuscate
|
|
||||||
@MinNumber(0)
|
|
||||||
@Desc("Try to fill a container with loot up to this many times to avoid too many empty chests.")
|
|
||||||
private int lootTries = 5;
|
|
||||||
|
|
||||||
@Required
|
@Required
|
||||||
@MinNumber(0)
|
@MinNumber(0)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -168,6 +163,10 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
@Desc("Generate vanilla structures")
|
@Desc("Generate vanilla structures")
|
||||||
private boolean vanillaStructures = false;
|
private boolean vanillaStructures = false;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("If defined, If air is defined below the area, this fluid will always place")
|
||||||
|
private IrisCaveFluid forceFluid = new IrisCaveFluid();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("Generate decorations or not")
|
@Desc("Generate decorations or not")
|
||||||
private boolean decorate = true;
|
private boolean decorate = true;
|
||||||
|
@ -6,10 +6,13 @@ import java.util.Random;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.attribute.Attributable;
|
import org.bukkit.attribute.Attributable;
|
||||||
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Mob;
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Panda;
|
||||||
|
import org.bukkit.entity.Panda.Gene;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.loot.LootContext;
|
import org.bukkit.loot.LootContext;
|
||||||
@ -134,6 +137,18 @@ public class IrisEntity extends IrisRegistrant
|
|||||||
@Desc("If specified, this entity will be leashed by this entity. I.e. THIS ENTITY Leashed by SPECIFIED. This has no effect on EnderDragons, Withers, Players, or Bats.Non-living entities excluding leashes will not persist as leashholders.")
|
@Desc("If specified, this entity will be leashed by this entity. I.e. THIS ENTITY Leashed by SPECIFIED. This has no effect on EnderDragons, Withers, Players, or Bats.Non-living entities excluding leashes will not persist as leashholders.")
|
||||||
private IrisEntity leashHolder = null;
|
private IrisEntity leashHolder = null;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The main gene for a panda if the entity type is a panda")
|
||||||
|
private Gene pandaMainGene = Gene.NORMAL;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The hidden gene for a panda if the entity type is a panda")
|
||||||
|
private Gene pandaHiddenGene = Gene.NORMAL;
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The this entity is ageable, set it's baby status")
|
||||||
|
private boolean baby = false;
|
||||||
|
|
||||||
public Entity spawn(ParallaxTerrainProvider gen, Location at)
|
public Entity spawn(ParallaxTerrainProvider gen, Location at)
|
||||||
{
|
{
|
||||||
return spawn(gen, at, new RNG(at.hashCode()));
|
return spawn(gen, at, new RNG(at.hashCode()));
|
||||||
@ -184,15 +199,10 @@ public class IrisEntity extends IrisRegistrant
|
|||||||
{
|
{
|
||||||
KList<ItemStack> items = new KList<>();
|
KList<ItemStack> items = new KList<>();
|
||||||
|
|
||||||
for(int t = 0; t < gen.getDimension().getLootTries(); t++)
|
for(String fi : getLoot().getTables())
|
||||||
{
|
{
|
||||||
int b = 4;
|
IrisLootTable i = gen.getData().getLootLoader().load(fi);
|
||||||
for(String fi : getLoot().getTables())
|
items.addAll(i.getLoot(gen.isDev(), false, rng.nextParallelRNG(345911), InventorySlotType.STORAGE, at.getBlockX(), at.getBlockY(), at.getBlockZ(), 8, 4));
|
||||||
{
|
|
||||||
IrisLootTable i = gen.getData().getLootLoader().load(fi);
|
|
||||||
b++;
|
|
||||||
items.addAll(i.getLoot(gen.isDev(), rng.nextParallelRNG(345911 * -t), InventorySlotType.STORAGE, at.getBlockX(), at.getBlockY(), at.getBlockZ(), t + b + b, b));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
@ -256,6 +266,17 @@ public class IrisEntity extends IrisRegistrant
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(e instanceof Ageable && isBaby())
|
||||||
|
{
|
||||||
|
((Ageable) e).setBaby();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e instanceof Panda)
|
||||||
|
{
|
||||||
|
((Panda) e).setMainGene(getPandaMainGene());
|
||||||
|
((Panda) e).setMainGene(getPandaHiddenGene());
|
||||||
|
}
|
||||||
|
|
||||||
if(Iris.awareEntities && e instanceof Mob)
|
if(Iris.awareEntities && e instanceof Mob)
|
||||||
{
|
{
|
||||||
Mob m = (Mob) e;
|
Mob m = (Mob) e;
|
||||||
|
@ -217,14 +217,14 @@ public class IrisLoot
|
|||||||
return new ItemStack(Material.AIR);
|
return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
|
public ItemStack get(boolean debug, boolean giveSomething, IrisLootTable table, RNG rng, int x, int y, int z)
|
||||||
{
|
{
|
||||||
if(debug)
|
if(debug)
|
||||||
{
|
{
|
||||||
chance.reset();
|
chance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
|
if(giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
|
||||||
{
|
{
|
||||||
if(getType() == null)
|
if(getType() == null)
|
||||||
{
|
{
|
||||||
|
@ -39,14 +39,19 @@ public class IrisLootTable extends IrisRegistrant
|
|||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The maximum amount of loot that can be picked in this table at a time.")
|
@Desc("The maximum amount of loot that can be picked in this table at a time.")
|
||||||
private int maxPicked = 3;
|
private int maxPicked = 5;
|
||||||
|
|
||||||
|
@MinNumber(0)
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The minimum amount of loot that can be picked in this table at a time.")
|
||||||
|
private int minPicked = 1;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The loot in this table")
|
@Desc("The loot in this table")
|
||||||
@ArrayType(min = 1, type = IrisLoot.class)
|
@ArrayType(min = 1, type = IrisLoot.class)
|
||||||
private KList<IrisLoot> loot = new KList<>();
|
private KList<IrisLoot> loot = new KList<>();
|
||||||
|
|
||||||
public KList<ItemStack> getLoot(boolean debug, RNG rng, InventorySlotType slot, int x, int y, int z, int gg, int ffs)
|
public KList<ItemStack> getLoot(boolean debug, boolean doSomething, RNG rng, InventorySlotType slot, int x, int y, int z, int gg, int ffs)
|
||||||
{
|
{
|
||||||
KList<ItemStack> lootf = new KList<>();
|
KList<ItemStack> lootf = new KList<>();
|
||||||
|
|
||||||
@ -56,7 +61,7 @@ public class IrisLootTable extends IrisRegistrant
|
|||||||
{
|
{
|
||||||
if(i.getSlotTypes().equals(slot))
|
if(i.getSlotTypes().equals(slot))
|
||||||
{
|
{
|
||||||
ItemStack item = i.get(debug, this, rng, x, y, z);
|
ItemStack item = i.get(debug, false, this, rng, x, y, z);
|
||||||
|
|
||||||
if(item != null)
|
if(item != null)
|
||||||
{
|
{
|
||||||
@ -72,6 +77,18 @@ public class IrisLootTable extends IrisRegistrant
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(lootf.size() < getMinPicked())
|
||||||
|
{
|
||||||
|
for(int i = 0; i < getMinPicked() - lootf.size(); i++)
|
||||||
|
{
|
||||||
|
ItemStack item = loot.get(rng.nextParallelRNG(3945).nextInt(loot.size())).get(debug, doSomething, this, rng, x, y, z);
|
||||||
|
if(item != null)
|
||||||
|
{
|
||||||
|
lootf.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return lootf;
|
return lootf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,20 +138,15 @@ public class B
|
|||||||
{
|
{
|
||||||
String bd = bdx.trim().toUpperCase();
|
String bd = bdx.trim().toUpperCase();
|
||||||
|
|
||||||
return typesb.get(bd, (k) ->
|
try
|
||||||
{
|
{
|
||||||
try
|
return Material.valueOf(bd);
|
||||||
{
|
}
|
||||||
return FastBlockData.of(Material.valueOf(k));
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}).getType();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSolid(FastBlockData mat)
|
public static boolean isSolid(FastBlockData mat)
|
||||||
@ -337,8 +332,33 @@ public class B
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NoArgsConstructor
|
// @builder
|
||||||
boolean str = mat.equals(B.mat("CHEST")) || mat.equals(B.mat("TRAPPED_CHEST")) || mat.equals(B.mat("SHULKER_BOX")) || mat.equals(B.mat("WHITE_SHULKER_BOX")) || mat.equals(B.mat("ORANGE_SHULKER_BOX")) || mat.equals(B.mat("MAGENTA_SHULKER_BOX")) || mat.equals(B.mat("LIGHT_BLUE_SHULKER_BOX")) || mat.equals(B.mat("YELLOW_SHULKER_BOX")) || mat.equals(B.mat("LIME_SHULKER_BOX")) || mat.equals(B.mat("PINK_SHULKER_BOX")) || mat.equals(B.mat("GRAY_SHULKER_BOX")) || mat.equals(B.mat("LIGHT_GRAY_SHULKER_BOX")) || mat.equals(B.mat("CYAN_SHULKER_BOX")) || mat.equals(B.mat("PURPLE_SHULKER_BOX")) || mat.equals(B.mat("BLUE_SHULKER_BOX")) || mat.equals(B.mat("BROWN_SHULKER_BOX")) || mat.equals(B.mat("GREEN_SHULKER_BOX")) || mat.equals(B.mat("RED_SHULKER_BOX")) || mat.equals(B.mat("BLACK_SHULKER_BOX")) || mat.equals(B.mat("BARREL")) || mat.equals(B.mat("DISPENSER")) || mat.equals(B.mat("DROPPER")) || mat.equals(B.mat("HOPPER")) || mat.equals(B.mat("FURNACE")) || mat.equals(B.mat("BLAST_FURNACE")) || mat.equals(B.mat("SMOKER"));
|
boolean str = mat.matEquals(B.mat("CHEST"))
|
||||||
|
|| mat.matEquals(B.mat("TRAPPED_CHEST"))
|
||||||
|
|| mat.matEquals(B.mat("SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("WHITE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("ORANGE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("MAGENTA_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIGHT_BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("YELLOW_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIME_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("PINK_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIGHT_GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("CYAN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("PURPLE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BROWN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("GREEN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("RED_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BLACK_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BARREL"))
|
||||||
|
|| mat.matEquals(B.mat("DISPENSER"))
|
||||||
|
|| mat.matEquals(B.mat("DROPPER"))
|
||||||
|
|| mat.matEquals(B.mat("HOPPER"))
|
||||||
|
|| mat.matEquals(B.mat("FURNACE"))
|
||||||
|
|| mat.matEquals(B.mat("BLAST_FURNACE"))
|
||||||
|
|| mat.matEquals(B.mat("SMOKER"));
|
||||||
//@done
|
//@done
|
||||||
|
|
||||||
if(str)
|
if(str)
|
||||||
@ -359,8 +379,30 @@ public class B
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NoArgsConstructor
|
// @builder
|
||||||
boolean str = mat.equals(B.mat("CHEST")) || mat.equals(B.mat("TRAPPED_CHEST")) || mat.equals(B.mat("SHULKER_BOX")) || mat.equals(B.mat("WHITE_SHULKER_BOX")) || mat.equals(B.mat("ORANGE_SHULKER_BOX")) || mat.equals(B.mat("MAGENTA_SHULKER_BOX")) || mat.equals(B.mat("LIGHT_BLUE_SHULKER_BOX")) || mat.equals(B.mat("YELLOW_SHULKER_BOX")) || mat.equals(B.mat("LIME_SHULKER_BOX")) || mat.equals(B.mat("PINK_SHULKER_BOX")) || mat.equals(B.mat("GRAY_SHULKER_BOX")) || mat.equals(B.mat("LIGHT_GRAY_SHULKER_BOX")) || mat.equals(B.mat("CYAN_SHULKER_BOX")) || mat.equals(B.mat("PURPLE_SHULKER_BOX")) || mat.equals(B.mat("BLUE_SHULKER_BOX")) || mat.equals(B.mat("BROWN_SHULKER_BOX")) || mat.equals(B.mat("GREEN_SHULKER_BOX")) || mat.equals(B.mat("RED_SHULKER_BOX")) || mat.equals(B.mat("BLACK_SHULKER_BOX")) || mat.equals(B.mat("BARREL")) || mat.equals(B.mat("DISPENSER")) || mat.equals(B.mat("DROPPER")) || mat.equals(B.mat("HOPPER"));
|
boolean str = mat.matEquals(B.mat("CHEST"))
|
||||||
|
|| mat.matEquals(B.mat("TRAPPED_CHEST"))
|
||||||
|
|| mat.matEquals(B.mat("SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("WHITE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("ORANGE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("MAGENTA_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIGHT_BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("YELLOW_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIME_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("PINK_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("LIGHT_GRAY_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("CYAN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("PURPLE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BLUE_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BROWN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("GREEN_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("RED_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BLACK_SHULKER_BOX"))
|
||||||
|
|| mat.matEquals(B.mat("BARREL"))
|
||||||
|
|| mat.matEquals(B.mat("DISPENSER"))
|
||||||
|
|| mat.matEquals(B.mat("DROPPER"))
|
||||||
|
|| mat.matEquals(B.mat("HOPPER"));
|
||||||
//@done
|
//@done
|
||||||
|
|
||||||
if(str)
|
if(str)
|
||||||
@ -381,8 +423,28 @@ public class B
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NoArgsConstructor
|
// @builder
|
||||||
boolean str = mat.equals(B.mat("GLOWSTONE")) || mat.equals(B.mat("END_ROD")) || mat.equals(B.mat("SOUL_SAND")) || mat.equals(B.mat("TORCH")) || mat.getType().equals(Material.REDSTONE_TORCH) || mat.equals(B.mat("SOUL_TORCH")) || mat.getType().equals(Material.REDSTONE_WALL_TORCH) || mat.getType().equals(Material.WALL_TORCH) || mat.equals(B.mat("SOUL_WALL_TORCH")) || mat.equals(B.mat("LANTERN")) || mat.getType().equals(Material.JACK_O_LANTERN) || mat.getType().equals(Material.REDSTONE_LAMP) || mat.getType().equals(Material.MAGMA_BLOCK) || mat.equals(B.mat("SHROOMLIGHT")) || mat.equals(B.mat("SEA_LANTERN")) || mat.equals(B.mat("SOUL_LANTERN")) || mat.getType().equals(Material.FIRE) || mat.equals(B.mat("SOUL_FIRE")) || mat.equals(B.mat("SEA_PICKLE")) || mat.getType().equals(Material.BREWING_STAND) || mat.getType().equals(Material.REDSTONE_ORE);
|
boolean str = mat.matEquals(B.mat("GLOWSTONE"))
|
||||||
|
|| mat.matEquals(B.mat("END_ROD"))
|
||||||
|
|| mat.matEquals(B.mat("SOUL_SAND"))
|
||||||
|
|| mat.matEquals(B.mat("TORCH"))
|
||||||
|
|| mat.getType().equals(Material.REDSTONE_TORCH)
|
||||||
|
|| mat.matEquals(B.mat("SOUL_TORCH"))
|
||||||
|
|| mat.getType().equals(Material.REDSTONE_WALL_TORCH)
|
||||||
|
|| mat.getType().equals(Material.WALL_TORCH)
|
||||||
|
|| mat.matEquals(B.mat("SOUL_WALL_TORCH"))
|
||||||
|
|| mat.matEquals(B.mat("LANTERN"))
|
||||||
|
|| mat.getType().equals(Material.JACK_O_LANTERN)
|
||||||
|
|| mat.getType().equals(Material.REDSTONE_LAMP)
|
||||||
|
|| mat.getType().equals(Material.MAGMA_BLOCK)
|
||||||
|
|| mat.matEquals(B.mat("SHROOMLIGHT"))
|
||||||
|
|| mat.matEquals(B.mat("SEA_LANTERN"))
|
||||||
|
|| mat.matEquals(B.mat("SOUL_LANTERN"))
|
||||||
|
|| mat.getType().equals(Material.FIRE)
|
||||||
|
|| mat.matEquals(B.mat("SOUL_FIRE"))
|
||||||
|
|| mat.matEquals(B.mat("SEA_PICKLE"))
|
||||||
|
|| mat.getType().equals(Material.BREWING_STAND)
|
||||||
|
|| mat.getType().equals(Material.REDSTONE_ORE);
|
||||||
//@done
|
//@done
|
||||||
if(str)
|
if(str)
|
||||||
{
|
{
|
||||||
@ -431,8 +493,36 @@ public class B
|
|||||||
}
|
}
|
||||||
|
|
||||||
FastBlockData mat = d;
|
FastBlockData mat = d;
|
||||||
// @NoArgsConstructor
|
// @builder
|
||||||
return mat.getType().equals(Material.POPPY) || mat.getType().equals(Material.DANDELION) || mat.equals(B.mat("CORNFLOWER")) || mat.equals(B.mat("SWEET_BERRY_BUSH")) || mat.equals(B.mat("CRIMSON_ROOTS")) || mat.equals(B.mat("WARPED_ROOTS")) || mat.equals(B.mat("NETHER_SPROUTS")) || mat.equals(B.mat("ALLIUM")) || mat.equals(B.mat("AZURE_BLUET")) || mat.equals(B.mat("BLUE_ORCHID")) || mat.equals(B.mat("POPPY")) || mat.equals(B.mat("DANDELION")) || mat.equals(B.mat("OXEYE_DAISY")) || mat.equals(B.mat("LILY_OF_THE_VALLEY")) || mat.equals(B.mat("WITHER_ROSE")) || mat.getType().equals(Material.DARK_OAK_SAPLING) || mat.getType().equals(Material.ACACIA_SAPLING) || mat.getType().equals(Material.JUNGLE_SAPLING) || mat.getType().equals(Material.BIRCH_SAPLING) || mat.getType().equals(Material.SPRUCE_SAPLING) || mat.getType().equals(Material.OAK_SAPLING) || mat.getType().equals(Material.ORANGE_TULIP) || mat.getType().equals(Material.PINK_TULIP) || mat.getType().equals(Material.RED_TULIP) || mat.getType().equals(Material.WHITE_TULIP) || mat.getType().equals(Material.FERN) || mat.getType().equals(Material.LARGE_FERN) || mat.getType().equals(Material.GRASS) || mat.getType().equals(Material.TALL_GRASS);
|
return mat.getType().equals(Material.POPPY)
|
||||||
|
|| mat.getType().equals(Material.DANDELION)
|
||||||
|
|| mat.matEquals(B.mat("CORNFLOWER"))
|
||||||
|
|| mat.matEquals(B.mat("SWEET_BERRY_BUSH"))
|
||||||
|
|| mat.matEquals(B.mat("CRIMSON_ROOTS"))
|
||||||
|
|| mat.matEquals(B.mat("WARPED_ROOTS"))
|
||||||
|
|| mat.matEquals(B.mat("NETHER_SPROUTS"))
|
||||||
|
|| mat.matEquals(B.mat("ALLIUM"))
|
||||||
|
|| mat.matEquals(B.mat("AZURE_BLUET"))
|
||||||
|
|| mat.matEquals(B.mat("BLUE_ORCHID"))
|
||||||
|
|| mat.matEquals(B.mat("POPPY"))
|
||||||
|
|| mat.matEquals(B.mat("DANDELION"))
|
||||||
|
|| mat.matEquals(B.mat("OXEYE_DAISY"))
|
||||||
|
|| mat.matEquals(B.mat("LILY_OF_THE_VALLEY"))
|
||||||
|
|| mat.matEquals(B.mat("WITHER_ROSE"))
|
||||||
|
|| mat.getType().equals(Material.DARK_OAK_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.ACACIA_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.JUNGLE_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.BIRCH_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.SPRUCE_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.OAK_SAPLING)
|
||||||
|
|| mat.getType().equals(Material.ORANGE_TULIP)
|
||||||
|
|| mat.getType().equals(Material.PINK_TULIP)
|
||||||
|
|| mat.getType().equals(Material.RED_TULIP)
|
||||||
|
|| mat.getType().equals(Material.WHITE_TULIP)
|
||||||
|
|| mat.getType().equals(Material.FERN)
|
||||||
|
|| mat.getType().equals(Material.LARGE_FERN)
|
||||||
|
|| mat.getType().equals(Material.GRASS)
|
||||||
|
|| mat.getType().equals(Material.TALL_GRASS);
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,11 @@ public class FastBlockData
|
|||||||
return getType().hashCode();
|
return getType().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matEquals(FastBlockData obj)
|
||||||
|
{
|
||||||
|
return getMaterial().equals(obj.getMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ public abstract class MortarCommand implements ICommand
|
|||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this with a super constructor as most commands shouldnt change these
|
* Override this with a super constructor as most commands shouldn't change these
|
||||||
* parameters
|
* parameters
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
|
@ -13,15 +13,14 @@ import org.bukkit.event.world.ChunkUnloadEvent;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.IrisTerrainProvider;
|
import com.volmit.iris.gen.IrisTerrainProvider;
|
||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||||
import com.volmit.iris.gui.PregenGui;
|
import com.volmit.iris.gui.PregenGui;
|
||||||
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.Getter;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class PregenJob implements Listener
|
public class PregenJob implements Listener
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private World world;
|
private World world;
|
||||||
private int size;
|
private int size;
|
||||||
private int total;
|
private int total;
|
||||||
@ -53,6 +52,8 @@ public class PregenJob implements Listener
|
|||||||
private long nogen = M.ms();
|
private long nogen = M.ms();
|
||||||
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
||||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||||
|
private BukkitTask pausedTask;
|
||||||
|
private boolean isPaused = false;
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
|
|
||||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||||
@ -77,7 +78,7 @@ public class PregenJob implements Listener
|
|||||||
this.chunkZ = 0;
|
this.chunkZ = 0;
|
||||||
completed = false;
|
completed = false;
|
||||||
first = true;
|
first = true;
|
||||||
tp = (world.getGenerator() instanceof ProvisionBukkit) ? (IrisTerrainProvider) ((ProvisionBukkit) world.getGenerator()).getProvider() : null;
|
tp = IrisWorlds.getProvider(world);
|
||||||
|
|
||||||
chunkSpiraler = new Spiraler(cubeSize, cubeSize, (x, z) ->
|
chunkSpiraler = new Spiraler(cubeSize, cubeSize, (x, z) ->
|
||||||
{
|
{
|
||||||
@ -126,6 +127,40 @@ public class PregenJob implements Listener
|
|||||||
task = -1;
|
task = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Cannot get paused value from this. Have to check bukkit tasks, not sure how.
|
||||||
|
// TODO: Trying to add functionality here to allow for pausing an continuing.
|
||||||
|
public static boolean isPaused(){
|
||||||
|
return false;
|
||||||
|
//return this.isPaused;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pause()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Save the task, tell bukkit to cancel it
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
task = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resume()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Load task and tell bukkit to continue it
|
||||||
|
}
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
task = -1;
|
||||||
|
}
|
||||||
|
|
||||||
public void onTick()
|
public void onTick()
|
||||||
{
|
{
|
||||||
if(completed)
|
if(completed)
|
||||||
@ -375,9 +410,17 @@ public class PregenJob implements Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(ChunkUnloadEvent e)
|
public void on(ChunkUnloadEvent e)
|
||||||
{
|
{
|
||||||
if(e.getWorld().equals(world) && isChunkWithin(e.getChunk().getX(), e.getChunk().getZ()) && consumer != null)
|
try
|
||||||
{
|
{
|
||||||
consumer.accept(new ChunkPosition(e.getChunk().getX(), e.getChunk().getZ()), tp != null ? tp.render(e.getChunk().getX() * 16, e.getChunk().getZ() * 16) : Color.blue.darker());
|
if(e.getWorld().equals(world) && isChunkWithin(e.getChunk().getX(), e.getChunk().getZ()) && consumer != null)
|
||||||
|
{
|
||||||
|
consumer.accept(new ChunkPosition(e.getChunk().getX(), e.getChunk().getZ()), tp != null ? tp.render(e.getChunk().getX() * 16, e.getChunk().getZ() * 16) : Color.blue.darker());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable ex)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,10 +462,4 @@ public class PregenJob implements Listener
|
|||||||
return new String[] {"Progress: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0), "Generated: " + Form.f(genned) + " Chunks", "Remaining: " + Form.f(total - genned) + " Chunks", "Elapsed: " + Form.duration((long) s.getMilliseconds(), 2), "Estimate: " + ((genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta, 2))), "ChunksMS: " + Form.duration(1000D / cps, 2), "Chunks/s: " + Form.f(cps, 1),
|
return new String[] {"Progress: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0), "Generated: " + Form.f(genned) + " Chunks", "Remaining: " + Form.f(total - genned) + " Chunks", "Elapsed: " + Form.duration((long) s.getMilliseconds(), 2), "Estimate: " + ((genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta, 2))), "ChunksMS: " + Form.duration(1000D / cps, 2), "Chunks/s: " + Form.f(cps, 1),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void progressMCA(Color color, int x, int z, double pct)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user