mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d2db90522 | ||
|
|
512ea0b0d7 | ||
|
|
9425e802dc | ||
|
|
95395cbc87 | ||
|
|
c71feb62e0 | ||
|
|
77969617d8 | ||
|
|
ac5788ef02 | ||
|
|
d7c5526eab | ||
|
|
4c90095361 | ||
|
|
25c612b3c3 | ||
|
|
6e078ad4a0 | ||
|
|
fc5db87514 | ||
|
|
d720e9afab | ||
|
|
9af3ec30ad | ||
|
|
47aef59858 | ||
|
|
36b352ea05 | ||
|
|
c1734b6270 | ||
|
|
ef24f2e8b2 | ||
|
|
a51802c487 | ||
|
|
5040d32cb8 | ||
|
|
d8c0c2cc61 | ||
|
|
1efb4c14db | ||
|
|
8fe8942f5d | ||
|
|
fadbcb8bb5 | ||
|
|
9489ffd4ad | ||
|
|
c6a7225fa8 | ||
|
|
2ae765ca16 | ||
|
|
1e04f61957 | ||
|
|
435ed10648 | ||
|
|
bf8077bd2c | ||
|
|
696d9e44df | ||
|
|
a8f50d4b7a | ||
|
|
709c0939af | ||
|
|
08a2954f10 | ||
|
|
9c6d32a58b | ||
|
|
4079e0a708 | ||
|
|
2cfb3d8dcc | ||
|
|
98e296b666 | ||
|
|
3532c16906 | ||
|
|
dd7d838c6b | ||
|
|
a8470c8178 | ||
|
|
8afbff4b42 | ||
|
|
05984cf64a | ||
|
|
aafbb879df | ||
|
|
86ce2856e8 | ||
|
|
564dcdcc72 | ||
|
|
ed44db5497 | ||
|
|
bdf6ad7cd0 | ||
|
|
832070cd69 |
No files matched your search
+3
-3
@@ -570,7 +570,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertTrue(state(blocks, 4, 96, 0).isAir());
|
||||
assertEquals(1, pathGround.size());
|
||||
@@ -619,7 +619,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertEquals(2, pathGround.size());
|
||||
for (NativeStructureTemplateOccupancy.LowestCell cell : pathGround.values()) {
|
||||
@@ -675,7 +675,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertEquals(2, pathGround.size());
|
||||
for (NativeStructureTemplateOccupancy.LowestCell cell : pathGround.values()) {
|
||||
|
||||
+3
-3
@@ -570,7 +570,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertTrue(state(blocks, 4, 96, 0).isAir());
|
||||
assertEquals(1, pathGround.size());
|
||||
@@ -619,7 +619,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertEquals(2, pathGround.size());
|
||||
for (NativeStructureTemplateOccupancy.LowestCell cell : pathGround.values()) {
|
||||
@@ -675,7 +675,7 @@ public class NativeStructurePostProcessorSurfaceTerrainTest {
|
||||
NativeStructurePostProcessorSurfaceTerrainTest::forbiddenTemplateManager,
|
||||
area::isInside, cells -> {});
|
||||
Map<Long, NativeStructureTemplateOccupancy.LowestCell> pathGround =
|
||||
NativeStructureTemplateOccupancy.lowestProcessedSolidCells(occupancy.cells());
|
||||
NativeStructureTemplateOccupancy.lowestFoundationCells(occupancy.cells());
|
||||
|
||||
assertEquals(2, pathGround.size());
|
||||
for (NativeStructureTemplateOccupancy.LowestCell cell : pathGround.values()) {
|
||||
|
||||
@@ -21,6 +21,7 @@ package art.arcane.iris;
|
||||
import art.arcane.iris.api.terrain.IrisTerrainService;
|
||||
import art.arcane.iris.command.CommandSVC;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.studio.app.StudioAppInstaller;
|
||||
import art.arcane.iris.configuration.SettingsHotloadWatch;
|
||||
import art.arcane.iris.diagnostics.LogFilterSVC;
|
||||
import art.arcane.iris.diagnostics.splash.IrisSplashComposer;
|
||||
@@ -976,6 +977,7 @@ public final class IrisRuntime implements IrisPluginRuntime {
|
||||
return;
|
||||
}
|
||||
BukkitGuiHost.install();
|
||||
StudioAppInstaller.installInBackground();
|
||||
// super.onEnable() already registers this instance as a listener.
|
||||
plugin.enablePlugin();
|
||||
if (IrisStartupValidation.isRestartRequired()) {
|
||||
|
||||
@@ -28,8 +28,7 @@ import art.arcane.volmlib.util.director.annotations.Director;
|
||||
import art.arcane.volmlib.util.director.annotations.Param;
|
||||
import art.arcane.iris.localization.C;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import art.arcane.iris.studio.workspace.FileOpener;
|
||||
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
@@ -51,15 +50,10 @@ public class CommandEdit implements DirectorExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
if (!FileOpener.isDesktopAvailable()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_CANNOT_OPEN_FILES_HEADLESS_ENVIRONMENTS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Desktop.isDesktopSupported()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_DESKTOP_IS_NOT_SUPPORTED_BY_THIS_ENVIRONMENT));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +68,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_CANNOT_FIND_FILE_PERHAPS_IT_WAS_NOT_LOADED_DIRECTLY_FROM));
|
||||
return;
|
||||
}
|
||||
Desktop.getDesktop().open(biome.getLoadFile());
|
||||
FileOpener.open(biome.getLoadFile());
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_OPENING_VSCODE, MessageArgument.untrusted("value", biome.getTypeName()), MessageArgument.untrusted("value2", biome.getLoadFile().getName().split("\\Q.\\E")[0])));
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
@@ -92,7 +86,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_CANNOT_FIND_FILE_PERHAPS_IT_WAS_NOT_LOADED_DIRECTLY_FROM_2));
|
||||
return;
|
||||
}
|
||||
Desktop.getDesktop().open(region.getLoadFile());
|
||||
FileOpener.open(region.getLoadFile());
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_OPENING_VSCODE_2, MessageArgument.untrusted("value", region.getTypeName()), MessageArgument.untrusted("value2", region.getLoadFile().getName().split("\\Q.\\E")[0])));
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
@@ -110,7 +104,7 @@ public class CommandEdit implements DirectorExecutor {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_CANNOT_FIND_FILE_PERHAPS_IT_WAS_NOT_LOADED_DIRECTLY_FROM_3));
|
||||
return;
|
||||
}
|
||||
Desktop.getDesktop().open(dimension.getLoadFile());
|
||||
FileOpener.open(dimension.getLoadFile());
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_EDIT_OPENING_VSCODE_3, MessageArgument.untrusted("value", dimension.getTypeName()), MessageArgument.untrusted("value2", dimension.getLoadFile().getName().split("\\Q.\\E")[0])));
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
@@ -21,9 +21,11 @@ package art.arcane.iris.command;
|
||||
import art.arcane.iris.Iris;
|
||||
import art.arcane.iris.platform.bukkit.BukkitPlatform;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.studio.map.MapWindow;
|
||||
import art.arcane.iris.studio.map.PaletteExplorerStart;
|
||||
import art.arcane.iris.studio.view.GuiHost;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.studio.bridge.StudioBridge;
|
||||
import art.arcane.iris.studio.bridge.StudioBridges;
|
||||
import art.arcane.iris.studio.bridge.StudioLaunch;
|
||||
import art.arcane.iris.studio.bridge.StudioWindow;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.studio.workspace.IrisProject;
|
||||
import art.arcane.iris.studio.workspace.IrisCodeWorkspace;
|
||||
@@ -104,6 +106,7 @@ import java.util.function.Consumer;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.BukkitCommandMessages;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
import art.arcane.volmlib.util.localization.TextKey;
|
||||
import art.arcane.volmlib.util.localization.LanguageAudience;
|
||||
import art.arcane.iris.localization.BukkitCommandMessagesExtended;
|
||||
@Director(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", descriptionKey = "iris.director.commandstudio.director.studio_commands")
|
||||
@@ -267,16 +270,10 @@ public class CommandStudio implements DirectorExecutor {
|
||||
|
||||
@Director(description = "Open the noise explorer (External GUI)", descriptionKey = "iris.director.commandstudio.director.open_noise_explorer_external_gui", aliases = {"nmap"})
|
||||
public void noise(
|
||||
@Param(description = "Optional pack generator to preview", descriptionKey = "iris.director.commandstudio.param.optional_pack_generator_preview", defaultValue = "null", contextual = true, contextualOverride = true)
|
||||
IrisGenerator generator,
|
||||
@Param(description = "The seed to preview the generator with", descriptionKey = "iris.director.commandstudio.param.seed_preview_generator_with", defaultValue = "12345")
|
||||
long seed
|
||||
@Param(name = "world", description = "The Iris world whose pack the noise explorer reads", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
if (noGUI()) return;
|
||||
VolmitSender commandSender = sender();
|
||||
UUID openerId = commandSender.isPlayer() ? commandSender.player().getUniqueId() : null;
|
||||
MapWindow.NoiseSelection selection = new MapWindow.NoiseSelection(generator == null ? null : generator.getLoadKey(), generator, seed);
|
||||
withPlayerContext(opener -> openNoiseAtPlayer(commandSender, openerId, opener, selection));
|
||||
openStudioApp(world, BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_NOISE_EXPLORER);
|
||||
}
|
||||
|
||||
@Director(description = "Open the image-map studio (External GUI)", descriptionKey = "iris.director.commandstudio.director.open_image_map_studio_external_gui", aliases = {"imap"})
|
||||
@@ -284,16 +281,7 @@ public class CommandStudio implements DirectorExecutor {
|
||||
@Param(name = "world", description = "The Iris world whose active pack receives image-map exports", descriptionKey = "iris.director.commandstudio.param.world_open_image_map_studio", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
if (noGUI()) {
|
||||
return;
|
||||
}
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_NEED_BE_SPECIFY_IRIS_GENERATED_WORLD));
|
||||
return;
|
||||
}
|
||||
|
||||
requestMapStart(world, MapWindow::openImageMaps);
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_IMAGE_MAP_STUDIO));
|
||||
openStudioApp(world, BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_IMAGE_MAP_STUDIO);
|
||||
}
|
||||
|
||||
@Director(description = "Show loot if a chest were right here", descriptionKey = "iris.director.commandstudio.director.show_loot_if_chest_were_right_here", origin = DirectorOrigin.PLAYER, sync = true)
|
||||
@@ -425,66 +413,45 @@ public class CommandStudio implements DirectorExecutor {
|
||||
@Param(name = "world", description = "The world to open the generator for", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
if (noGUI()) return;
|
||||
openStudioApp(world, BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_MAP);
|
||||
}
|
||||
|
||||
@Director(description = "Open the Iris Studio app on a world", descriptionKey = "iris.director.commandstudio.director.render_world_map_external_gui", aliases = "app")
|
||||
public void studioApp(
|
||||
@Param(name = "world", description = "The world to open the generator for", descriptionKey = "iris.director.commandstudio.param.world_open_generator", contextual = true, contextualOverride = true)
|
||||
World world
|
||||
) {
|
||||
openStudioApp(world, BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_MAP);
|
||||
}
|
||||
|
||||
/** Opens the app on the world; when it can't, tells the sender why and hands over the link to connect by hand. */
|
||||
private void openStudioApp(World world, TextKey openedMessage) {
|
||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_NEED_BE_SPECIFY_IRIS_GENERATED_WORLD));
|
||||
return;
|
||||
}
|
||||
|
||||
requestMapStart(world, MapWindow::openMap);
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_MAP));
|
||||
}
|
||||
|
||||
// The map opens where the player stands when they are in that world, otherwise at the world origin.
|
||||
private PaletteExplorerStart mapStartIn(World world, Player opener, UUID openerId) {
|
||||
Location center = opener != null && opener.getWorld().equals(world) ? opener.getLocation() : null;
|
||||
return new PaletteExplorerStart(
|
||||
IrisToolbelt.access(world).getEngine(),
|
||||
world.getUID(),
|
||||
openerId,
|
||||
null,
|
||||
center == null ? 0D : center.getX(),
|
||||
center == null ? 0D : center.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
private void requestMapStart(World world, Consumer<PaletteExplorerStart> launch) {
|
||||
UUID openerId = sender().isPlayer() ? player().getUniqueId() : null;
|
||||
withPlayerContext(opener -> launch.accept(mapStartIn(world, opener, openerId)));
|
||||
}
|
||||
|
||||
private void openNoiseAtPlayer(VolmitSender commandSender, UUID openerId, Player opener, MapWindow.NoiseSelection selection) {
|
||||
World world = opener == null ? null : opener.getWorld();
|
||||
PlatformChunkGenerator worldGenerator = world == null ? null : IrisToolbelt.access(world);
|
||||
Engine engine = worldGenerator == null ? GuiHost.get().findActiveEngine() : worldGenerator.getEngine();
|
||||
if (engine == null) {
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_NEED_BE_SPECIFY_IRIS_GENERATED_WORLD));
|
||||
PlatformChunkGenerator generator = IrisToolbelt.access(world);
|
||||
StudioBridge bridge;
|
||||
try {
|
||||
bridge = StudioBridges.open(world.getName(), generator::getEngine, openerId);
|
||||
} catch (IOException error) {
|
||||
IrisLogging.warn("Could not open the studio bridge: %s", error.getMessage());
|
||||
return;
|
||||
}
|
||||
PaletteExplorerStart start = worldGenerator == null
|
||||
? new PaletteExplorerStart(engine, null, openerId, null, 0D, 0D)
|
||||
: mapStartIn(world, opener, openerId);
|
||||
MapWindow.openNoise(start, selection);
|
||||
commandSender.sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_OPENING_NOISE_EXPLORER));
|
||||
}
|
||||
|
||||
private void withPlayerContext(Consumer<Player> action) {
|
||||
Player opener = sender().isPlayer() ? player() : null;
|
||||
if (opener == null) {
|
||||
action.accept(null);
|
||||
StudioLaunch launch = StudioWindow.show(bridge);
|
||||
if (launch.opened()) {
|
||||
sender().sendMessage(IrisLanguage.text(openedMessage));
|
||||
return;
|
||||
}
|
||||
AtomicBoolean completed = new AtomicBoolean();
|
||||
Consumer<Player> complete = player -> {
|
||||
if (completed.compareAndSet(false, true)) {
|
||||
action.accept(player);
|
||||
}
|
||||
};
|
||||
Runnable retired = () -> complete.accept(null);
|
||||
if (!J.runEntity(opener, () -> complete.accept(opener.isOnline() ? opener : null), 0, retired)) {
|
||||
retired.run();
|
||||
}
|
||||
IrisLogging.info("Iris Studio link for %s: %s", world.getName(), bridge.link());
|
||||
sendStudioLink(launch, bridge.link());
|
||||
}
|
||||
|
||||
private void sendStudioLink(StudioLaunch launch, String link) {
|
||||
sender().sendMessage(C.RED + IrisLanguage.text(launch.failureMessage()));
|
||||
sender().sendCopyButton(IrisLanguage.text(RuntimeUiMessages.STUDIO_LINK_COPY_BUTTON),
|
||||
IrisLanguage.text(RuntimeUiMessages.STUDIO_LINK_COPY_HOVER), link);
|
||||
}
|
||||
|
||||
@Director(description = "Profiles the performance of a dimension", descriptionKey = "iris.director.commandstudio.director.profiles_performance_dimension", origin = DirectorOrigin.PLAYER)
|
||||
@@ -953,21 +920,6 @@ public class CommandStudio implements DirectorExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if server GUIs are not enabled
|
||||
*/
|
||||
private boolean noGUI() {
|
||||
if (!IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_YOU_MUST_HAVE_SERVER_LAUNCHED_GUIS_ENABLED_SETTINGS));
|
||||
return true;
|
||||
}
|
||||
if (!GuiHost.isAvailable()) {
|
||||
sender().sendMessage(IrisLanguage.text(BukkitCommandMessagesExtended.COMMAND_STUDIO_DESKTOP_UNAVAILABLE));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if no studio is open or the player is not in one
|
||||
*/
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
import { readFile, realpath } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
|
||||
const nonGround = new Set(['air', 'cave_air', 'void_air', 'water', 'lava', 'nether_wart_block', 'warped_wart_block'])
|
||||
const chunkOffsets = [-56, -40, -24, -8, 8, 24, 40, 56]
|
||||
|
||||
function isWood(block) {
|
||||
return block !== null && /_(wood|hyphae|log|stem)$/.test(block.name)
|
||||
}
|
||||
|
||||
function isGround(block) {
|
||||
return block !== null && block.boundingBox === 'block' && !nonGround.has(block.name)
|
||||
&& !block.name.endsWith('_leaves') && !isWood(block)
|
||||
}
|
||||
|
||||
function positionKey(position) {
|
||||
return `${position.x},${position.y},${position.z}`
|
||||
}
|
||||
|
||||
function groundSpread(bot, base) {
|
||||
const heights = []
|
||||
for (const x of [-3, 0, 3]) {
|
||||
for (const z of [-3, 0, 3]) {
|
||||
for (let y = base.y + 6; y >= base.y - 8; y--) {
|
||||
if (!isGround(bot.blockAt(base.offset(x, y - base.y, z)))) continue
|
||||
heights.push(y)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return heights.length === 9 ? Math.max(...heights) - Math.min(...heights) : null
|
||||
}
|
||||
|
||||
function inspectTrees(context) {
|
||||
const bot = context.bot
|
||||
const center = bot.entity.position.floored()
|
||||
const woodIds = Object.values(bot.registry.blocksByName).filter(isWood).map(block => block.id)
|
||||
const positions = bot.findBlocks({ matching: woodIds, point: center, maxDistance: 64, count: 20000 })
|
||||
const columns = new Map()
|
||||
for (const position of positions) {
|
||||
const key = `${position.x},${position.z}`
|
||||
if (!columns.has(key)) columns.set(key, [])
|
||||
columns.get(key).push(position)
|
||||
}
|
||||
const trees = []
|
||||
for (const column of columns.values()) {
|
||||
column.sort((first, second) => first.y - second.y)
|
||||
const base = column[0]
|
||||
const height = column[column.length - 1].y - base.y + 1
|
||||
if (column.length < 8 || height < 8 || column.length / height < 0.65) continue
|
||||
if (column.some(position => position.distanceTo(center) >= 60)) continue
|
||||
if (![0, 1, 2, 3].every(y => isWood(bot.blockAt(base.offset(0, y, 0))))) continue
|
||||
const upperGaps = []
|
||||
for (let y = base.y; y < base.y + height; y++) {
|
||||
const block = bot.blockAt(base.offset(0, y - base.y, 0))
|
||||
if (block === null || !isWood(block)) upperGaps.push({ y, block: block?.name ?? null })
|
||||
}
|
||||
const grounded = isGround(bot.blockAt(base.offset(0, -1, 0)))
|
||||
const spread = groundSpread(bot, base)
|
||||
trees.push({ base: { x: base.x, y: base.y, z: base.z }, woodBlocks: column.length,
|
||||
height, grounded, terrainSpread: spread, upperGaps })
|
||||
}
|
||||
return trees
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'iris-tree-grounding',
|
||||
description: 'Verify grounded spindle bases, continuous overlapping trunks, and paired pack geometry.',
|
||||
async run(context) {
|
||||
const directory = await realpath(context.server.directory)
|
||||
const source = await readFile(path.join(directory, '.server-source'), 'utf8')
|
||||
context.expect(/^isolated=true\s*$/m.test(source), 'Tree generation requires an isolated instance')
|
||||
const packs = await realpath(path.join(directory, 'plugins', 'Iris', 'packs'))
|
||||
context.expect(packs.startsWith(`${directory}${path.sep}`), 'Tree tests require local pack copies')
|
||||
context.report.treeWorlds = []
|
||||
context.report.treeGrounding = []
|
||||
context.report.treeContinuity = []
|
||||
for (const pack of ['overworld', 'underworld']) {
|
||||
const dimension = JSON.parse(await readFile(path.join(packs, pack, 'dimensions', `${pack}.json`), 'utf8'))
|
||||
context.expect(dimension.focus === 'estranged/spindlewood', 'Pack must focus on spindlewood', { pack })
|
||||
await context.step(`create ${pack} spindle world`, async () => {
|
||||
const world = `tree_${pack}_${Date.now().toString(36)}`
|
||||
const response = await context.command(`/iris create name=${world} type=${pack} seed=78264193`,
|
||||
/Successfully created your world|Failed to create/, 240000)
|
||||
context.expect(response.includes('Successfully created your world'), response)
|
||||
context.report.treeWorlds.push({ pack, name: world, seed: 78264193, biome: dimension.focus })
|
||||
if (context.bot.game.gameMode !== 'spectator') {
|
||||
await context.command('/minecraft:gamemode spectator', /spectator/i, 30000)
|
||||
}
|
||||
await context.waitUntil(() => context.bot.game.gameMode === 'spectator',
|
||||
{ label: 'Spectator mode for terrain inspection', timeoutMs: 30000, intervalMs: 100 })
|
||||
})
|
||||
await context.step(`${pack} trees connect to flat and sloped terrain`, async () => {
|
||||
const origin = context.bot.entity.position.floored()
|
||||
const inspected = new Map()
|
||||
for (const offset of [0, 80, 160]) {
|
||||
await context.command(`/minecraft:tp @s ${origin.x + offset + 0.5} ${origin.y + 12} ${origin.z + 0.5}`,
|
||||
/Teleported/i, 30000)
|
||||
await context.waitUntil(() => {
|
||||
const center = context.bot.entity.position.floored()
|
||||
if (Math.abs(center.x - origin.x - offset) > 1) return false
|
||||
return chunkOffsets.every(x => chunkOffsets.every(z => context.bot.blockAt(center.offset(x, 0, z)) !== null))
|
||||
}, { label: 'Complete terrain neighborhood', timeoutMs: 90000, intervalMs: 250 })
|
||||
const trees = inspectTrees(context)
|
||||
for (const tree of trees) {
|
||||
context.expect(tree.grounded, 'Generated spindle trunk base has no terrain connection', { pack, ...tree })
|
||||
inspected.set(positionKey(tree.base), tree)
|
||||
}
|
||||
if (inspected.size >= 8 && [...inspected.values()].some(tree => tree.terrainSpread >= 2)) break
|
||||
}
|
||||
const trees = [...inspected.values()]
|
||||
const sloped = trees.filter(tree => tree.terrainSpread >= 2)
|
||||
context.expect(trees.length >= 8, 'Expected at least eight generated spindle trunk bases', { pack, trees })
|
||||
context.expect(sloped.length > 0, 'Expected a grounded tree on uneven terrain', { pack, trees })
|
||||
context.report.treeGrounding.push({ pack, trees: trees.length, sloped: sloped.length, samples: trees })
|
||||
})
|
||||
await context.step(`${pack} overlapping canopy preserves the seeded main trunk`, async () => {
|
||||
await context.command('/minecraft:tp @s 0.5 88 0.5', /Teleported/i, 30000)
|
||||
await context.waitUntil(() => {
|
||||
const center = context.bot.entity.position.floored()
|
||||
return Math.abs(center.x) < 2 && Math.abs(center.z) < 2
|
||||
&& context.bot.blockAt(center.offset(-7 - center.x, 69 - center.y, 6 - center.z)) !== null
|
||||
}, { label: 'Seeded trunk neighborhood', timeoutMs: 90000, intervalMs: 250 })
|
||||
const center = context.bot.entity.position.floored()
|
||||
const blocks = []
|
||||
for (let y = 69; y <= 83; y++) {
|
||||
const block = context.bot.blockAt(center.offset(-7 - center.x, y - center.y, 6 - center.z))
|
||||
context.expect(isWood(block), 'Overlapping canopy interrupted the seeded main trunk',
|
||||
{ pack, x: -7, y, z: 6, block: block?.name ?? null })
|
||||
blocks.push({ y, block: block.name })
|
||||
}
|
||||
context.report.treeContinuity.push({ pack, x: -7, z: 6, blocks })
|
||||
})
|
||||
}
|
||||
await context.step('paired packs retain matching sampled tree geometry', async () => {
|
||||
const geometry = context.report.treeGrounding.map(result => result.samples.map(tree => ({
|
||||
base: tree.base, woodBlocks: tree.woodBlocks, height: tree.height, terrainSpread: tree.terrainSpread
|
||||
})).sort((first, second) => positionKey(first.base).localeCompare(positionKey(second.base))))
|
||||
context.expect(JSON.stringify(geometry[0]) === JSON.stringify(geometry[1]),
|
||||
'Paired spindle packs produced different sampled geometry', { geometry })
|
||||
})
|
||||
}
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.studio.view.GuiHost;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CommandStudioDesktopTest {
|
||||
private IrisSettings previousSettings;
|
||||
private boolean previousSuppressed;
|
||||
private RecordingSender sender;
|
||||
private CommandStudio command;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
previousSettings = IrisSettings.settings;
|
||||
previousSuppressed = GuiHost.isDesktopSuppressed();
|
||||
IrisSettings.settings = new IrisSettings();
|
||||
IrisSettings.settings.getGui().setUseServerLaunchedGuis(true);
|
||||
GuiHost.suppressDesktop(true);
|
||||
sender = new RecordingSender();
|
||||
command = new TestCommand(sender);
|
||||
}
|
||||
|
||||
@After
|
||||
public void restore() {
|
||||
IrisSettings.settings = previousSettings;
|
||||
GuiHost.suppressDesktop(previousSuppressed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapReportsMissingDisplayBeforeAccessingWorld() {
|
||||
command.map(null);
|
||||
|
||||
assertDisplayMessage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void imageMapReportsMissingDisplayInsteadOfDisabledSetting() {
|
||||
command.imagemap(null);
|
||||
|
||||
assertDisplayMessage();
|
||||
}
|
||||
|
||||
private void assertDisplayMessage() {
|
||||
assertEquals(1, sender.messages.size());
|
||||
assertTrue(sender.messages.getFirst(), sender.messages.getFirst().contains("display"));
|
||||
}
|
||||
|
||||
private static final class TestCommand extends CommandStudio {
|
||||
private final VolmitSender sender;
|
||||
|
||||
private TestCommand(VolmitSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolmitSender sender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RecordingSender extends VolmitSender {
|
||||
private final List<String> messages = new ArrayList<>();
|
||||
|
||||
private RecordingSender() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
package art.arcane.iris.command;
|
||||
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.platform.bukkit.plugin.VolmitSender;
|
||||
import art.arcane.iris.platform.generation.PlatformChunkGenerator;
|
||||
import art.arcane.iris.studio.map.MapWindow;
|
||||
import art.arcane.iris.studio.map.PaletteExplorerStart;
|
||||
import art.arcane.iris.studio.view.GuiHost;
|
||||
import art.arcane.iris.world.IrisToolbelt;
|
||||
import art.arcane.iris.world.task.J;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class StudioMapPositionTest {
|
||||
@Test
|
||||
public void mapCapturesItsStartingPositionOnThePlayerScheduler() {
|
||||
IrisSettings previous = IrisSettings.settings;
|
||||
IrisSettings.settings = new IrisSettings();
|
||||
IrisSettings.settings.getGui().setUseServerLaunchedGuis(true);
|
||||
World world = mock(World.class);
|
||||
Player player = mock(Player.class);
|
||||
VolmitSender sender = mock(VolmitSender.class);
|
||||
PlatformChunkGenerator generator = mock(PlatformChunkGenerator.class);
|
||||
Engine engine = mock(Engine.class);
|
||||
UUID playerId = UUID.randomUUID();
|
||||
UUID worldId = UUID.randomUUID();
|
||||
AtomicBoolean owned = new AtomicBoolean();
|
||||
AtomicReference<Runnable> task = new AtomicReference<>();
|
||||
AtomicReference<PaletteExplorerStart> start = new AtomicReference<>();
|
||||
when(world.getUID()).thenReturn(worldId);
|
||||
when(player.getUniqueId()).thenReturn(playerId);
|
||||
when(player.isOnline()).thenReturn(true);
|
||||
when(player.getWorld()).thenAnswer(invocation -> {
|
||||
assertTrue("world read must use the player scheduler", owned.get());
|
||||
return world;
|
||||
});
|
||||
when(player.getLocation()).thenAnswer(invocation -> {
|
||||
assertTrue("location read must use the player scheduler", owned.get());
|
||||
return new Location(world, 33.25D, 91D, -72.5D);
|
||||
});
|
||||
when(sender.isPlayer()).thenReturn(true);
|
||||
when(sender.player()).thenReturn(player);
|
||||
when(generator.getEngine()).thenReturn(engine);
|
||||
CommandStudio command = new CommandStudio() {
|
||||
@Override
|
||||
public VolmitSender sender() {
|
||||
return sender;
|
||||
}
|
||||
};
|
||||
try (MockedStatic<GuiHost> host = mockStatic(GuiHost.class);
|
||||
MockedStatic<IrisToolbelt> toolbelt = mockStatic(IrisToolbelt.class);
|
||||
MockedStatic<J> scheduling = mockStatic(J.class);
|
||||
MockedStatic<MapWindow> windows = mockStatic(MapWindow.class)) {
|
||||
host.when(GuiHost::isAvailable).thenReturn(true);
|
||||
toolbelt.when(() -> IrisToolbelt.isIrisWorld(world)).thenReturn(true);
|
||||
toolbelt.when(() -> IrisToolbelt.access(world)).thenReturn(generator);
|
||||
scheduling.when(() -> J.runEntity(same(player), any(Runnable.class), eq(0), any(Runnable.class)))
|
||||
.thenAnswer(invocation -> {
|
||||
task.set(invocation.getArgument(1));
|
||||
return true;
|
||||
});
|
||||
windows.when(() -> MapWindow.openMap(any(PaletteExplorerStart.class))).thenAnswer(invocation -> {
|
||||
start.set(invocation.getArgument(0));
|
||||
return null;
|
||||
});
|
||||
|
||||
command.map(world);
|
||||
assertNull(start.get());
|
||||
owned.set(true);
|
||||
task.get().run();
|
||||
|
||||
assertEquals(engine, start.get().engine());
|
||||
assertEquals(playerId, start.get().playerId());
|
||||
assertEquals(worldId, start.get().worldId());
|
||||
assertEquals(33.25D, start.get().centerX(), 0D);
|
||||
assertEquals(-72.5D, start.get().centerZ(), 0D);
|
||||
} finally {
|
||||
IrisSettings.settings = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeEntityBehavior;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeStateMerger;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.ModdedServerAccess;
|
||||
|
||||
import art.arcane.iris.studio.app.StudioAppInstaller;
|
||||
import art.arcane.iris.studio.view.GuiHost;
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.generation.decoration.DecoratorPlatformHooks;
|
||||
@@ -492,6 +493,7 @@ public final class ModdedEngineBootstrap {
|
||||
GuiHost.Provider previousGuiHost = GuiHost.get();
|
||||
ModdedGuiHost.install();
|
||||
rollback.add(() -> GuiHost.set(previousGuiHost));
|
||||
StudioAppInstaller.installInBackground();
|
||||
|
||||
ModdedDecoratorHooks decoratorHooks = new ModdedDecoratorHooks();
|
||||
DecoratorPlatformHooks.Bindings previousDecoratorBindings = DecoratorPlatformHooks.bind(decoratorHooks, decoratorHooks);
|
||||
|
||||
+5
-3
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.BiomeEnvironment;
|
||||
@@ -223,17 +224,18 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
||||
}
|
||||
|
||||
private void applyEffects(NativeWorld level, NativeProtocolPlayer player, Iterable<IrisEffect> effects) {
|
||||
PackRuntime runtime = PackRuntime.of(getEngine());
|
||||
for (IrisEffect effect : effects) {
|
||||
try {
|
||||
applyEffect(level, player, effect);
|
||||
applyEffect(level, player, effect, runtime);
|
||||
} catch (Throwable error) {
|
||||
IrisLogging.reportError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyEffect(NativeWorld level, NativeProtocolPlayer player, IrisEffect effect) {
|
||||
if (!effect.shouldApplyNow()) {
|
||||
private void applyEffect(NativeWorld level, NativeProtocolPlayer player, IrisEffect effect, PackRuntime runtime) {
|
||||
if (!effect.shouldApplyNow(runtime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisSurface;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
@@ -127,7 +128,7 @@ public final class ModdedEntitySpawner {
|
||||
|
||||
entity.configureAnimal(irisEntity);
|
||||
|
||||
applySpawnEffect(irisEntity.getSpawnEffect(), entity, level);
|
||||
applySpawnEffect(irisEntity.getSpawnEffect(), entity, level, PackRuntime.of(engine));
|
||||
ModdedEntityCommandRunner.run(irisEntity.getRawCommands(), level.world(), blockX, blockY, blockZ);
|
||||
if (riseEffectActive && entity.living()) {
|
||||
startRiseEffect(engine, level, entity);
|
||||
@@ -200,8 +201,9 @@ public final class ModdedEntitySpawner {
|
||||
return level.chunksSafe(chunkX, chunkZ);
|
||||
}
|
||||
|
||||
private static void applySpawnEffect(IrisEffect effect, NativeSpawnedEntity entity, NativeEntityRuntime level) {
|
||||
if (effect == null || !effect.shouldApplyNow()) {
|
||||
private static void applySpawnEffect(IrisEffect effect, NativeSpawnedEntity entity, NativeEntityRuntime level,
|
||||
PackRuntime runtime) {
|
||||
if (effect == null || !effect.shouldApplyNow(runtime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import art.arcane.iris.world.loot.IrisLootTable;
|
||||
import art.arcane.iris.structure.object.IrisObjectLoot;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectVanillaLoot;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
@@ -40,6 +41,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class ModdedLootApplier {
|
||||
private static final String LOOT_TABLE_KEY_KIND = "missing-loot-table";
|
||||
private static final String VANILLA_LOOT_TABLE_KEY_KIND = "missing-vanilla-loot-table";
|
||||
|
||||
private ModdedLootApplier() {
|
||||
}
|
||||
|
||||
@@ -117,7 +121,8 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
IrisLootTable table = engine.getData().getLootLoader().load(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
||||
IrisLogging.warnOnce(IrisData.onceKey(engine.getData(), LOOT_TABLE_KEY_KIND, loot.getName()),
|
||||
"Couldn't find loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
bucket(engine, loot, new Candidate(new IrisLootSource(table), loot.getWeight()), access, exact, basic, global);
|
||||
@@ -129,7 +134,8 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
NativeContainerLoot.Table table = access.table(loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find vanilla loot table " + loot.getName());
|
||||
IrisLogging.warnOnce(IrisData.onceKey(engine.getData(), VANILLA_LOOT_TABLE_KEY_KIND, loot.getName()),
|
||||
"Couldn't find vanilla loot table " + loot.getName());
|
||||
continue;
|
||||
}
|
||||
bucket(engine, loot, new Candidate(new NativeLootSource(table), loot.getWeight()), access, exact, basic, global);
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStagePolicy;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.mantle.DeferredPlacementRecords;
|
||||
@@ -151,7 +152,7 @@ final class ModdedNativeStructurePolicy implements NativeModdedStructureStage.Po
|
||||
|
||||
@Override
|
||||
public NativeBlockState paletteBlock(StructurePalette source, RNG rng, int x, int y, int z) {
|
||||
return ((IrisMaterialPalette) source).get(rng, x, y, z, generator.engine().getData());
|
||||
return ((IrisMaterialPalette) source).get(rng, x, y, z, PackRuntime.of(generator.engine()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-7
@@ -20,18 +20,18 @@ package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.pack.loading.ResourceLoader;
|
||||
import art.arcane.iris.pack.loading.SnippetFolder;
|
||||
import art.arcane.iris.pack.schema.SchemaBuilder;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.world.task.J;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.io.IO;
|
||||
import art.arcane.volmlib.util.json.JSONArray;
|
||||
import art.arcane.volmlib.util.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public final class ModdedWorkspaceGenerator {
|
||||
private ModdedWorkspaceGenerator() {
|
||||
@@ -100,11 +100,7 @@ public final class ModdedWorkspaceGenerator {
|
||||
try {
|
||||
String snipType = snippetClass.getDeclaredAnnotation(Snippet.class).value();
|
||||
JSONObject entry = new JSONObject();
|
||||
KList<String> fileMatch = new KList<>();
|
||||
|
||||
for (int depth = 1; depth < 8; depth++) {
|
||||
fileMatch.add("/snippet/" + snipType + Form.repeat("/*", depth) + ".json");
|
||||
}
|
||||
List<String> fileMatch = new SnippetFolder(snipType).workspaceFileMatches();
|
||||
|
||||
entry.put("fileMatch", new JSONArray(fileMatch.toArray()));
|
||||
entry.put("url", "./.iris/schema/snippet/" + snipType + "-schema.json");
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeCommandSource;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockPoint;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeEditPlayer;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import art.arcane.iris.studio.workspace.FileOpener;
|
||||
import java.io.File;
|
||||
|
||||
final class ModdedEditCommands {
|
||||
@@ -110,7 +110,7 @@ final class ModdedEditCommands {
|
||||
}
|
||||
|
||||
private static int openJson(NativeCommandSource source, IrisRegistrant registrant) {
|
||||
if (!GuiHost.isAvailable() || !Desktop.isDesktopSupported()) {
|
||||
if (!GuiHost.isAvailable() || !FileOpener.isDesktopAvailable()) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_CANNOT_OPEN_FILES_HERE, MessageArgument.untrusted("value", ModdedGuiHost.guiUnavailableReason())));
|
||||
return 0;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ final class ModdedEditCommands {
|
||||
}
|
||||
File file = registrant.getLoadFile();
|
||||
try {
|
||||
Desktop.getDesktop().open(file);
|
||||
FileOpener.open(file);
|
||||
} catch (Throwable e) {
|
||||
ModdedIrisLog.error("Iris edit failed to open {}", file, e);
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.IRIS_MODDED_COMMANDS_COULD_NOT_OPEN, MessageArgument.untrusted("value", file.getName()), MessageArgument.untrusted("value2", e.getClass().getSimpleName())));
|
||||
|
||||
+56
-65
@@ -23,8 +23,11 @@ import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeWorldView;
|
||||
|
||||
import art.arcane.iris.modded.ModdedIrisLog;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.studio.map.MapWindow;
|
||||
import art.arcane.iris.studio.map.PaletteExplorerStart;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.studio.bridge.StudioBridge;
|
||||
import art.arcane.iris.studio.bridge.StudioBridges;
|
||||
import art.arcane.iris.studio.bridge.StudioLaunch;
|
||||
import art.arcane.iris.studio.bridge.StudioWindow;
|
||||
import art.arcane.iris.studio.view.GuiHost;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.pack.StructurePackageClosure;
|
||||
@@ -74,7 +77,7 @@ import art.arcane.volmlib.nativelib.terrain.NativeWorld;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeProtocolPlayer;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import art.arcane.iris.studio.workspace.FileOpener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -93,6 +96,9 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import art.arcane.iris.localization.IrisLanguage;
|
||||
import art.arcane.iris.localization.RuntimeUiMessages;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeCommandText;
|
||||
import art.arcane.volmlib.nativelib.minecraft26_2.modded.NativeCommandText.Format;
|
||||
import art.arcane.iris.modded.localization.ModdedCommandMessages;
|
||||
import art.arcane.volmlib.util.localization.LanguageAudience;
|
||||
import art.arcane.volmlib.util.localization.MessageArgument;
|
||||
@@ -226,11 +232,7 @@ public final class ModdedStudioCommands {
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> noiseTree(String name) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> noise(context.getSource(), null, 12345L)))
|
||||
.then(NativeCommandRegistration.argument("generator", StringArgumentType.word()).suggests(GENERATOR_KEYS)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> noise(context.getSource(), StringArgumentType.getString(context, "generator"), 12345L)))
|
||||
.then(NativeCommandRegistration.argument("seed", LongArgumentType.longArg())
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> noise(context.getSource(), StringArgumentType.getString(context, "generator"), LongArgumentType.getLong(context, "seed"))))));
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> noise(context.getSource())));
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> mapTree(String name) {
|
||||
@@ -243,88 +245,77 @@ public final class ModdedStudioCommands {
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> imageMap(context.getSource())));
|
||||
}
|
||||
|
||||
private static int noise(NativeCommandSource source, String generatorKey, long seed) {
|
||||
NativeWorld level = source.world();
|
||||
Engine engine = IrisModdedCommands.engineFor(level);
|
||||
if (!GuiHost.isAvailable() || !IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
|
||||
IrisModdedCommands.fail(source, guiUnavailableMessage());
|
||||
return 0;
|
||||
}
|
||||
if (engine != null) {
|
||||
NativeProtocolPlayer player = source.player();
|
||||
ModdedGuiHost.bindContext(worldView(source.server(), level), engine, player == null ? null : player.id());
|
||||
}
|
||||
Engine mapEngine = engine != null ? engine : GuiHost.get().findActiveEngine();
|
||||
if ((generatorKey == null || generatorKey.isBlank()) && mapEngine != null) {
|
||||
MapWindow.openNoise(mapStart(mapEngine, source.player()), new MapWindow.NoiseSelection(null, null, seed));
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_NOISE_EXPLORER_ON_SERVER_DISPLAY));
|
||||
return 1;
|
||||
}
|
||||
private static int noise(NativeCommandSource source) {
|
||||
Engine engine = IrisModdedCommands.engineFor(source.world());
|
||||
if (engine == null) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_THIS_DIMENSION_IS_NOT_GENERATED_BY_IRIS_RUN_IRIS_STUDIO));
|
||||
return 0;
|
||||
}
|
||||
IrisGenerator generator = engine.getData().getGeneratorLoader().load(generatorKey.trim());
|
||||
if (generator == null) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_UNKNOWN_GENERATOR_PACK, MessageArgument.untrusted("generatorKey", generatorKey), MessageArgument.untrusted("value", engine.getDimension().getLoadKey())));
|
||||
return 0;
|
||||
}
|
||||
String selectedGeneratorKey = generatorKey.trim();
|
||||
MapWindow.openNoise(mapStart(engine, source.player()), new MapWindow.NoiseSelection(selectedGeneratorKey, generator, seed));
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_NOISE_EXPLORER_GENERATOR_SEED, MessageArgument.untrusted("value", generatorKey.trim()), MessageArgument.untrusted("seed", seed)));
|
||||
return 1;
|
||||
return openStudioApp(source, engine, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_NOISE_EXPLORER_ON_SERVER_DISPLAY));
|
||||
}
|
||||
|
||||
private static int map(NativeCommandSource source) {
|
||||
NativeWorld level = source.world();
|
||||
Engine engine = IrisModdedCommands.engineFor(level);
|
||||
Engine engine = IrisModdedCommands.engineFor(source.world());
|
||||
if (engine == null) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_THIS_DIMENSION_IS_NOT_GENERATED_BY_IRIS_STAND_IRIS_STUDIO));
|
||||
return 0;
|
||||
}
|
||||
if (!GuiHost.isAvailable() || !IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
|
||||
IrisModdedCommands.fail(source, guiUnavailableMessage());
|
||||
return 0;
|
||||
}
|
||||
NativeProtocolPlayer player = source.player();
|
||||
ModdedGuiHost.bindContext(worldView(source.server(), level), engine, player == null ? null : player.id());
|
||||
MapWindow.openMap(mapStart(engine, player));
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_VISION_MAP_ON_SERVER_DISPLAY, MessageArgument.untrusted("value", level.name())));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Modded worlds have no Bukkit world id; the map finds the engine again through the bound GUI context.
|
||||
private static PaletteExplorerStart mapStart(Engine engine, NativeProtocolPlayer player) {
|
||||
IrisWorld world = engine.getWorld();
|
||||
NativeWorld level = world == null ? null : world.platformWorld();
|
||||
boolean inWorld = player != null && player.connected() && level != null && player.inWorld(level);
|
||||
return new PaletteExplorerStart(engine, null, player == null ? null : player.id(), null,
|
||||
inWorld ? player.x() : 0D, inWorld ? player.z() : 0D);
|
||||
return openStudioApp(source, engine, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_VISION_MAP_ON_SERVER_DISPLAY, MessageArgument.untrusted("value", source.world().name())));
|
||||
}
|
||||
|
||||
private static int imageMap(NativeCommandSource source) {
|
||||
NativeWorld level = source.world();
|
||||
Engine engine = IrisModdedCommands.engineFor(level);
|
||||
Engine engine = IrisModdedCommands.engineFor(source.world());
|
||||
if (engine == null) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(
|
||||
ModdedCommandMessages.MODDED_STUDIO_COMMANDS_IMAGE_MAP_REQUIRES_IRIS_DIMENSION
|
||||
));
|
||||
return 0;
|
||||
}
|
||||
if (!GuiHost.isAvailable() || !IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
|
||||
return openStudioApp(source, engine, IrisLanguage.plain(
|
||||
ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_IMAGE_MAP_STUDIO_ON_SERVER_DISPLAY,
|
||||
MessageArgument.untrusted("value", source.world().name())
|
||||
));
|
||||
}
|
||||
|
||||
/** Opens the studio app on the source's world; when it can't, tells the source why and hands over the link to connect by hand. */
|
||||
private static int openStudioApp(NativeCommandSource source, Engine engine, String openedMessage) {
|
||||
if (GuiHost.isDesktopSuppressed()) {
|
||||
IrisModdedCommands.fail(source, guiUnavailableMessage());
|
||||
return 0;
|
||||
}
|
||||
NativeWorld level = source.world();
|
||||
NativeProtocolPlayer player = source.player();
|
||||
ModdedGuiHost.bindContext(worldView(source.server(), level), engine, player == null ? null : player.id());
|
||||
MapWindow.openImageMaps(mapStart(engine, player));
|
||||
IrisModdedCommands.ok(source, IrisLanguage.plain(
|
||||
ModdedCommandMessages.MODDED_STUDIO_COMMANDS_OPENING_IMAGE_MAP_STUDIO_ON_SERVER_DISPLAY,
|
||||
MessageArgument.untrusted("value", level.name())
|
||||
));
|
||||
UUID openerId = player == null ? null : player.id();
|
||||
ModdedGuiHost.bindContext(worldView(source.server(), level), engine, openerId);
|
||||
StudioBridge bridge;
|
||||
try {
|
||||
bridge = StudioBridges.open(level.name(), () -> engine, openerId);
|
||||
} catch (IOException error) {
|
||||
IrisModdedCommands.fail(source, "Could not open the studio bridge: " + error.getMessage());
|
||||
return 0;
|
||||
}
|
||||
StudioLaunch launch = StudioWindow.show(bridge);
|
||||
if (!launch.opened()) {
|
||||
IrisLogging.info("Iris Studio link for %s: %s", level.name(), bridge.link());
|
||||
sendStudioLink(source, launch, bridge.link());
|
||||
return 0;
|
||||
}
|
||||
IrisModdedCommands.ok(source, openedMessage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static void sendStudioLink(NativeCommandSource source, StudioLaunch launch, String link) {
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(launch.failureMessage()));
|
||||
if (source.player() == null) {
|
||||
return;
|
||||
}
|
||||
NativeCommandText hover = NativeCommandText.literal(IrisLanguage.plain(RuntimeUiMessages.STUDIO_LINK_COPY_HOVER));
|
||||
NativeCommandText button = NativeCommandText.literal(IrisLanguage.plain(RuntimeUiMessages.STUDIO_LINK_COPY_BUTTON))
|
||||
.withStyle(Format.GREEN)
|
||||
.withStyle(style -> style.copyToClipboard(link).hover(hover));
|
||||
IrisModdedCommands.ok(source, button);
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<NativeCommandSource> workspaceTree(String name, boolean open) {
|
||||
return NativeCommandRegistration.literal(name)
|
||||
.executes(ModdedCommandTree.localized((CommandContext<NativeCommandSource> context) -> workspace(context.getSource(), null, open)))
|
||||
@@ -349,12 +340,12 @@ public final class ModdedStudioCommands {
|
||||
if (!open) {
|
||||
return 1;
|
||||
}
|
||||
if (!GuiHost.isAvailable() || !Desktop.isDesktopSupported()) {
|
||||
if (!GuiHost.isAvailable() || !FileOpener.isDesktopAvailable()) {
|
||||
IrisModdedCommands.fail(source, guiUnavailableMessage());
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
Desktop.getDesktop().open(workspace);
|
||||
FileOpener.open(workspace);
|
||||
} catch (Throwable e) {
|
||||
ModdedIrisLog.error("Iris workspace open failed for {}", workspace, e);
|
||||
IrisModdedCommands.fail(source, IrisLanguage.plain(ModdedCommandMessages.MODDED_STUDIO_COMMANDS_COULD_NOT_OPEN, MessageArgument.untrusted("value", workspace.getName()), MessageArgument.untrusted("value2", e.getClass().getSimpleName())));
|
||||
|
||||
@@ -190,6 +190,63 @@ def generateNoiseNatives = tasks.register('generateNoiseNatives') {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The studio app ships inside the Bukkit jar. The Electron build it runs on is 100+ MB per platform, so it stays out
|
||||
// and is pinned instead: StudioAppInstaller downloads the host's archive from Electron's release at startup and
|
||||
// checks it against these checksums.
|
||||
File studioAppDirectory = file('studio')
|
||||
List<String> electronPlatforms = ['linux-x64', 'linux-arm64', 'win32-x64', 'win32-arm64', 'darwin-x64', 'darwin-arm64']
|
||||
Provider<String> electronVersion = providers.fileContents(layout.projectDirectory.file('studio/package-lock.json')).asText.map { String lock ->
|
||||
(String) ((Map) ((Map) new groovy.json.JsonSlurper().parseText(lock)).packages).get('node_modules/electron').version
|
||||
}
|
||||
List<String> npmCommand = System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('win') ? ['cmd', '/c', 'npm'] : ['npm']
|
||||
def installStudioDependencies = tasks.register('installStudioDependencies', Exec) {
|
||||
inputs.files('studio/package.json', 'studio/package-lock.json')
|
||||
outputs.file('studio/node_modules/.package-lock.json')
|
||||
workingDir(studioAppDirectory)
|
||||
commandLine(npmCommand + ['ci', '--no-audit', '--no-fund'])
|
||||
}
|
||||
def buildStudioApp = tasks.register('buildStudioApp', Exec) {
|
||||
dependsOn(installStudioDependencies)
|
||||
inputs.dir('studio/src')
|
||||
inputs.files('studio/package.json', 'studio/package-lock.json', 'studio/electron.vite.config.ts', 'studio/tsconfig.json', 'studio/components.json')
|
||||
outputs.dir('studio/out')
|
||||
workingDir(studioAppDirectory)
|
||||
commandLine(npmCommand + ['run', 'build'])
|
||||
}
|
||||
def bundleStudioApp = tasks.register('bundleStudioApp', Zip) {
|
||||
from(buildStudioApp) {
|
||||
into('out')
|
||||
}
|
||||
from('studio/package.json')
|
||||
archiveFileName.set('studio-app.zip')
|
||||
destinationDirectory.set(layout.buildDirectory.dir('generated/studio-app'))
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
def pinElectronRuntime = tasks.register('pinElectronRuntime') {
|
||||
inputs.property('electronVersion', electronVersion)
|
||||
inputs.property('platforms', electronPlatforms)
|
||||
def pins = layout.buildDirectory.file('generated/studio-app-pins/studio-app.properties')
|
||||
outputs.file(pins)
|
||||
doLast {
|
||||
String version = electronVersion.get()
|
||||
String checksums = URI.create("https://github.com/electron/electron/releases/download/v${version}/SHASUMS256.txt")
|
||||
.toURL().getText('UTF-8')
|
||||
Map<String, String> checksumByArchive = checksums.readLines().collectEntries { String line ->
|
||||
def match = line.trim() =~ /^([0-9a-f]{64}) \*?(\S+)$/
|
||||
match.matches() ? [(match.group(2)): match.group(1)] : [:]
|
||||
}
|
||||
List<String> lines = ["electron.version=${version}".toString()]
|
||||
electronPlatforms.each { String platform ->
|
||||
String checksum = checksumByArchive.get("electron-v${version}-${platform}.zip".toString())
|
||||
if (checksum == null) {
|
||||
throw new GradleException("Electron ${version} publishes no ${platform} archive")
|
||||
}
|
||||
lines.add("${platform}.sha256=${checksum}".toString())
|
||||
}
|
||||
pins.get().asFile.setText(lines.join('\n') + '\n', 'UTF-8')
|
||||
}
|
||||
}
|
||||
def jarJar = configurations.create('jarJar')
|
||||
dependencies {
|
||||
add('included', project(path: ':core', configuration: 'shadow'))
|
||||
@@ -208,6 +265,12 @@ tasks.named('jar', Jar).configure {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
includeEmptyDirs = false
|
||||
from(jarJar)
|
||||
from(bundleStudioApp) {
|
||||
into('META-INF/iris')
|
||||
}
|
||||
from(pinElectronRuntime) {
|
||||
into('META-INF/iris')
|
||||
}
|
||||
from(provider { included.resolve().collect { zipTree(it) } }) {
|
||||
exclude('META-INF/INDEX.LIST')
|
||||
exclude('languages/**')
|
||||
@@ -529,6 +592,8 @@ List<String> requiredBukkitArtifactEntries = [
|
||||
'slimjar-resolutions.dat',
|
||||
'META-INF/iris/native-runtime.properties',
|
||||
NoiseNativeArtifacts.MANIFEST,
|
||||
'META-INF/iris/studio-app.zip',
|
||||
'META-INF/iris/studio-app.properties',
|
||||
'META-INF/volmit/volmlib.properties',
|
||||
'iris-language-source.properties',
|
||||
'agent.jar',
|
||||
|
||||
+1
-1
@@ -482,7 +482,7 @@ List<String> dependencyBuildMetadata = [
|
||||
'META-INF/versions/*/OSGI-INF/**'
|
||||
]
|
||||
|
||||
String languageTomlSupportClassPattern = 'art/arcane/volmlib/util/config/(?:TomlCodec|ConfigJson|ConfigExposePolicy|ConfigDoc|ConfigDescription|ConfigDocumentation)(?:\\$[^/]+)?\\.class'
|
||||
String languageTomlSupportClassPattern = 'art/arcane/volmlib/util/config/(?:TomlCodec|TomlSegments|ConfigComments|ConfigJson|ConfigExposePolicy|ConfigDoc|ConfigDescription|ConfigDocumentation)(?:\\$[^/]+)?\\.class'
|
||||
|
||||
tasks.named('shadowJar', ShadowJar).configure {
|
||||
inputs.property('languageTomlSupportClassPattern', languageTomlSupportClassPattern)
|
||||
|
||||
+64
@@ -28,6 +28,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -35,6 +36,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -196,6 +198,68 @@ public class CraftEngineDataProviderTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decayingCustomLeavesAreMadePersistentAndKeepTheirCustomIdentity() {
|
||||
BooleanProperty persistent = BooleanProperty.create("persistent", false);
|
||||
BlockDefinition definition = mock(BlockDefinition.class);
|
||||
ImmutableBlockState decaying = blockState(definition, "test:leaves[persistent=false]");
|
||||
ImmutableBlockState kept = blockState(definition, "test:leaves[persistent=true]");
|
||||
BlockData base = mock(BlockData.class);
|
||||
BlockData keptBase = mock(BlockData.class);
|
||||
doReturn(persistent).when(decaying).getProperty("persistent");
|
||||
doReturn(false).when(decaying).get(persistent);
|
||||
when(decaying.with(persistent, true)).thenReturn(kept);
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(base)).thenReturn(decaying);
|
||||
blocks.when(() -> CraftEngineBlocks.getBukkitBlockData(kept)).thenReturn(keptBase);
|
||||
|
||||
IrisCustomData result = (IrisCustomData) new CraftEngineDataProvider()
|
||||
.withoutDecay(IrisCustomData.of(base, new Identifier("craftengine", "test/leaves[persistent=false]")));
|
||||
|
||||
assertSame(keptBase, result.getBase());
|
||||
assertEquals(new Identifier("test", "leaves[persistent=true]"), result.getCustom());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistentOrDecaylessCustomBlocksAreKeptAsTheyAre() {
|
||||
BooleanProperty persistent = BooleanProperty.create("persistent", false);
|
||||
BlockDefinition definition = mock(BlockDefinition.class);
|
||||
ImmutableBlockState alreadyPersistent = blockState(definition, "test:leaves[persistent=true]");
|
||||
ImmutableBlockState withoutProperty = blockState(definition, "test:log");
|
||||
BlockData persistentData = mock(BlockData.class);
|
||||
BlockData logData = mock(BlockData.class);
|
||||
BlockData vanilla = mock(BlockData.class);
|
||||
doReturn(persistent).when(alreadyPersistent).getProperty("persistent");
|
||||
doReturn(true).when(alreadyPersistent).get(persistent);
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(persistentData)).thenReturn(alreadyPersistent);
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(logData)).thenReturn(withoutProperty);
|
||||
CraftEngineDataProvider provider = new CraftEngineDataProvider();
|
||||
|
||||
assertSame(persistentData, provider.withoutDecay(persistentData));
|
||||
assertSame(logData, provider.withoutDecay(logData));
|
||||
assertSame(vanilla, provider.withoutDecay(vanilla));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customBlocksCarryTheTagsTheirSettingsListEvenWhenWrapped() {
|
||||
ImmutableBlockState state = mock(ImmutableBlockState.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
BlockData base = mock(BlockData.class);
|
||||
BlockData vanilla = mock(BlockData.class);
|
||||
when(state.settings().tags()).thenReturn(Set.of(Key.of("minecraft:logs")));
|
||||
try (MockedStatic<CraftEngineBlocks> blocks = mockStatic(CraftEngineBlocks.class)) {
|
||||
blocks.when(() -> CraftEngineBlocks.getCustomBlockState(base)).thenReturn(state);
|
||||
CraftEngineDataProvider provider = new CraftEngineDataProvider();
|
||||
BlockData wrapped = IrisCustomData.of(base, new Identifier("craftengine", "test/log"));
|
||||
|
||||
assertTrue(provider.hasBlockTag(wrapped, NamespacedKey.minecraft("logs")));
|
||||
assertFalse(provider.hasBlockTag(wrapped, NamespacedKey.minecraft("leaves")));
|
||||
assertFalse(provider.hasBlockTag(vanilla, NamespacedKey.minecraft("logs")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownOrInvalidBlockPropertiesFailBeforeNativeConversion() {
|
||||
Identifier id = new Identifier("test", "lamp");
|
||||
|
||||
@@ -404,6 +404,9 @@ public class IrisSettings {
|
||||
public boolean disableTimeAndWeather = true;
|
||||
public boolean entitySpawning = true;
|
||||
public boolean autoStartDefaultStudio = false;
|
||||
public boolean downloadApp = true;
|
||||
public String studioApp = "";
|
||||
public String electron = "electron";
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.bake;
|
||||
|
||||
import art.arcane.iris.generation.runtime.ThreadSlots;
|
||||
import art.arcane.iris.generation.cache.ConcurrentClockCache;
|
||||
import art.arcane.iris.generation.stream.ProvisionalSampling;
|
||||
|
||||
@@ -16,7 +17,7 @@ public final class ChunkBakeCache {
|
||||
|
||||
private final PlaneSource source;
|
||||
private final ConcurrentClockCache<ChunkPlanes> entries;
|
||||
private final ThreadLocal<Recent> recent = ThreadLocal.withInitial(Recent::new);
|
||||
private final ThreadSlots<Recent> recent = new ThreadSlots<>(Recent::new);
|
||||
private volatile int generation;
|
||||
|
||||
public ChunkBakeCache(PlaneSource source, int capacityChunks) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package art.arcane.iris.generation.bake;
|
||||
import art.arcane.iris.generation.noise.GeneratorProgram;
|
||||
import art.arcane.iris.generation.noise.IrisGenerator;
|
||||
import art.arcane.iris.generation.noise.TerrainBatchScratch;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -12,26 +13,28 @@ public final class TerrainProgram {
|
||||
private static final int CONSTANT = 1;
|
||||
private static final int ACTIVE = 2;
|
||||
|
||||
private final PackRuntime runtime;
|
||||
private final IrisGenerator[][] generators;
|
||||
private final GeneratorProgram[][] programs;
|
||||
private final long heightSeed;
|
||||
|
||||
private TerrainProgram(IrisGenerator[][] generators, GeneratorProgram[][] programs, long heightSeed) {
|
||||
private TerrainProgram(PackRuntime runtime, IrisGenerator[][] generators, GeneratorProgram[][] programs, long heightSeed) {
|
||||
this.runtime = runtime;
|
||||
this.generators = generators;
|
||||
this.programs = programs;
|
||||
this.heightSeed = heightSeed;
|
||||
}
|
||||
|
||||
public static TerrainProgram compile(IrisGenerator[][] generators, long heightSeed) {
|
||||
public static TerrainProgram compile(PackRuntime runtime, IrisGenerator[][] generators, long heightSeed) {
|
||||
GeneratorProgram[][] programs = new GeneratorProgram[generators.length][];
|
||||
for (int group = 0; group < generators.length; group++) {
|
||||
programs[group] = new GeneratorProgram[generators[group].length];
|
||||
for (int index = 0; index < generators[group].length; index++) {
|
||||
IrisGenerator generator = generators[group][index];
|
||||
programs[group][index] = generator.supportsBatch() ? generator.compileProgram(heightSeed) : null;
|
||||
programs[group][index] = generator.supportsBatch() ? generator.compileProgram(runtime, heightSeed) : null;
|
||||
}
|
||||
}
|
||||
return new TerrainProgram(generators, programs, heightSeed);
|
||||
return new TerrainProgram(runtime, generators, programs, heightSeed);
|
||||
}
|
||||
|
||||
public long heightSeed() {
|
||||
@@ -58,7 +61,7 @@ public final class TerrainProgram {
|
||||
GeneratorProgram[] compiled = programs[group];
|
||||
for (int member = 0; member < members.length; member++) {
|
||||
GeneratorProgram program = compiled[member];
|
||||
double noise = program != null ? program.height(scratch, x, z) : members[member].getHeight(x, z, heightSeed);
|
||||
double noise = program != null ? program.height(scratch, x, z) : members[member].getHeight(runtime, x, z, heightSeed);
|
||||
if (!Double.isFinite(noise)) {
|
||||
throw new IllegalStateException("Terrain generator noise was not finite at " + x + "," + z
|
||||
+ " (generator=" + members[member].getLoadKey() + ", noise=" + noise
|
||||
@@ -148,7 +151,7 @@ public final class TerrainProgram {
|
||||
program.heights(scratch, activeX, activeZ, activeCount, noise);
|
||||
} else {
|
||||
for (int index = 0; index < activeCount; index++) {
|
||||
noise[index] = members[member].getHeight(activeX[index], activeZ[index], heightSeed);
|
||||
noise[index] = members[member].getHeight(runtime, activeX[index], activeZ[index], heightSeed);
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < activeCount; index++) {
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
import art.arcane.iris.generation.decoration.DecoratorRuntime;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisBiome}: its scatter generators, the children generators per shrink
|
||||
* scale, the height generators of its layer palettes and the runtimes of those palettes, linked by layer index so
|
||||
* painting a column reads them without looking each layer up.
|
||||
*/
|
||||
public final class BiomeRuntime {
|
||||
private static final int BIOME_SEED_CAPACITY = 8;
|
||||
private static final int CHILD_SEED_CAPACITY = 8;
|
||||
private static final int LAYER_HEIGHT_SEED_CAPACITY = 32;
|
||||
private static final int SURFACE_LAYER_SEED_OFFSET = 7235;
|
||||
private static final int SEA_LAYER_SEED_OFFSET = 7735;
|
||||
private static final int CEILING_LAYER_SEED_OFFSET = 7235;
|
||||
|
||||
private final IrisBiome biome;
|
||||
private final PackRuntime runtime;
|
||||
private final SeedTable<CNG> biomeGenerators;
|
||||
private final ConcurrentHashMap<Long, SeedTable<CNG>> childGeneratorsByScale = new ConcurrentHashMap<>();
|
||||
private final SeedTable<KList<CNG>> layerHeights;
|
||||
private final SeedTable<KList<CNG>> seaLayerHeights;
|
||||
private final SeedTable<KList<CNG>> ceilingLayerHeights;
|
||||
private final LinkedLayers surfaceLayers;
|
||||
private final LinkedLayers seaLayers;
|
||||
private final LinkedLayers ceilingLayers;
|
||||
private final AtomicReferenceArray<LinkedDecorators> decoratorBuckets =
|
||||
new AtomicReferenceArray<>(IrisDecorationPart.values().length);
|
||||
|
||||
public BiomeRuntime(IrisBiome biome, PackRuntime runtime) {
|
||||
this.biome = biome;
|
||||
this.runtime = runtime;
|
||||
this.biomeGenerators = new SeedTable<>(BIOME_SEED_CAPACITY, seed -> biome.createBiomeGenerator(seed, runtime));
|
||||
this.layerHeights = new SeedTable<>(LAYER_HEIGHT_SEED_CAPACITY, seed ->
|
||||
IrisBiomeLayerGenerator.createHeightGenerators(biome.getLayers(), SURFACE_LAYER_SEED_OFFSET, seed, runtime));
|
||||
this.seaLayerHeights = new SeedTable<>(LAYER_HEIGHT_SEED_CAPACITY, seed ->
|
||||
IrisBiomeLayerGenerator.createHeightGenerators(biome.getSeaLayers(), SEA_LAYER_SEED_OFFSET, seed, runtime));
|
||||
this.ceilingLayerHeights = new SeedTable<>(LAYER_HEIGHT_SEED_CAPACITY, seed ->
|
||||
IrisBiomeLayerGenerator.createHeightGenerators(biome.getCaveCeilingLayers(), CEILING_LAYER_SEED_OFFSET, seed, runtime));
|
||||
this.surfaceLayers = new LinkedLayers(biome::getLayers);
|
||||
this.seaLayers = new LinkedLayers(biome::getSeaLayers);
|
||||
this.ceilingLayers = new LinkedLayers(biome::getCaveCeilingLayers);
|
||||
}
|
||||
|
||||
public CNG biomeGenerator(long seed) {
|
||||
return biomeGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG childrenGenerator(long seed, double scale) {
|
||||
return childGeneratorsByScale.computeIfAbsent(Double.doubleToLongBits(scale), ignored ->
|
||||
new SeedTable<>(CHILD_SEED_CAPACITY, childSeed -> biome.createChildrenGenerator(childSeed, scale, runtime)))
|
||||
.get(seed);
|
||||
}
|
||||
|
||||
public KList<CNG> layerHeights(long seed) {
|
||||
return layerHeights.get(seed);
|
||||
}
|
||||
|
||||
public KList<CNG> seaLayerHeights(long seed) {
|
||||
return seaLayerHeights.get(seed);
|
||||
}
|
||||
|
||||
public KList<CNG> ceilingLayerHeights(long seed) {
|
||||
return ceilingLayerHeights.get(seed);
|
||||
}
|
||||
|
||||
/** The runtime of the surface layer at this index of {@link IrisBiome#getLayers()}. */
|
||||
public PaletteLayerRuntime surfaceLayer(int index) {
|
||||
return surfaceLayers.get(index);
|
||||
}
|
||||
|
||||
/** The runtime of the sea layer at this index of {@link IrisBiome#getSeaLayers()}. */
|
||||
public PaletteLayerRuntime seaLayer(int index) {
|
||||
return seaLayers.get(index);
|
||||
}
|
||||
|
||||
/** The runtime of the cave ceiling layer at this index of {@link IrisBiome#getCaveCeilingLayers()}. */
|
||||
public PaletteLayerRuntime ceilingLayer(int index) {
|
||||
return ceilingLayers.get(index);
|
||||
}
|
||||
|
||||
/** The runtimes of this part's {@link IrisBiome#getDecoratorBucket} decorators, in bucket order. */
|
||||
public DecoratorRuntime[] decorators(IrisDecorationPart part) {
|
||||
IrisDecorator[] bucket = biome.getDecoratorBucket(part);
|
||||
LinkedDecorators linked = decoratorBuckets.getAcquire(part.ordinal());
|
||||
if (linked != null && linked.bucket() == bucket) {
|
||||
return linked.runtimes();
|
||||
}
|
||||
DecoratorRuntime[] runtimes = new DecoratorRuntime[bucket.length];
|
||||
for (int index = 0; index < bucket.length; index++) {
|
||||
runtimes[index] = runtime.decorator(bucket[index]);
|
||||
}
|
||||
decoratorBuckets.setRelease(part.ordinal(), new LinkedDecorators(bucket, runtimes));
|
||||
return runtimes;
|
||||
}
|
||||
|
||||
private record LinkedDecorators(IrisDecorator[] bucket, DecoratorRuntime[] runtimes) {
|
||||
}
|
||||
|
||||
private final class LinkedLayers {
|
||||
private final Supplier<KList<IrisBiomePaletteLayer>> layers;
|
||||
private volatile PaletteLayerRuntime[] linked;
|
||||
|
||||
private LinkedLayers(Supplier<KList<IrisBiomePaletteLayer>> layers) {
|
||||
this.layers = layers;
|
||||
}
|
||||
|
||||
private PaletteLayerRuntime get(int index) {
|
||||
PaletteLayerRuntime[] current = linked;
|
||||
if (current == null) {
|
||||
current = link(layers.get());
|
||||
linked = current;
|
||||
}
|
||||
return current[index];
|
||||
}
|
||||
|
||||
private PaletteLayerRuntime[] link(KList<IrisBiomePaletteLayer> source) {
|
||||
PaletteLayerRuntime[] result = new PaletteLayerRuntime[source.size()];
|
||||
for (int index = 0; index < result.length; index++) {
|
||||
result[index] = runtime.paletteLayer(source.get(index));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfileSampler;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisFloatingChildBiomes} entry: its edge taper profile per base seed and the
|
||||
* cave profile sampler of the biome it carves with.
|
||||
*/
|
||||
public final class FloatingChildRuntime {
|
||||
private static final int EDGE_PROFILE_SEED_CAPACITY = 8;
|
||||
|
||||
private final IrisFloatingChildBiomes entry;
|
||||
private final PackRuntime runtime;
|
||||
private final SeedTable<FloatingIslandEdgeProfile> edgeProfiles;
|
||||
private volatile Optional<IrisCaveProfileSampler> carvingProfileSampler;
|
||||
|
||||
public FloatingChildRuntime(IrisFloatingChildBiomes entry, PackRuntime runtime) {
|
||||
this.entry = entry;
|
||||
this.runtime = runtime;
|
||||
this.edgeProfiles = new SeedTable<>(EDGE_PROFILE_SEED_CAPACITY, seed -> entry.createEdgeTaperProfile(seed, runtime));
|
||||
}
|
||||
|
||||
public FloatingIslandEdgeProfile edgeTaperProfile(long baseSeed) {
|
||||
return edgeProfiles.get(baseSeed);
|
||||
}
|
||||
|
||||
public IrisCaveProfileSampler carvingProfileSampler() {
|
||||
Optional<IrisCaveProfileSampler> resolved = carvingProfileSampler;
|
||||
if (resolved == null) {
|
||||
resolved = Optional.ofNullable(entry.createCarvingProfileSampler(runtime));
|
||||
carvingProfileSampler = resolved;
|
||||
}
|
||||
return resolved.orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* One worker's floating island samples for the chunk it is generating. A runtime scope keeps one per worker thread,
|
||||
* so the memo never outlives the engine that produced its samples.
|
||||
*/
|
||||
public final class FloatingIslandMemo {
|
||||
private static final int CHUNK_COLUMN_COUNT = 256;
|
||||
|
||||
private final HashMap<Long, MemoizedSample> samples = new HashMap<>(CHUNK_COLUMN_COUNT);
|
||||
private MemoContext context;
|
||||
|
||||
public void clear() {
|
||||
samples.clear();
|
||||
context = null;
|
||||
}
|
||||
|
||||
/** The memoized sample for this column and parent, which may itself be null; null when not sampled yet. */
|
||||
MemoizedSample find(IrisBiome parent, long column) {
|
||||
MemoizedSample cached = samples.get(column);
|
||||
return cached != null && cached.parent == parent ? cached : null;
|
||||
}
|
||||
|
||||
void remember(IrisBiome parent, long column, FloatingIslandSample sample) {
|
||||
samples.put(column, new MemoizedSample(parent, sample));
|
||||
}
|
||||
|
||||
void enterChunk(int chunkX, int chunkZ, int height, long seed, FloatingIslandBoundarySampler boundarySampler) {
|
||||
if (context != null && context.matches(chunkX, chunkZ, height, seed, boundarySampler)) {
|
||||
return;
|
||||
}
|
||||
samples.clear();
|
||||
context = new MemoContext(chunkX, chunkZ, height, seed, boundarySampler);
|
||||
}
|
||||
|
||||
private record MemoContext(int chunkX, int chunkZ, int height, long seed,
|
||||
FloatingIslandBoundarySampler boundarySampler) {
|
||||
private boolean matches(int chunkX, int chunkZ, int height, long seed,
|
||||
FloatingIslandBoundarySampler boundarySampler) {
|
||||
return this.chunkX == chunkX && this.chunkZ == chunkZ && this.height == height && this.seed == seed
|
||||
&& this.boundarySampler == boundarySampler;
|
||||
}
|
||||
}
|
||||
|
||||
record MemoizedSample(IrisBiome parent, FloatingIslandSample sample) {
|
||||
}
|
||||
}
|
||||
@@ -20,16 +20,12 @@ package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfileSampler;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public final class FloatingIslandSample {
|
||||
@@ -51,8 +47,6 @@ public final class FloatingIslandSample {
|
||||
private static final double CARVE_MAX_VERTICAL_RUN_FRACTION = 0.18D;
|
||||
private static final ThreadLocal<int[]> LAST_REJECT = ThreadLocal.withInitial(() -> new int[1]);
|
||||
private static final ThreadLocal<double[]> LAST_DENSITY = ThreadLocal.withInitial(() -> new double[2]);
|
||||
private static final ThreadLocal<ChunkMemo> CHUNK_MEMO = ThreadLocal.withInitial(ChunkMemo::new);
|
||||
private static final ThreadLocal<IdentityHashMap<CNG, Long2DoubleOpenHashMap>> FOOTPRINT_MEMO = ThreadLocal.withInitial(IdentityHashMap::new);
|
||||
private static final AtomicBoolean NULL_CNG_WARNED = new AtomicBoolean(false);
|
||||
|
||||
public static int getLastReject() {
|
||||
@@ -67,33 +61,20 @@ public final class FloatingIslandSample {
|
||||
return LAST_DENSITY.get()[1];
|
||||
}
|
||||
|
||||
public static void clearThreadCaches() {
|
||||
CHUNK_MEMO.remove();
|
||||
FOOTPRINT_MEMO.remove();
|
||||
LAST_REJECT.remove();
|
||||
LAST_DENSITY.remove();
|
||||
public static void clearChunkMemo(PackRuntime runtime) {
|
||||
runtime.floatingIslandMemo().clear();
|
||||
}
|
||||
|
||||
public static void clearChunkMemo() {
|
||||
CHUNK_MEMO.get().samples.clear();
|
||||
FOOTPRINT_MEMO.get().clear();
|
||||
}
|
||||
|
||||
public static FloatingIslandSample sampleMemoized(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) {
|
||||
long key = (((long) wx) << 32) ^ (wz & 0xFFFFFFFFL);
|
||||
ChunkMemo memo = CHUNK_MEMO.get();
|
||||
if (memo.context == null || !memo.context.matches(wx >> 4, wz >> 4, chunkHeight, baseSeed,
|
||||
data, engine, boundarySampler)) {
|
||||
memo.samples.clear();
|
||||
FOOTPRINT_MEMO.get().clear();
|
||||
memo.context = new MemoContext(wx >> 4, wz >> 4, chunkHeight, baseSeed, data, engine, boundarySampler);
|
||||
public static FloatingIslandSample sampleMemoized(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, PackRuntime runtime, FloatingIslandBoundarySampler boundarySampler) {
|
||||
long column = (((long) wx) << 32) ^ (wz & 0xFFFFFFFFL);
|
||||
FloatingIslandMemo memo = runtime.floatingIslandMemo();
|
||||
memo.enterChunk(wx >> 4, wz >> 4, chunkHeight, baseSeed, boundarySampler);
|
||||
FloatingIslandMemo.MemoizedSample cached = memo.find(parent, column);
|
||||
if (cached != null) {
|
||||
return cached.sample();
|
||||
}
|
||||
MemoizedSample cached = memo.samples.get(key);
|
||||
if (cached != null && cached.parent == parent) {
|
||||
return cached.sample;
|
||||
}
|
||||
FloatingIslandSample result = sample(parent, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler);
|
||||
memo.samples.put(key, new MemoizedSample(parent, result));
|
||||
FloatingIslandSample result = sample(parent, wx, wz, chunkHeight, baseSeed, runtime, boundarySampler);
|
||||
memo.remember(parent, column, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -184,18 +165,18 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
|
||||
private static int maximumEdgeFieldWidth(KList<IrisFloatingChildBiomes> entries, long baseSeed,
|
||||
IrisData data, IrisBiome parent) {
|
||||
PackRuntime runtime, IrisBiome parent) {
|
||||
int maximumWidth = FloatingIslandEdgeProfile.MIN_WIDTH;
|
||||
for (IrisFloatingChildBiomes entry : entries) {
|
||||
FloatingIslandEdgeProfile profile = resolveEdgeProfile(entry, baseSeed, data, parent);
|
||||
FloatingIslandEdgeProfile profile = resolveEdgeProfile(entry, baseSeed, runtime, parent);
|
||||
maximumWidth = Math.max(maximumWidth, profile.fieldWidth());
|
||||
}
|
||||
return maximumWidth;
|
||||
}
|
||||
|
||||
private static FloatingIslandEdgeProfile resolveEdgeProfile(IrisFloatingChildBiomes entry, long baseSeed,
|
||||
IrisData data, IrisBiome parent) {
|
||||
FloatingIslandEdgeProfile profile = entry.getEdgeTaperProfile(baseSeed, data);
|
||||
PackRuntime runtime, IrisBiome parent) {
|
||||
FloatingIslandEdgeProfile profile = entry.getEdgeTaperProfile(baseSeed, runtime);
|
||||
if (profile != null) {
|
||||
return profile;
|
||||
}
|
||||
@@ -203,17 +184,17 @@ public final class FloatingIslandSample {
|
||||
return FloatingIslandEdgeProfile.DEFAULT;
|
||||
}
|
||||
|
||||
public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, IrisData data, Engine engine, FloatingIslandBoundarySampler boundarySampler) {
|
||||
public static FloatingIslandSample sample(IrisBiome parent, int wx, int wz, int chunkHeight, long baseSeed, PackRuntime runtime, FloatingIslandBoundarySampler boundarySampler) {
|
||||
KList<IrisFloatingChildBiomes> entries = parent.getFloatingChildBiomes();
|
||||
if (entries == null || entries.isEmpty()) {
|
||||
return reject(REJECT_NO_ENTRIES);
|
||||
}
|
||||
|
||||
int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, data, parent);
|
||||
int boundaryFieldWidth = maximumEdgeFieldWidth(entries, baseSeed, runtime, parent);
|
||||
int parentBoundaryDistance = boundarySampler.edgeDistance(parent, wx, wz, boundaryFieldWidth);
|
||||
|
||||
if (parent.isMergeFloatingChildBiomes()) {
|
||||
return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
|
||||
return sampleMerged(parent, entries, wx, wz, chunkHeight, baseSeed, runtime, boundarySampler,
|
||||
parentBoundaryDistance, boundaryFieldWidth);
|
||||
}
|
||||
|
||||
@@ -223,7 +204,7 @@ public final class FloatingIslandSample {
|
||||
entry = entries.getFirst();
|
||||
} else {
|
||||
IrisFloatingChildBiomes reference = entries.getFirst();
|
||||
CNG picker = reference.getPickerCng(baseSeed, data);
|
||||
CNG picker = reference.getPickerCng(baseSeed, runtime);
|
||||
if (picker == null) {
|
||||
warnNullCng("pickerStyle", parent);
|
||||
return reject(REJECT_NO_PICK);
|
||||
@@ -237,20 +218,20 @@ public final class FloatingIslandSample {
|
||||
ownershipBoundaryDistance = ownership.boundaryDistance();
|
||||
}
|
||||
|
||||
return sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine, boundarySampler,
|
||||
return sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, runtime, boundarySampler,
|
||||
parentBoundaryDistance, ownershipBoundaryDistance);
|
||||
}
|
||||
|
||||
private static FloatingIslandSample sampleMerged(IrisBiome parent, KList<IrisFloatingChildBiomes> entries,
|
||||
int wx, int wz, int chunkHeight, long baseSeed, IrisData data,
|
||||
Engine engine, FloatingIslandBoundarySampler boundarySampler,
|
||||
int wx, int wz, int chunkHeight, long baseSeed, PackRuntime runtime,
|
||||
FloatingIslandBoundarySampler boundarySampler,
|
||||
int parentBoundaryDistance, int boundaryFieldWidth) {
|
||||
KList<FloatingIslandSample> samples = new KList<>();
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
|
||||
for (IrisFloatingChildBiomes entry : entries) {
|
||||
FloatingIslandSample sample = sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, data, engine,
|
||||
FloatingIslandSample sample = sampleEntry(parent, entry, wx, wz, chunkHeight, baseSeed, runtime,
|
||||
boundarySampler, parentBoundaryDistance, boundaryFieldWidth + 1);
|
||||
if (sample == null) {
|
||||
continue;
|
||||
@@ -313,11 +294,11 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
|
||||
private static FloatingIslandSample sampleEntry(IrisBiome parent, IrisFloatingChildBiomes entry, int wx, int wz,
|
||||
int chunkHeight, long baseSeed, IrisData data, Engine engine,
|
||||
int chunkHeight, long baseSeed, PackRuntime runtime,
|
||||
FloatingIslandBoundarySampler boundarySampler,
|
||||
int parentBoundaryDistance, int ownershipBoundaryDistance) {
|
||||
FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, data, parent);
|
||||
CNG footprintCng = entry.getFootprintCng(baseSeed, data);
|
||||
FloatingIslandEdgeProfile edgeProfile = resolveEdgeProfile(entry, baseSeed, runtime, parent);
|
||||
CNG footprintCng = entry.getFootprintCng(baseSeed, runtime);
|
||||
if (footprintCng == null) {
|
||||
warnNullCng("footprintStyle", parent);
|
||||
return reject(REJECT_NO_SEED);
|
||||
@@ -343,23 +324,23 @@ public final class FloatingIslandSample {
|
||||
return reject(REJECT_NO_THICKNESS);
|
||||
}
|
||||
|
||||
CNG altitudeCng = entry.getAltitudeCng(baseSeed, data);
|
||||
CNG altitudeCng = entry.getAltitudeCng(baseSeed, runtime);
|
||||
if (altitudeCng == null) {
|
||||
warnNullCng("altitudeStyle", parent);
|
||||
return reject(REJECT_NO_SEED);
|
||||
}
|
||||
double altNoise = altitudeCng.noise(wx, wz);
|
||||
double altClamped = Math.max(0, Math.min(1, altNoise));
|
||||
int worldMin = engine.getWorld().minHeight();
|
||||
int worldMin = runtime.engine().getWorld().minHeight();
|
||||
int minAlt = Math.max(0, entry.getMinHeightAboveSurface() - worldMin);
|
||||
int maxAlt = Math.max(minAlt, entry.getMaxHeightAboveSurface() - worldMin);
|
||||
int baseY = minAlt + (int) Math.round(altClamped * (maxAlt - minAlt));
|
||||
|
||||
IrisBiome target = entry.getRealBiome(parent, data);
|
||||
int fullTopHeight = computeTopHeight(entry, target, engine, baseSeed, wx, wz, data);
|
||||
IrisBiome target = entry.getRealBiome(parent, runtime.data());
|
||||
int fullTopHeight = computeTopHeight(entry, target, runtime, baseSeed, wx, wz);
|
||||
int topH = roundedEdgeHeight(fullTopHeight, edgeFade);
|
||||
|
||||
CNG bottomCng = entry.getBottomCng(baseSeed, data);
|
||||
CNG bottomCng = entry.getBottomCng(baseSeed, runtime);
|
||||
if (bottomCng == null) {
|
||||
warnNullCng("bottomStyle", parent);
|
||||
return reject(REJECT_NO_SEED);
|
||||
@@ -416,11 +397,11 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
|
||||
boolean[] solidMask = new boolean[thickness];
|
||||
CNG wallWarp = entry.getWallWarpCng(baseSeed, data);
|
||||
CNG wallWarp = entry.getWallWarpCng(baseSeed, runtime);
|
||||
double warpAmp = Math.max(0, entry.getWallWarpAmplitude());
|
||||
double effectiveWarpAmp = effectiveWallWarpAmplitude(warpAmp, edgeFade);
|
||||
IrisCaveProfileSampler carvingProfileSampler = entry.getCarvingProfileSampler(engine, data);
|
||||
CNG carve = carvingProfileSampler == null && !entry.hasCarvingReference() ? entry.getCarveCng(baseSeed, data) : null;
|
||||
IrisCaveProfileSampler carvingProfileSampler = entry.getCarvingProfileSampler(runtime);
|
||||
CNG carve = carvingProfileSampler == null && !entry.hasCarvingReference() ? entry.getCarveCng(baseSeed, runtime) : null;
|
||||
double carveThreshold = entry.getCarveThreshold();
|
||||
boolean useWarp = wallWarp != null && effectiveWarpAmp > 0;
|
||||
boolean useProfileCarve = carvingProfileSampler != null;
|
||||
@@ -683,27 +664,7 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
|
||||
private static double footprintSigned(CNG footprintCng, int wx, int wz) {
|
||||
IdentityHashMap<CNG, Long2DoubleOpenHashMap> memoByCng = FOOTPRINT_MEMO.get();
|
||||
Long2DoubleOpenHashMap memo = memoByCng.get(footprintCng);
|
||||
if (memo == null) {
|
||||
memo = new Long2DoubleOpenHashMap(512);
|
||||
memo.defaultReturnValue(Double.NaN);
|
||||
memoByCng.put(footprintCng, memo);
|
||||
}
|
||||
|
||||
long key = columnKey(wx, wz);
|
||||
double cached = memo.get(key);
|
||||
if (!Double.isNaN(cached)) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
double signed = signedFromUnit(footprintCng.noise(wx, wz));
|
||||
memo.put(key, signed);
|
||||
return signed;
|
||||
}
|
||||
|
||||
private static long columnKey(int wx, int wz) {
|
||||
return ((long) wx << 32) ^ (wz & 0xFFFFFFFFL);
|
||||
return signedFromUnit(footprintCng.noise(wx, wz));
|
||||
}
|
||||
|
||||
private static double signedFromUnit(double value) {
|
||||
@@ -779,7 +740,7 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
}
|
||||
|
||||
private static int computeTopHeight(IrisFloatingChildBiomes entry, IrisBiome target, Engine engine, long baseSeed, int wx, int wz, IrisData data) {
|
||||
private static int computeTopHeight(IrisFloatingChildBiomes entry, IrisBiome target, PackRuntime runtime, long baseSeed, int wx, int wz) {
|
||||
int maxTopHeight = Math.max(0, entry.getMaxTopHeight());
|
||||
if (maxTopHeight == 0) {
|
||||
return 0;
|
||||
@@ -787,7 +748,7 @@ public final class FloatingIslandSample {
|
||||
return switch (entry.getTopShapeMode()) {
|
||||
case FLAT -> maxTopHeight;
|
||||
case NOISE -> {
|
||||
CNG topCng = entry.getTopShapeCng(baseSeed, data);
|
||||
CNG topCng = entry.getTopShapeCng(baseSeed, runtime);
|
||||
if (topCng == null) {
|
||||
warnNullCng("topShapeStyle", null);
|
||||
yield maxTopHeight / 2;
|
||||
@@ -801,7 +762,7 @@ public final class FloatingIslandSample {
|
||||
if (target == null) {
|
||||
yield maxTopHeight / 2;
|
||||
}
|
||||
double h = target.getHeight(engine, wx, wz, baseSeed);
|
||||
double h = target.getHeight(runtime, wx, wz, baseSeed);
|
||||
int rounded = (int) Math.round(h);
|
||||
if (rounded < 0) {
|
||||
yield 0;
|
||||
@@ -810,21 +771,4 @@ public final class FloatingIslandSample {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static final class ChunkMemo {
|
||||
private final HashMap<Long, MemoizedSample> samples = new HashMap<>(256);
|
||||
private MemoContext context;
|
||||
}
|
||||
|
||||
private record MemoContext(int chunkX, int chunkZ, int height, long seed, IrisData data, Engine engine,
|
||||
FloatingIslandBoundarySampler boundarySampler) {
|
||||
private boolean matches(int chunkX, int chunkZ, int height, long seed, IrisData data, Engine engine,
|
||||
FloatingIslandBoundarySampler boundarySampler) {
|
||||
return this.chunkX == chunkX && this.chunkZ == chunkZ && this.height == height && this.seed == seed
|
||||
&& this.data == data && this.engine == engine && this.boundarySampler == boundarySampler;
|
||||
}
|
||||
}
|
||||
|
||||
private record MemoizedSample(IrisBiome parent, FloatingIslandSample sample) {
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfile;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorationPart;
|
||||
import art.arcane.iris.generation.decoration.IrisDecorator;
|
||||
@@ -25,7 +26,6 @@ import art.arcane.iris.generation.decoration.IrisDepositGenerator;
|
||||
import art.arcane.iris.generation.decoration.IrisDepositVariant;
|
||||
import art.arcane.iris.generation.decoration.IrisOreGenerator;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralObjects;
|
||||
import art.arcane.iris.generation.hydrology.config.IrisHydrologyPolicy;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -47,7 +47,6 @@ import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.pack.loading.IrisRegistrant;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.iris.pack.schema.annotation.DependsOn;
|
||||
@@ -63,7 +62,6 @@ import art.arcane.volmlib.util.collection.KSet;
|
||||
import art.arcane.iris.generation.block.DataProvider;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
import art.arcane.iris.generation.context.IrisContext;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
@@ -93,7 +91,6 @@ import java.util.Objects;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
public static final int CHILD_HOPS = 4;
|
||||
private static final int BIOME_GENERATOR_CACHE_SIZE = 8;
|
||||
private static final int CHILDREN_SEED_SALT = 2137;
|
||||
|
||||
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
|
||||
@@ -104,25 +101,10 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
private final transient AtomicCache<Color> cacheColorDecoratorLoad = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColorLayerLoad = new AtomicCache<>();
|
||||
private final transient AtomicCache<Color> cacheColorDepositLoad = new AtomicCache<>();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<ChildGeneratorKey, CNG> childrenGenerators = new LazyBoundedCache<>(8);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile CachedChildGenerator recentChildGenerator;
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<Long, CNG> biomeGenerators =
|
||||
new LazyBoundedCache<>(BIOME_GENERATOR_CACHE_SIZE);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile SeededBiomeGenerator recentBiomeGenerator;
|
||||
private final transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
||||
private final transient AtomicCache<Integer> maxWithObjectHeight = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisBiome> realCarveBiome = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
|
||||
private final transient IrisBiomeLayerHeightCache layerHeightGenerators = new IrisBiomeLayerHeightCache();
|
||||
private final transient IrisBiomeLayerHeightCache layerCeilingHeightGenerators = new IrisBiomeLayerHeightCache();
|
||||
private final transient IrisBiomeLayerHeightCache layerSeaHeightGenerators = new IrisBiomeLayerHeightCache();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> surfaceOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<IrisOreGenerator>> undergroundOreCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<IrisOreBands> surfaceOreBandsCache = new AtomicCache<>();
|
||||
@@ -225,8 +207,6 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
@ArrayType(min = 1, type = IrisObjectPlacement.class)
|
||||
@Description("Objects define what schematics (iob files) iris will place in this biome")
|
||||
private KList<IrisObjectPlacement> objects = new KList<>();
|
||||
@Description("Procedural objects (such as trees) iris generates from scratch and places in this biome, instead of loading them from iob files")
|
||||
private IrisProceduralObjects proceduralObjects = new IrisProceduralObjects();
|
||||
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
||||
@Description("Structures define jigsaw or vanilla/datapack structures iris will place in this biome")
|
||||
private KList<IrisStructurePlacement> structures = new KList<>();
|
||||
@@ -274,16 +254,16 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return IrisBiomeOres.canReplaceSurfaceOre(this, state);
|
||||
}
|
||||
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
return IrisBiomeOres.generateOres(this, x, y, z, rng, data, surface);
|
||||
public NativeBlockState generateOres(int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
return IrisBiomeOres.generateOres(this, x, y, z, rng, runtime, surface);
|
||||
}
|
||||
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, data);
|
||||
public NativeBlockState generateSurfaceOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return IrisBiomeOres.generateSurfaceOres(this, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, data);
|
||||
public NativeBlockState generateUndergroundOres(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return IrisBiomeOres.generateUndergroundOres(this, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
public boolean hasSurfaceOres() {
|
||||
@@ -469,68 +449,38 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
});
|
||||
}
|
||||
|
||||
public double getHeight(Engine xg, double x, double z, long seed) {
|
||||
public double getHeight(PackRuntime runtime, double x, double z, long seed) {
|
||||
double height = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : generators) {
|
||||
height += i.getHeight(xg, x, z, seed);
|
||||
height += i.getHeight(runtime, x, z, seed);
|
||||
}
|
||||
|
||||
return Math.max(0, Math.min(height, xg.getHeight()));
|
||||
}
|
||||
|
||||
public CNG getBiomeGenerator(RNG random) {
|
||||
IrisData loader = getLoader();
|
||||
Engine engine = resolveBiomeGeneratorEngine(loader);
|
||||
return getBiomeGenerator(random, engine);
|
||||
return Math.max(0, Math.min(height, runtime.engine().getHeight()));
|
||||
}
|
||||
|
||||
/** Engines seed the scatter generator from their own biome seed; engine-less tools use the caller's seed. */
|
||||
public CNG getBiomeGenerator(RNG random, Engine engine) {
|
||||
IrisData loader = getLoader();
|
||||
long seed = engine == null ? random.getSeed() : engine.getSeedManager().getBiome();
|
||||
SeededBiomeGenerator recent = recentBiomeGenerator;
|
||||
if (recent != null && recent.seed == seed) {
|
||||
return recent.generator;
|
||||
}
|
||||
|
||||
CNG generator = biomeGenerators.computeIfAbsent(seed, ignored -> createBiomeGenerator(seed, loader));
|
||||
recentBiomeGenerator = new SeededBiomeGenerator(seed, generator);
|
||||
return generator;
|
||||
return PackRuntime.of(engine, getLoader()).biome(this).biomeGenerator(seed);
|
||||
}
|
||||
|
||||
private Engine resolveBiomeGeneratorEngine(IrisData loader) {
|
||||
IrisContext context = IrisContext.get();
|
||||
if (context != null) {
|
||||
Engine contextEngine = context.getEngine();
|
||||
if (!contextEngine.isClosed() && (loader == null || contextEngine.getData() == loader)) {
|
||||
return contextEngine;
|
||||
}
|
||||
}
|
||||
|
||||
return loader == null ? null : loader.getEngine();
|
||||
}
|
||||
|
||||
private CNG createBiomeGenerator(long seed, IrisData loader) {
|
||||
CNG createBiomeGenerator(long seed, PackRuntime runtime) {
|
||||
int signature = 213949 + 228888 + getRarity() + getName().length();
|
||||
return biomeStyle.createNoCache(new RNG(seed).nextParallelRNG(signature), loader);
|
||||
return biomeStyle.createNoCache(new RNG(seed).nextParallelRNG(signature), runtime);
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
|
||||
return getChildrenGenerator(deriveChildStyleSeed(random, sig).getSeed(), scale);
|
||||
public CNG getChildrenGenerator(PackRuntime runtime, RNG random, int sig, double scale) {
|
||||
return getChildrenGenerator(runtime, deriveChildStyleSeed(random, sig).getSeed(), scale);
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(long seed, double scale) {
|
||||
IrisData data = getLoader();
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
CachedChildGenerator recent = recentChildGenerator;
|
||||
if (recent != null && recent.key.matches(seed, scale, data, engine)) {
|
||||
return recent.generator;
|
||||
}
|
||||
ChildGeneratorKey key = new ChildGeneratorKey(seed, scale, data, engine);
|
||||
CNG generator = childrenGenerators.computeIfAbsent(key,
|
||||
ignored -> getChildStyle().createScaledGenerator(new RNG(seed), data, scale));
|
||||
recentChildGenerator = new CachedChildGenerator(key, generator);
|
||||
return generator;
|
||||
public CNG getChildrenGenerator(PackRuntime runtime, long seed, double scale) {
|
||||
double childScale = getChildStyle().isSeeded() ? 1 : scale;
|
||||
return runtime.biome(this).childrenGenerator(seed, childScale);
|
||||
}
|
||||
|
||||
CNG createChildrenGenerator(long seed, double scale, PackRuntime runtime) {
|
||||
return getChildStyle().createScaledGenerator(new RNG(seed), runtime, scale);
|
||||
}
|
||||
|
||||
static RNG deriveChildStyleSeed(RNG random, int signature) {
|
||||
@@ -541,24 +491,24 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return deriveChildStyleSeed(random, signature).getSeed();
|
||||
}
|
||||
|
||||
public KList<NativeBlockState> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
|
||||
public KList<NativeBlockState> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, runtime, complex);
|
||||
}
|
||||
|
||||
public KList<NativeBlockState> generateLayersWithSlope(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, ProceduralStream<Double> slopeStream) {
|
||||
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, rdata, slopeStream);
|
||||
public KList<NativeBlockState> generateLayersWithSlope(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, ProceduralStream<Double> slopeStream) {
|
||||
return IrisBiomeLayerGenerator.generateLayers(this, dim, wx, wz, random, maxDepth, height, runtime, slopeStream);
|
||||
}
|
||||
|
||||
public KList<NativeBlockState> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateCeilingLayers(this, dim, wx, wz, random, maxDepth, height, rdata, complex);
|
||||
public KList<NativeBlockState> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateCeilingLayers(this, dim, wx, wz, random, maxDepth, height, runtime, complex);
|
||||
}
|
||||
|
||||
public KList<NativeBlockState> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLockedLayers(this, wx, wz, random, maxDepthf, height, rdata, complex);
|
||||
public KList<NativeBlockState> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
return IrisBiomeLayerGenerator.generateLockedLayers(this, wx, wz, random, maxDepthf, height, runtime, complex);
|
||||
}
|
||||
|
||||
public KList<NativeBlockState> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
return IrisBiomeLayerGenerator.generateSeaLayers(this, wx, wz, random, maxDepth, rdata);
|
||||
public KList<NativeBlockState> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, PackRuntime runtime) {
|
||||
return IrisBiomeLayerGenerator.generateSeaLayers(this, wx, wz, random, maxDepth, runtime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,20 +523,20 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return IrisBiomeLayerGenerator.getMaxWithObjectHeight(this, data, engine);
|
||||
}
|
||||
|
||||
public KList<CNG> getLayerHeightGenerators(RNG rng, IrisData rdata) {
|
||||
return IrisBiomeLayerGenerator.getLayerHeightGenerators(this, rng, rdata);
|
||||
public KList<CNG> getLayerHeightGenerators(RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(this).layerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
public KList<CNG> getLayerSeaHeightGenerators(RNG rng, IrisData data) {
|
||||
return IrisBiomeLayerGenerator.getLayerSeaHeightGenerators(this, rng, data);
|
||||
public KList<CNG> getLayerSeaHeightGenerators(RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(this).seaLayerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
public KList<CNG> getCaveCeilingLayerHeightGenerators(RNG rng, IrisData data) {
|
||||
return IrisBiomeLayerGenerator.getCaveCeilingLayerHeightGenerators(this, rng, data);
|
||||
public KList<CNG> getCaveCeilingLayerHeightGenerators(RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(this).ceilingLayerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
public NativeBlockState getSurfaceBlock(int x, int z, RNG rng, IrisData idm) {
|
||||
return IrisBiomeLayerGenerator.getSurfaceBlock(this, x, z, rng, idm);
|
||||
public NativeBlockState getSurfaceBlock(int x, int z, RNG rng, PackRuntime runtime) {
|
||||
return IrisBiomeLayerGenerator.getSurfaceBlock(this, x, z, rng, runtime);
|
||||
}
|
||||
|
||||
public boolean isLand() {
|
||||
@@ -616,18 +566,10 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return inferredType.equals(InferredType.SHORE);
|
||||
}
|
||||
|
||||
public Biome getSkyBiome(RNG rng, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getSkyBiome(this, rng, resolveBiomeGeneratorEngine(getLoader()), x, y, z);
|
||||
}
|
||||
|
||||
public Biome getSkyBiome(RNG rng, Engine engine, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getSkyBiome(this, rng, engine, x, y, z);
|
||||
}
|
||||
|
||||
public IrisBiomeCustom getCustomBiome(RNG rng, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getCustomBiome(this, rng, resolveBiomeGeneratorEngine(getLoader()), x, y, z);
|
||||
}
|
||||
|
||||
public IrisBiomeCustom getCustomBiome(RNG rng, Engine engine, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getCustomBiome(this, rng, engine, x, y, z);
|
||||
}
|
||||
@@ -656,27 +598,14 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
return new KList<>(m);
|
||||
}
|
||||
|
||||
//TODO: Test
|
||||
public Biome getGroundBiome(RNG rng, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getGroundBiome(this, rng, resolveBiomeGeneratorEngine(getLoader()), x, y, z);
|
||||
}
|
||||
|
||||
public Biome getGroundBiome(RNG rng, Engine engine, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getGroundBiome(this, rng, engine, x, y, z);
|
||||
}
|
||||
|
||||
public String getSkyBiomeKey(RNG rng, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getSkyBiomeKey(this, rng, resolveBiomeGeneratorEngine(getLoader()), x, y, z);
|
||||
}
|
||||
|
||||
public String getSkyBiomeKey(RNG rng, Engine engine, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getSkyBiomeKey(this, rng, engine, x, y, z);
|
||||
}
|
||||
|
||||
public String getGroundBiomeKey(RNG rng, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getGroundBiomeKey(this, rng, resolveBiomeGeneratorEngine(getLoader()), x, y, z);
|
||||
}
|
||||
|
||||
public String getGroundBiomeKey(RNG rng, Engine engine, double x, double y, double z) {
|
||||
return IrisBiomeDerivatives.getGroundBiomeKey(this, rng, engine, x, y, z);
|
||||
}
|
||||
@@ -714,37 +643,4 @@ public class IrisBiome extends IrisRegistrant implements Rarity {
|
||||
public String getTypeName() {
|
||||
return "Biome";
|
||||
}
|
||||
|
||||
private static final class SeededBiomeGenerator {
|
||||
private final long seed;
|
||||
private final CNG generator;
|
||||
|
||||
private SeededBiomeGenerator(long seed, CNG generator) {
|
||||
this.seed = seed;
|
||||
this.generator = generator;
|
||||
}
|
||||
}
|
||||
|
||||
private record ChildGeneratorKey(long seed, double scale, IrisData data, Engine engine) {
|
||||
private boolean matches(long seed, double scale, IrisData data, Engine engine) {
|
||||
return this.seed == seed && Double.doubleToLongBits(this.scale) == Double.doubleToLongBits(scale)
|
||||
&& this.data == data && this.engine == engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof ChildGeneratorKey other && matches(other.seed, other.scale, other.data, other.engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = Long.hashCode(seed);
|
||||
hash = 31 * hash + Double.hashCode(scale);
|
||||
hash = 31 * hash + System.identityHashCode(data);
|
||||
return 31 * hash + System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
|
||||
private record CachedChildGenerator(ChildGeneratorKey key, CNG generator) {
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.noise.IrisGenerator;
|
||||
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
@@ -81,8 +82,8 @@ public class IrisBiomeGeneratorLink {
|
||||
});
|
||||
}
|
||||
|
||||
public double getHeight(DataProvider xg, double x, double z, long seed) {
|
||||
double g = getCachedGenerator(xg).getHeight(x, z, seed);
|
||||
public double getHeight(PackRuntime runtime, double x, double z, long seed) {
|
||||
double g = getCachedGenerator(runtime::data).getHeight(runtime, x, z, seed);
|
||||
g = g < 0 ? 0 : g;
|
||||
g = g > 1 ? 1 : g;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisSlopeClip;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
@@ -45,18 +46,18 @@ final class IrisBiomeLayerGenerator {
|
||||
private IrisBiomeLayerGenerator() {
|
||||
}
|
||||
|
||||
static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
return generateLayers(biome, dim, wx, wz, random, maxDepth, height, rdata, complex, null);
|
||||
static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
return generateLayers(biome, dim, wx, wz, random, maxDepth, height, runtime, complex, null);
|
||||
}
|
||||
|
||||
static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, ProceduralStream<Double> slopeStream) {
|
||||
return generateLayers(biome, dim, wx, wz, random, maxDepth, height, rdata, null, slopeStream);
|
||||
static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, ProceduralStream<Double> slopeStream) {
|
||||
return generateLayers(biome, dim, wx, wz, random, maxDepth, height, runtime, null, slopeStream);
|
||||
}
|
||||
|
||||
private static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex, ProceduralStream<Double> slopeStream) {
|
||||
private static KList<NativeBlockState> generateLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, IrisComplex complex, ProceduralStream<Double> slopeStream) {
|
||||
if (biome.isLockLayers()) {
|
||||
KList<NativeBlockState> data = generateLockedLayers(biome, wx, wz, random, maxDepth, height, rdata, complex, slopeStream);
|
||||
appendSurfaceFallback(data, biome, dim, wx, wz, random, Math.min(maxDepth, biome.getLockLayersMax()), rdata);
|
||||
KList<NativeBlockState> data = generateLockedLayers(biome, wx, wz, random, maxDepth, height, runtime, complex, slopeStream);
|
||||
appendSurfaceFallback(data, biome, dim, wx, wz, random, Math.min(maxDepth, biome.getLockLayersMax()), runtime);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -73,7 +74,8 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
|
||||
BiomeRuntime biomeRuntime = runtime.biome(biome);
|
||||
KList<CNG> heightGenerators = biomeRuntime.layerHeights(random.getSeed());
|
||||
double surfaceSlope = 0D;
|
||||
boolean sampledSlope = false;
|
||||
|
||||
@@ -98,7 +100,7 @@ final class IrisBiomeLayerGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
appendLayer(data, layer, i, d, wx, wz, random, maxDepth, rdata);
|
||||
appendLayer(data, layer, biomeRuntime.surfaceLayer(i), i, d, wx, wz, random, maxDepth);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
@@ -115,12 +117,12 @@ final class IrisBiomeLayerGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
appendSurfaceFallback(data, biome, dim, wx, wz, random, maxDepth, rdata);
|
||||
appendSurfaceFallback(data, biome, dim, wx, wz, random, maxDepth, runtime);
|
||||
return data;
|
||||
}
|
||||
|
||||
private static void appendSurfaceFallback(KList<NativeBlockState> data, IrisBiome biome, IrisDimension dim,
|
||||
double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
double wx, double wz, RNG random, int maxDepth, PackRuntime runtime) {
|
||||
if (!data.isEmpty() || maxDepth <= 0 || biome.getLayers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -129,11 +131,11 @@ final class IrisBiomeLayerGenerator {
|
||||
fallback = dim.getSurfaceLayerFallback();
|
||||
}
|
||||
if (fallback == IrisSurfaceLayerFallback.TOP_LAYER) {
|
||||
appendLayer(data, biome.getLayers().get(0), 0, 1, wx, wz, random, maxDepth, rdata);
|
||||
appendLayer(data, biome.getLayers().get(0), runtime.biome(biome).surfaceLayer(0), 0, 1, wx, wz, random, maxDepth);
|
||||
}
|
||||
}
|
||||
|
||||
static KList<NativeBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
static KList<NativeBlockState> generateCeilingLayers(IrisBiome biome, IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
KList<NativeBlockState> data = new KList<>();
|
||||
|
||||
if (maxDepth <= 0) {
|
||||
@@ -147,7 +149,8 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getCaveCeilingLayerHeightGenerators(biome, random, rdata);
|
||||
BiomeRuntime biomeRuntime = runtime.biome(biome);
|
||||
KList<CNG> heightGenerators = biomeRuntime.ceilingLayerHeights(random.getSeed());
|
||||
|
||||
for (int i = 0; i < layerCount; i++) {
|
||||
IrisBiomePaletteLayer layer = ceilingLayers.get(i);
|
||||
@@ -159,7 +162,7 @@ final class IrisBiomeLayerGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
appendLayer(data, layer, i, d, wx, wz, random, maxDepth, rdata);
|
||||
appendLayer(data, layer, biomeRuntime.ceilingLayer(i), i, d, wx, wz, random, maxDepth);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
@@ -179,11 +182,11 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
static KList<NativeBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepthf, height, rdata, complex, null);
|
||||
static KList<NativeBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, PackRuntime runtime, IrisComplex complex) {
|
||||
return generateLockedLayers(biome, wx, wz, random, maxDepthf, height, runtime, complex, null);
|
||||
}
|
||||
|
||||
private static KList<NativeBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex, ProceduralStream<Double> slopeStream) {
|
||||
private static KList<NativeBlockState> generateLockedLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepthf, int height, PackRuntime runtime, IrisComplex complex, ProceduralStream<Double> slopeStream) {
|
||||
KList<NativeBlockState> data = new KList<>();
|
||||
int maxDepth = Math.min(maxDepthf, biome.getLockLayersMax());
|
||||
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
|
||||
@@ -192,7 +195,8 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerHeightGenerators(biome, random, rdata);
|
||||
BiomeRuntime biomeRuntime = runtime.biome(biome);
|
||||
KList<CNG> heightGenerators = biomeRuntime.layerHeights(random.getSeed());
|
||||
int[] boundaries = new int[layerCount + 1];
|
||||
double surfaceSlope = 0D;
|
||||
boolean sampledSlope = false;
|
||||
@@ -227,10 +231,10 @@ final class IrisBiomeLayerGenerator {
|
||||
int layerIndex = findLayer(boundaries, position);
|
||||
IrisBiomePaletteLayer layer = layers.get(layerIndex);
|
||||
int offset = position - boundaries[layerIndex];
|
||||
double zoom = layer.getZoom();
|
||||
double blocksPerSample = layer.blocksPerSample();
|
||||
try {
|
||||
data.add(layer.get(random, layerIndex + offset,
|
||||
(wx + offset) / zoom, offset, (wz - offset) / zoom, rdata));
|
||||
(wx + offset) / blocksPerSample, offset, (wz - offset) / blocksPerSample, biomeRuntime.surfaceLayer(layerIndex)));
|
||||
} catch (Throwable error) {
|
||||
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) wx, height - depth, (int) wz, biome.getLoadKey());
|
||||
}
|
||||
@@ -274,7 +278,7 @@ final class IrisBiomeLayerGenerator {
|
||||
: complex.getSlopeStream().getDouble(x, z);
|
||||
}
|
||||
|
||||
static KList<NativeBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
static KList<NativeBlockState> generateSeaLayers(IrisBiome biome, double wx, double wz, RNG random, int maxDepth, PackRuntime runtime) {
|
||||
KList<NativeBlockState> data = new KList<>();
|
||||
|
||||
KList<IrisBiomePaletteLayer> seaLayers = biome.getSeaLayers();
|
||||
@@ -284,7 +288,8 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
KList<CNG> heightGenerators = getLayerSeaHeightGenerators(biome, random, rdata);
|
||||
BiomeRuntime biomeRuntime = runtime.biome(biome);
|
||||
KList<CNG> heightGenerators = biomeRuntime.seaLayerHeights(random.getSeed());
|
||||
|
||||
for (int i = 0; i < layerCount; i++) {
|
||||
IrisBiomePaletteLayer layer = seaLayers.get(i);
|
||||
@@ -296,7 +301,7 @@ final class IrisBiomeLayerGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
appendLayer(data, layer, i, d, wx, wz, random, maxDepth, rdata);
|
||||
appendLayer(data, layer, biomeRuntime.seaLayer(i), i, d, wx, wz, random, maxDepth);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
@@ -306,46 +311,51 @@ final class IrisBiomeLayerGenerator {
|
||||
return data;
|
||||
}
|
||||
|
||||
static KList<CNG> getLayerHeightGenerators(IrisBiome biome, RNG rng, IrisData rdata) {
|
||||
return getHeightGenerators(biome.getLayerHeightGenerators(), biome.getLayers(), 7235, rng, rdata);
|
||||
static KList<CNG> getLayerHeightGenerators(IrisBiome biome, RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(biome).layerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
static KList<CNG> getLayerSeaHeightGenerators(IrisBiome biome, RNG rng, IrisData data) {
|
||||
return getHeightGenerators(biome.getLayerSeaHeightGenerators(), biome.getSeaLayers(), 7735, rng, data);
|
||||
static KList<CNG> getLayerSeaHeightGenerators(IrisBiome biome, RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(biome).seaLayerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
static KList<CNG> getCaveCeilingLayerHeightGenerators(IrisBiome biome, RNG rng, IrisData data) {
|
||||
return getHeightGenerators(biome.getLayerCeilingHeightGenerators(), biome.getCaveCeilingLayers(), 7235, rng, data);
|
||||
static KList<CNG> getCaveCeilingLayerHeightGenerators(IrisBiome biome, RNG rng, PackRuntime runtime) {
|
||||
return runtime.biome(biome).ceilingLayerHeights(rng.getSeed());
|
||||
}
|
||||
|
||||
private static KList<CNG> getHeightGenerators(IrisBiomeLayerHeightCache cache,
|
||||
KList<IrisBiomePaletteLayer> layers,
|
||||
int seedOffset, RNG rng, IrisData data) {
|
||||
return cache.get(layers, seedOffset, rng, data);
|
||||
static KList<CNG> createHeightGenerators(KList<IrisBiomePaletteLayer> layers, int seedOffset, long seed,
|
||||
PackRuntime runtime) {
|
||||
RNG rng = new RNG(seed);
|
||||
KList<CNG> result = new KList<>();
|
||||
int offset = seedOffset;
|
||||
for (IrisBiomePaletteLayer layer : layers) {
|
||||
result.add(layer.getHeightGenerator(rng.nextParallelRNG((offset++) * offset * offset * offset), runtime));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void appendLayer(KList<NativeBlockState> blocks, IrisBiomePaletteLayer layer,
|
||||
int layerIndex, int thickness, double x, double z,
|
||||
RNG random, int maxDepth, IrisData data) {
|
||||
double zoom = layer.getZoom();
|
||||
PaletteLayerRuntime layerRuntime, int layerIndex, int thickness, double x, double z,
|
||||
RNG random, int maxDepth) {
|
||||
double blocksPerSample = layer.blocksPerSample();
|
||||
for (int offset = 0; offset < thickness && blocks.size() < maxDepth; offset++) {
|
||||
try {
|
||||
blocks.add(layer.get(random, layerIndex + offset,
|
||||
(x + offset) / zoom, offset, (z - offset) / zoom, data));
|
||||
(x + offset) / blocksPerSample, offset, (z - offset) / blocksPerSample, layerRuntime));
|
||||
} catch (Throwable error) {
|
||||
GenerationFailures.skipPlacement(error, "surface layer", "block", (int) x, -1, (int) z, "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static NativeBlockState getSurfaceBlock(IrisBiome biome, int x, int z, RNG rng, IrisData idm) {
|
||||
static NativeBlockState getSurfaceBlock(IrisBiome biome, int x, int z, RNG rng, PackRuntime runtime) {
|
||||
KList<IrisBiomePaletteLayer> layers = biome.getLayers();
|
||||
|
||||
if (layers.isEmpty()) {
|
||||
return B.getState("AIR");
|
||||
}
|
||||
|
||||
return layers.get(0).get(rng, x, 0, z, idm);
|
||||
return layers.get(0).get(rng, x, 0, z, runtime);
|
||||
}
|
||||
|
||||
static int getMaxHeight(IrisBiome biome, Engine engine) {
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
final class IrisBiomeLayerHeightCache {
|
||||
private final LazyBoundedCache<GeneratorKey, KList<CNG>> generators = new LazyBoundedCache<>(32);
|
||||
private volatile CachedGenerators recent;
|
||||
|
||||
KList<CNG> get(KList<IrisBiomePaletteLayer> layers, int seedOffset, RNG rng, IrisData data) {
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
long seed = rng.getSeed();
|
||||
CachedGenerators cached = recent;
|
||||
if (cached != null && cached.key.matches(data, engine, seed)) {
|
||||
return cached.generators;
|
||||
}
|
||||
|
||||
GeneratorKey key = new GeneratorKey(data, engine, seed);
|
||||
KList<CNG> result = generators.computeIfAbsent(key, ignored -> create(layers, seedOffset, rng, data));
|
||||
recent = new CachedGenerators(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static KList<CNG> create(KList<IrisBiomePaletteLayer> layers, int seedOffset, RNG rng, IrisData data) {
|
||||
KList<CNG> result = new KList<>();
|
||||
int offset = seedOffset;
|
||||
for (IrisBiomePaletteLayer layer : layers) {
|
||||
result.add(layer.getHeightGenerator(rng.nextParallelRNG((offset++) * offset * offset * offset), data));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private record CachedGenerators(GeneratorKey key, KList<CNG> generators) {
|
||||
}
|
||||
|
||||
private static final class GeneratorKey {
|
||||
private final IrisData data;
|
||||
private final Engine engine;
|
||||
private final long seed;
|
||||
|
||||
private GeneratorKey(IrisData data, Engine engine, long seed) {
|
||||
this.data = data;
|
||||
this.engine = engine;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
private boolean matches(IrisData data, Engine engine, long seed) {
|
||||
return this.data == data && this.engine == engine && this.seed == seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return this == object || object instanceof GeneratorKey other
|
||||
&& matches(other.data, other.engine, other.seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = System.identityHashCode(data);
|
||||
result = 31 * result + System.identityHashCode(engine);
|
||||
return 31 * result + Long.hashCode(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import art.arcane.iris.generation.decoration.IrisOreGenerator;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
@@ -39,17 +39,17 @@ final class IrisBiomeOres {
|
||||
private IrisBiomeOres() {
|
||||
}
|
||||
|
||||
static NativeBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data, boolean surface) {
|
||||
static NativeBlockState generateOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime, boolean surface) {
|
||||
KList<IrisOreGenerator> localOres = surface ? getSurfaceOres(biome) : getUndergroundOres(biome);
|
||||
return generateOres(localOres, x, y, z, rng, data);
|
||||
return generateOres(localOres, x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static NativeBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getSurfaceOres(biome), x, y, z, rng, data);
|
||||
static NativeBlockState generateSurfaceOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getSurfaceOres(biome), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static NativeBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generateOres(getUndergroundOres(biome), x, y, z, rng, data);
|
||||
static NativeBlockState generateUndergroundOres(IrisBiome biome, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
return generateOres(getUndergroundOres(biome), x, y, z, rng, runtime);
|
||||
}
|
||||
|
||||
static boolean hasSurfaceOres(IrisBiome biome) {
|
||||
@@ -122,7 +122,7 @@ final class IrisBiomeOres {
|
||||
});
|
||||
}
|
||||
|
||||
private static NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, IrisData data) {
|
||||
private static NativeBlockState generateOres(KList<IrisOreGenerator> localOres, int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (localOres.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ final class IrisBiomeOres {
|
||||
int oreCount = localOres.size();
|
||||
for (int oreIndex = 0; oreIndex < oreCount; oreIndex++) {
|
||||
IrisOreGenerator oreGenerator = localOres.get(oreIndex);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, data);
|
||||
NativeBlockState ore = oreGenerator.generate(x, y, z, rng, runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -25,8 +26,6 @@ import art.arcane.iris.generation.terrain.IrisSlopeClip;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.iris.pack.schema.annotation.DependsOn;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
@@ -37,17 +36,12 @@ import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
@Snippet("biome-palette")
|
||||
@Accessors(chain = true)
|
||||
@@ -56,24 +50,7 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
@Description("A layer of surface / subsurface material in biomes")
|
||||
@Data
|
||||
public class IrisBiomePaletteLayer {
|
||||
private static final int LAYER_GENERATOR_CACHE_SIZE = 32;
|
||||
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockData = new AtomicCache<>();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<LayerGeneratorKey, CNG> layerGenerators =
|
||||
new LazyBoundedCache<>(LAYER_GENERATOR_CACHE_SIZE);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient AtomicReferenceArray<CachedLayerGenerator> recentLayerGenerators =
|
||||
new AtomicReferenceArray<>(LAYER_GENERATOR_CACHE_SIZE);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<LayerGeneratorKey, CNG> heightGenerators =
|
||||
new LazyBoundedCache<>(LAYER_GENERATOR_CACHE_SIZE);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient AtomicReference<CachedLayerGenerator> recentHeightGenerator = new AtomicReference<>();
|
||||
@Description("The style of noise")
|
||||
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
|
||||
@DependsOn({"minHeight", "maxHeight"})
|
||||
@@ -98,23 +75,17 @@ public class IrisBiomePaletteLayer {
|
||||
@Description("The palette of blocks to be used in this layer")
|
||||
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("GRASS_BLOCK"));
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
long generatorSeed = rng.getSeed() + minHeight * maxHeight + getBlockData(data).size();
|
||||
CachedLayerGenerator recent = recentHeightGenerator.get();
|
||||
if (recent != null && recent.key.matches(data, engine, generatorSeed)) {
|
||||
return recent.generator;
|
||||
}
|
||||
|
||||
LayerGeneratorKey key = new LayerGeneratorKey(data, engine, generatorSeed);
|
||||
CNG generator = heightGenerators.computeIfAbsent(key,
|
||||
ignored -> CNG.signature(new RNG(generatorSeed)));
|
||||
recentHeightGenerator.set(new CachedLayerGenerator(key, generator));
|
||||
return generator;
|
||||
public CNG getHeightGenerator(RNG rng, PackRuntime runtime) {
|
||||
long generatorSeed = rng.getSeed() + minHeight * maxHeight + getBlockData(runtime.data()).size();
|
||||
return runtime.paletteLayer(this).heightGenerator(generatorSeed);
|
||||
}
|
||||
|
||||
public NativeBlockState get(RNG rng, double x, double y, double z, IrisData data) {
|
||||
return get(rng, 0, x, y, z, data);
|
||||
static CNG createHeightGenerator(long generatorSeed) {
|
||||
return CNG.signature(new RNG(generatorSeed));
|
||||
}
|
||||
|
||||
public NativeBlockState get(RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
return get(rng, 0, x, y, z, runtime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,44 +93,53 @@ public class IrisBiomePaletteLayer {
|
||||
* only built inside the lazy layer generator initializer, using the exact same seed derivation
|
||||
* as {@code parent.nextParallelRNG(signature)} followed by the generator signature.
|
||||
*/
|
||||
public NativeBlockState get(RNG parent, int signature, double x, double y, double z, IrisData data) {
|
||||
KList<NativeBlockState> localBlockData = getBlockData(data);
|
||||
|
||||
if (localBlockData.isEmpty()) {
|
||||
return null;
|
||||
public NativeBlockState get(RNG parent, int signature, double x, double y, double z, PackRuntime runtime) {
|
||||
KList<NativeBlockState> localBlockData = getBlockData(runtime.data());
|
||||
if (localBlockData.size() <= 1) {
|
||||
return localBlockData.isEmpty() ? null : localBlockData.get(0);
|
||||
}
|
||||
return fit(localBlockData, runtime.paletteLayer(this), parent, signature, x, y, z);
|
||||
}
|
||||
|
||||
if (localBlockData.size() == 1) {
|
||||
return localBlockData.get(0);
|
||||
/** {@link #get(RNG, int, double, double, double, PackRuntime)} for a caller that already holds this layer's runtime. */
|
||||
public NativeBlockState get(RNG parent, int signature, double x, double y, double z, PaletteLayerRuntime layerRuntime) {
|
||||
KList<NativeBlockState> localBlockData = getBlockData(layerRuntime.packRuntime().data());
|
||||
if (localBlockData.size() <= 1) {
|
||||
return localBlockData.isEmpty() ? null : localBlockData.get(0);
|
||||
}
|
||||
return fit(localBlockData, layerRuntime, parent, signature, x, y, z);
|
||||
}
|
||||
|
||||
private NativeBlockState fit(KList<NativeBlockState> localBlockData, PaletteLayerRuntime layerRuntime,
|
||||
RNG parent, int signature, double x, double y, double z) {
|
||||
CNG generator = layerRuntime.layerGenerator(layerGeneratorSeed(parent, signature, localBlockData.size()));
|
||||
if (style.isSeeded()) {
|
||||
return generator.fit(localBlockData, x, z);
|
||||
}
|
||||
double localZoom = zoom;
|
||||
double scaledX = x / localZoom;
|
||||
double scaledY = y / localZoom;
|
||||
double scaledZ = z / localZoom;
|
||||
return getLayerGenerator(parent, signature, data).fit(localBlockData, scaledX, scaledY, scaledZ);
|
||||
return generator.fit(localBlockData, x / localZoom, y / localZoom, z / localZoom);
|
||||
}
|
||||
|
||||
public CNG getLayerGenerator(RNG rng, IrisData data) {
|
||||
return getLayerGenerator(rng, 0, data);
|
||||
/** How many blocks one step of the layer's block noise spans: its zoom, or 1 for a seeded style, which is read flat. */
|
||||
public double blocksPerSample() {
|
||||
return style.isSeeded() ? 1 : zoom;
|
||||
}
|
||||
|
||||
public CNG getLayerGenerator(RNG parent, int signature, IrisData data) {
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
long generatorSeed = parent.getSeed() + signature + minHeight + maxHeight + getBlockData(data).size();
|
||||
int slot = (int) generatorSeed & (LAYER_GENERATOR_CACHE_SIZE - 1);
|
||||
CachedLayerGenerator recent = recentLayerGenerators.getAcquire(slot);
|
||||
if (recent != null && recent.key.matches(data, engine, generatorSeed)) {
|
||||
return recent.generator;
|
||||
}
|
||||
public CNG getLayerGenerator(RNG rng, PackRuntime runtime) {
|
||||
return getLayerGenerator(rng, 0, runtime);
|
||||
}
|
||||
|
||||
LayerGeneratorKey key = new LayerGeneratorKey(data, engine, generatorSeed);
|
||||
CNG generator = layerGenerators.computeIfAbsent(key,
|
||||
ignored -> style.create(new RNG(generatorSeed), data, engine));
|
||||
if (generator != null) {
|
||||
recentLayerGenerators.setRelease(slot, new CachedLayerGenerator(key, generator));
|
||||
}
|
||||
return generator;
|
||||
public CNG getLayerGenerator(RNG parent, int signature, PackRuntime runtime) {
|
||||
long generatorSeed = layerGeneratorSeed(parent, signature, getBlockData(runtime.data()).size());
|
||||
return runtime.paletteLayer(this).layerGenerator(generatorSeed);
|
||||
}
|
||||
|
||||
private long layerGeneratorSeed(RNG parent, int signature, int blockCount) {
|
||||
return parent.getSeed() + signature + minHeight + maxHeight + blockCount;
|
||||
}
|
||||
|
||||
CNG createLayerGenerator(long generatorSeed, PackRuntime runtime) {
|
||||
return style.createNoCache(new RNG(generatorSeed), runtime);
|
||||
}
|
||||
|
||||
public KList<IrisBlockData> add(String b) {
|
||||
@@ -195,49 +175,4 @@ public class IrisBiomePaletteLayer {
|
||||
palette.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
private static final class LayerGeneratorKey {
|
||||
private final IrisData data;
|
||||
private final Engine engine;
|
||||
private final long seed;
|
||||
|
||||
private LayerGeneratorKey(IrisData data, Engine engine, long seed) {
|
||||
this.data = data;
|
||||
this.engine = engine;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
private boolean matches(IrisData data, Engine engine, long seed) {
|
||||
return this.data == data && this.engine == engine && this.seed == seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof LayerGeneratorKey other)) {
|
||||
return false;
|
||||
}
|
||||
return data == other.data && engine == other.engine && seed == other.seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = System.identityHashCode(data);
|
||||
result = 31 * result + System.identityHashCode(engine);
|
||||
result = 31 * result + Long.hashCode(seed);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CachedLayerGenerator {
|
||||
private final LayerGeneratorKey key;
|
||||
private final CNG generator;
|
||||
|
||||
private CachedLayerGenerator(LayerGeneratorKey key, CNG generator) {
|
||||
this.key = key;
|
||||
this.generator = generator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.cave.IrisCaveProfileSampler;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -33,10 +34,6 @@ import art.arcane.volmlib.util.math.Rarity;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
@@ -62,97 +59,72 @@ import lombok.experimental.Accessors;
|
||||
@Data
|
||||
public class IrisFloatingChildBiomes implements Rarity {
|
||||
private final transient AtomicCache<IrisBiome> resolvedBiome = new AtomicCache<>();
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<RuntimeKey, FloatingIslandEdgeProfile> edgeTaperProfiles = new LazyBoundedCache<>(8);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile CachedEdgeProfile recentEdgeProfile;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<RuntimeKey, IrisCaveProfileSampler> carvingProfileSamplers = new LazyBoundedCache<>(8);
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private transient volatile CachedCarvingProfile recentCarvingProfile;
|
||||
private final transient AtomicCache<IrisObjectScale> shrinkScaleCache = new AtomicCache<>();
|
||||
|
||||
public CNG getFootprintCng(long baseSeed, IrisData data) {
|
||||
return getFootprintStyle().create(baseSeed ^ 0xF007B17DL, data);
|
||||
public CNG getFootprintCng(long baseSeed, PackRuntime runtime) {
|
||||
return getFootprintStyle().create(baseSeed ^ 0xF007B17DL, runtime);
|
||||
}
|
||||
|
||||
public FloatingIslandEdgeProfile getEdgeTaperProfile(long baseSeed, IrisData data) {
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
CachedEdgeProfile recent = recentEdgeProfile;
|
||||
if (recent != null && recent.key.matches(baseSeed, data, engine)) {
|
||||
return recent.profile;
|
||||
}
|
||||
RuntimeKey key = new RuntimeKey(baseSeed, data, engine);
|
||||
FloatingIslandEdgeProfile profile = edgeTaperProfiles.computeIfAbsent(key, ignored -> {
|
||||
int width = FloatingIslandEdgeProfile.clampWidth(getEdgeTaperWidth());
|
||||
double amplitude = FloatingIslandEdgeProfile.clampVariationAmplitude(
|
||||
getEdgeTaperVariationAmplitude(), width);
|
||||
IrisGeneratorStyle style = getEdgeTaperVariationStyle();
|
||||
CNG variation = amplitude > 0.0D && style != null
|
||||
? style.create(baseSeed ^ 0xED6E7A9E5L, data)
|
||||
: null;
|
||||
return new FloatingIslandEdgeProfile(width, getEdgeTaperExponent(), amplitude, variation);
|
||||
});
|
||||
recentEdgeProfile = new CachedEdgeProfile(key, profile);
|
||||
return profile;
|
||||
public FloatingIslandEdgeProfile getEdgeTaperProfile(long baseSeed, PackRuntime runtime) {
|
||||
return runtime.floatingChild(this).edgeTaperProfile(baseSeed);
|
||||
}
|
||||
|
||||
public CNG getPickerCng(long baseSeed, IrisData data) {
|
||||
return getPickerStyle().create(baseSeed ^ 0x91C4E72DL, data);
|
||||
FloatingIslandEdgeProfile createEdgeTaperProfile(long baseSeed, PackRuntime runtime) {
|
||||
int width = FloatingIslandEdgeProfile.clampWidth(getEdgeTaperWidth());
|
||||
double amplitude = FloatingIslandEdgeProfile.clampVariationAmplitude(getEdgeTaperVariationAmplitude(), width);
|
||||
IrisGeneratorStyle style = getEdgeTaperVariationStyle();
|
||||
CNG variation = amplitude > 0.0D && style != null
|
||||
? style.create(baseSeed ^ 0xED6E7A9E5L, runtime)
|
||||
: null;
|
||||
return new FloatingIslandEdgeProfile(width, getEdgeTaperExponent(), amplitude, variation);
|
||||
}
|
||||
|
||||
public CNG getAltitudeCng(long baseSeed, IrisData data) {
|
||||
return getAltitudeStyle().create(baseSeed ^ 0xA17DEBBL, data);
|
||||
public CNG getPickerCng(long baseSeed, PackRuntime runtime) {
|
||||
return getPickerStyle().create(baseSeed ^ 0x91C4E72DL, runtime);
|
||||
}
|
||||
|
||||
public CNG getTopShapeCng(long baseSeed, IrisData data) {
|
||||
return getTopShapeStyle().create(baseSeed ^ 0x70970601DEFL, data);
|
||||
public CNG getAltitudeCng(long baseSeed, PackRuntime runtime) {
|
||||
return getAltitudeStyle().create(baseSeed ^ 0xA17DEBBL, runtime);
|
||||
}
|
||||
|
||||
public CNG getBottomCng(long baseSeed, IrisData data) {
|
||||
return getBottomStyle().create(baseSeed ^ 0xB0770075CAFEL, data);
|
||||
public CNG getTopShapeCng(long baseSeed, PackRuntime runtime) {
|
||||
return getTopShapeStyle().create(baseSeed ^ 0x70970601DEFL, runtime);
|
||||
}
|
||||
|
||||
public CNG getWallWarpCng(long baseSeed, IrisData data) {
|
||||
public CNG getBottomCng(long baseSeed, PackRuntime runtime) {
|
||||
return getBottomStyle().create(baseSeed ^ 0xB0770075CAFEL, runtime);
|
||||
}
|
||||
|
||||
public CNG getWallWarpCng(long baseSeed, PackRuntime runtime) {
|
||||
IrisGeneratorStyle style = getWallWarpStyle();
|
||||
if (style == null) {
|
||||
return null;
|
||||
}
|
||||
return style.create(baseSeed ^ 0xA117BA17E0FL, data);
|
||||
return style.create(baseSeed ^ 0xA117BA17E0FL, runtime);
|
||||
}
|
||||
|
||||
public CNG getCarveCng(long baseSeed, IrisData data) {
|
||||
public CNG getCarveCng(long baseSeed, PackRuntime runtime) {
|
||||
IrisGeneratorStyle style = getCarveStyle();
|
||||
if (style == null) {
|
||||
return null;
|
||||
}
|
||||
return style.create(baseSeed ^ 0xCA5EC1EE5EL, data);
|
||||
return style.create(baseSeed ^ 0xCA5EC1EE5EL, runtime);
|
||||
}
|
||||
|
||||
public IrisCaveProfileSampler getCarvingProfileSampler(Engine engine, IrisData data) {
|
||||
public IrisCaveProfileSampler getCarvingProfileSampler(PackRuntime runtime) {
|
||||
if (!hasCarvingReference()) {
|
||||
return null;
|
||||
}
|
||||
return runtime.floatingChild(this).carvingProfileSampler();
|
||||
}
|
||||
|
||||
CachedCarvingProfile recent = recentCarvingProfile;
|
||||
if (recent != null && recent.key.matches(0L, data, engine)) {
|
||||
return recent.sampler;
|
||||
IrisCaveProfileSampler createCarvingProfileSampler(PackRuntime runtime) {
|
||||
Engine engine = runtime.engine();
|
||||
IrisBiome resolved = resolveCarvingBiome(carving, engine, runtime.data());
|
||||
if (resolved == null || resolved.getCaveProfile() == null || !resolved.getCaveProfile().isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
RuntimeKey key = new RuntimeKey(0L, data, engine);
|
||||
IrisCaveProfileSampler sampler = carvingProfileSamplers.computeIfAbsent(key, ignored -> {
|
||||
IrisBiome resolved = resolveCarvingBiome(carving, engine, data);
|
||||
if (resolved == null || resolved.getCaveProfile() == null || !resolved.getCaveProfile().isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new IrisCaveProfileSampler(engine, resolved.getCaveProfile());
|
||||
});
|
||||
recentCarvingProfile = new CachedCarvingProfile(key, sampler);
|
||||
return sampler;
|
||||
return new IrisCaveProfileSampler(engine, resolved.getCaveProfile());
|
||||
}
|
||||
|
||||
public boolean hasCarvingReference() {
|
||||
@@ -400,28 +372,4 @@ public class IrisFloatingChildBiomes implements Rarity {
|
||||
return loaded;
|
||||
});
|
||||
}
|
||||
|
||||
private record RuntimeKey(long seed, IrisData data, Engine engine) {
|
||||
private boolean matches(long seed, IrisData data, Engine engine) {
|
||||
return this.seed == seed && this.data == data && this.engine == engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof RuntimeKey other && matches(other.seed, other.data, other.engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = Long.hashCode(seed);
|
||||
hash = 31 * hash + System.identityHashCode(data);
|
||||
return 31 * hash + System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
|
||||
private record CachedEdgeProfile(RuntimeKey key, FloatingIslandEdgeProfile profile) {
|
||||
}
|
||||
|
||||
private record CachedCarvingProfile(RuntimeKey key, IrisCaveProfileSampler sampler) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.biome;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisBiomePaletteLayer}: the block selection and depth generators of the
|
||||
* seeds that sample it.
|
||||
*/
|
||||
public final class PaletteLayerRuntime {
|
||||
private static final int LAYER_SEED_CAPACITY = 32;
|
||||
private static final int LAYER_RECENT_SLOTS = 32;
|
||||
private static final int HEIGHT_SEED_CAPACITY = 32;
|
||||
|
||||
private final PackRuntime runtime;
|
||||
private final SeedTable<CNG> layerGenerators;
|
||||
private final SeedTable<CNG> heightGenerators;
|
||||
|
||||
public PaletteLayerRuntime(IrisBiomePaletteLayer layer, PackRuntime runtime) {
|
||||
this.runtime = runtime;
|
||||
this.layerGenerators = new SeedTable<>(LAYER_SEED_CAPACITY, LAYER_RECENT_SLOTS,
|
||||
seed -> layer.createLayerGenerator(seed, runtime));
|
||||
this.heightGenerators = new SeedTable<>(HEIGHT_SEED_CAPACITY, IrisBiomePaletteLayer::createHeightGenerator);
|
||||
}
|
||||
|
||||
/** The scope this runtime was built in, whose pack data resolves the layer's palette. */
|
||||
public PackRuntime packRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public CNG layerGenerator(long seed) {
|
||||
return layerGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG heightGenerator(long seed) {
|
||||
return heightGenerators.get(seed);
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,14 @@ public class B {
|
||||
return state != null && state.isTreeBlock();
|
||||
}
|
||||
|
||||
public static boolean isLog(NativeBlockState state) {
|
||||
return state != null && state.isLog();
|
||||
}
|
||||
|
||||
public static boolean isLeaves(NativeBlockState state) {
|
||||
return state != null && state.isLeaves();
|
||||
}
|
||||
|
||||
public static boolean isFoliagePlantable(NativeBlockState state) {
|
||||
return state != null && state.isFoliagePlantable();
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package art.arcane.iris.generation.cache;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class LazyBoundedCache<K, V> {
|
||||
private final int maximumSize;
|
||||
private transient LinkedHashMap<K, V> entries;
|
||||
|
||||
public LazyBoundedCache(int maximumSize) {
|
||||
if (maximumSize <= 0) {
|
||||
throw new IllegalArgumentException("Maximum cache size must be positive");
|
||||
}
|
||||
this.maximumSize = maximumSize;
|
||||
}
|
||||
|
||||
public synchronized V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
|
||||
K requiredKey = Objects.requireNonNull(key, "Cache key");
|
||||
Function<? super K, ? extends V> requiredMapping = Objects.requireNonNull(mappingFunction, "Cache mapping function");
|
||||
if (entries != null) {
|
||||
V cached = entries.get(requiredKey);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
|
||||
V computed = requiredMapping.apply(requiredKey);
|
||||
if (computed == null) {
|
||||
return null;
|
||||
}
|
||||
if (entries == null) {
|
||||
entries = new LinkedHashMap<>(maximumSize, 1F, true);
|
||||
}
|
||||
entries.put(requiredKey, computed);
|
||||
if (entries.size() > maximumSize) {
|
||||
entries.sequencedKeySet().removeFirst();
|
||||
}
|
||||
return computed;
|
||||
}
|
||||
|
||||
synchronized boolean isInitialized() {
|
||||
return entries != null;
|
||||
}
|
||||
|
||||
synchronized int size() {
|
||||
return entries == null ? 0 : entries.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package art.arcane.iris.generation.cave;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.mantle.CaveProfilePreview;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.studio.scene.SceneBlocks;
|
||||
import art.arcane.iris.studio.scene.SceneEntry;
|
||||
import art.arcane.iris.studio.scene.SceneRequest;
|
||||
import art.arcane.iris.studio.scene.SceneSizes;
|
||||
import art.arcane.iris.studio.scene.SceneView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/** The carved space of each enabled cave profile, as blocks coloured by depth. */
|
||||
public final class CaveProfileSceneView implements SceneView {
|
||||
private static final SceneSizes SIZES = new SceneSizes(List.of(64, 128, 256), 128);
|
||||
private static final int VARIANTS = 4;
|
||||
private static final int VARIANT_SPACING_BLOCKS = 4096;
|
||||
private static final int SURFACE_ABOVE_SEA_BLOCKS = 48;
|
||||
private static final int MAX_DEPTH_BLOCKS = 160;
|
||||
private static final String DIMENSION_KEY = "dimension";
|
||||
private static final String REGION_PREFIX = "region/";
|
||||
private static final String BIOME_PREFIX = "biome/";
|
||||
private static final String[] DEPTH_BANDS = {"minecraft:yellow_concrete", "minecraft:lime_concrete", "minecraft:light_blue_concrete",
|
||||
"minecraft:purple_concrete"};
|
||||
private static final int[][] NEIGHBOURS = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return "caveProfiles";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String label() {
|
||||
return "Cave profiles";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "The carved space of each enabled cave profile of the dimension, its regions and its biomes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneSizes sizes() {
|
||||
return SIZES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SceneEntry> entries(Engine engine) {
|
||||
IrisData data = engine.getData();
|
||||
IrisDimension dimension = engine.getDimension();
|
||||
List<SceneEntry> entries = new ArrayList<>();
|
||||
if (dimension.getCaveProfile().isEnabled()) {
|
||||
entries.add(new SceneEntry(DIMENSION_KEY, dimension.getName(), "Dimension", VARIANTS));
|
||||
}
|
||||
for (IrisRegion region : data.getRegionLoader().loadAll(data.getRegionLoader().getPossibleKeys())) {
|
||||
if (region != null && region.getCaveProfile().isEnabled()) {
|
||||
entries.add(new SceneEntry(REGION_PREFIX + region.getLoadKey(), region.getName(), "Regions", VARIANTS));
|
||||
}
|
||||
}
|
||||
for (IrisBiome biome : data.getBiomeLoader().loadAll(data.getBiomeLoader().getPossibleKeys())) {
|
||||
if (biome != null && biome.getCaveProfile().isEnabled()) {
|
||||
entries.add(new SceneEntry(BIOME_PREFIX + biome.getLoadKey(), biome.getName(), "Biomes", VARIANTS));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneBlocks scene(Engine engine, SceneRequest request) throws IOException {
|
||||
IrisCaveProfile profile = profileOf(engine, request.key());
|
||||
int size = request.size();
|
||||
int surfaceY = Math.min(engine.getHeight() - 1, engine.getDimension().getFluidHeight() + SURFACE_ABOVE_SEA_BLOCKS);
|
||||
int bottomY = Math.max(0, Math.max((int) Math.floor(profile.getVerticalRange().getMin()), surfaceY - MAX_DEPTH_BLOCKS));
|
||||
int originX = Math.floorMod(request.variant(), VARIANTS) * VARIANT_SPACING_BLOCKS;
|
||||
boolean[] carved = CaveProfilePreview.carve(engine, profile, originX, size, bottomY, surfaceY);
|
||||
return outsideOf(carved, size, surfaceY - bottomY + 1);
|
||||
}
|
||||
|
||||
private static IrisCaveProfile profileOf(Engine engine, String key) {
|
||||
IrisData data = engine.getData();
|
||||
IrisCaveProfile profile = null;
|
||||
if (DIMENSION_KEY.equals(key)) {
|
||||
profile = engine.getDimension().getCaveProfile();
|
||||
} else if (key.startsWith(REGION_PREFIX)) {
|
||||
IrisRegion region = data.getRegionLoader().load(key.substring(REGION_PREFIX.length()));
|
||||
profile = region == null ? null : region.getCaveProfile();
|
||||
} else if (key.startsWith(BIOME_PREFIX)) {
|
||||
IrisBiome biome = data.getBiomeLoader().load(key.substring(BIOME_PREFIX.length()));
|
||||
profile = biome == null ? null : biome.getCaveProfile();
|
||||
}
|
||||
if (profile == null) {
|
||||
throw new NoSuchElementException("No cave profile " + key);
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
// Only the carved blocks on the outside of the space are kept, as the inside could not be seen.
|
||||
private static SceneBlocks outsideOf(boolean[] carved, int size, int height) {
|
||||
SceneBlocks scene = new SceneBlocks();
|
||||
for (int y = 0; y < height; y++) {
|
||||
String band = DEPTH_BANDS[Math.min(DEPTH_BANDS.length - 1, (height - 1 - y) * DEPTH_BANDS.length / height)];
|
||||
for (int z = 0; z < size; z++) {
|
||||
for (int x = 0; x < size; x++) {
|
||||
if (carved[cellOf(x, y, z, size)] && touchesRock(carved, x, y, z, size, height)) {
|
||||
scene.add(x, y, z, band);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return scene;
|
||||
}
|
||||
|
||||
private static boolean touchesRock(boolean[] carved, int x, int y, int z, int size, int height) {
|
||||
for (int[] step : NEIGHBOURS) {
|
||||
int nx = x + step[0];
|
||||
int ny = y + step[1];
|
||||
int nz = z + step[2];
|
||||
boolean inside = nx >= 0 && ny >= 0 && nz >= 0 && nx < size && ny < height && nz < size;
|
||||
if (!inside || !carved[cellOf(nx, ny, nz, size)]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int cellOf(int x, int y, int z, int size) {
|
||||
return (y * size + z) * size + x;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import art.arcane.iris.pack.value.IrisRange;
|
||||
import art.arcane.iris.generation.noise.IrisStyledRange;
|
||||
import art.arcane.volmlib.util.math.M;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -52,18 +52,18 @@ public final class IrisCaveProfileSampler {
|
||||
private final boolean hasModules;
|
||||
|
||||
public IrisCaveProfileSampler(Engine engine, IrisCaveProfile profile) {
|
||||
IrisData data = engine.getData();
|
||||
PackRuntime runtime = PackRuntime.of(engine, engine.getData());
|
||||
this.profile = profile;
|
||||
List<ModuleState> moduleStates = new ArrayList<>();
|
||||
RNG baseRng = new RNG(engine.getSeedManager().getCarve());
|
||||
this.baseDensity = profile.getBaseDensityStyle().create(baseRng.nextParallelRNG(934_447), data);
|
||||
this.detailDensity = profile.getDetailDensityStyle().create(baseRng.nextParallelRNG(612_991), data);
|
||||
this.warpDensity = profile.getWarpStyle().create(baseRng.nextParallelRNG(770_713), data);
|
||||
this.baseDensity = profile.getBaseDensityStyle().create(baseRng.nextParallelRNG(934_447), runtime);
|
||||
this.detailDensity = profile.getDetailDensityStyle().create(baseRng.nextParallelRNG(612_991), runtime);
|
||||
this.warpDensity = profile.getWarpStyle().create(baseRng.nextParallelRNG(770_713), runtime);
|
||||
IrisStyledRange threshold = profile.getDensityThreshold();
|
||||
thresholdMin = threshold.getMin();
|
||||
thresholdMax = threshold.getMax();
|
||||
thresholdHasNoise = thresholdMin != thresholdMax && !threshold.getStyle().isFlat();
|
||||
thresholdDensity = thresholdHasNoise ? threshold.getStyle().create(baseRng.nextParallelRNG(489_112), data) : null;
|
||||
thresholdDensity = thresholdHasNoise ? threshold.getStyle().create(baseRng.nextParallelRNG(489_112), runtime) : null;
|
||||
constantThreshold = thresholdMin == thresholdMax ? thresholdMin : M.lerp(thresholdMin, thresholdMax, 0.5D);
|
||||
this.baseWeight = profile.getBaseWeight();
|
||||
this.detailWeight = profile.getDetailWeight();
|
||||
@@ -73,7 +73,7 @@ public final class IrisCaveProfileSampler {
|
||||
double weight = Math.abs(baseWeight) + Math.abs(detailWeight);
|
||||
int index = 0;
|
||||
for (IrisCaveFieldModule module : profile.getModules()) {
|
||||
CNG moduleDensity = module.getStyle().create(baseRng.nextParallelRNG(1_000_003L + (index * 65_537L)), data);
|
||||
CNG moduleDensity = module.getStyle().create(baseRng.nextParallelRNG(1_000_003L + (index * 65_537L)), runtime);
|
||||
ModuleState state = new ModuleState(module, moduleDensity);
|
||||
moduleStates.add(state);
|
||||
weight += Math.abs(state.weight);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.GenerationFailures;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.mantle.EngineMantle;
|
||||
@@ -46,6 +47,7 @@ final class DecoratorCore {
|
||||
private static volatile NativeBlockState twistingVines;
|
||||
private static volatile NativeBlockState twistingVinesPlant;
|
||||
|
||||
/** Per-thread placement options; callers clear the mantle reference once a placement returns. */
|
||||
static final ThreadLocal<PlaceOpts> SCRATCH_OPTS = ThreadLocal.withInitial(PlaceOpts::new);
|
||||
|
||||
|
||||
@@ -92,25 +94,27 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
static IrisDecorator pickDecorator(IrisBiome biome, IrisDecorationPart part, RNG gRNG,
|
||||
RNG colRng, IrisData data, double realX, double realZ) {
|
||||
RNG colRng, PackRuntime runtime, double realX, double realZ) {
|
||||
IrisDecorator[] bucket = biome.getDecoratorBucket(part);
|
||||
if (bucket.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DecoratorRuntime[] decoratorRuntimes = runtime.biome(biome).decorators(part);
|
||||
IrisDecorator picked = null;
|
||||
int count = 0;
|
||||
|
||||
for (IrisDecorator d : bucket) {
|
||||
for (int index = 0; index < bucket.length; index++) {
|
||||
IrisDecorator d = bucket[index];
|
||||
try {
|
||||
if (d.passesChanceGate(gRNG, realX, realZ, data)) {
|
||||
if (d.passesChanceGate(gRNG, realX, realZ, decoratorRuntimes[index])) {
|
||||
count++;
|
||||
if (count == 1 || colRng.nextInt(count) == 0) {
|
||||
picked = d;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
skip(e, d, data, (int) realX, -1, (int) realZ, biome);
|
||||
skip(e, d, runtime.data(), (int) realX, -1, (int) realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,14 +123,14 @@ final class DecoratorCore {
|
||||
|
||||
static void placeSurfaceSingle(IrisDecorator decorator,
|
||||
int x, int z, int realX, int height, int realZ,
|
||||
Hunk<NativeBlockState> data, RNG rng, IrisData irisData,
|
||||
Hunk<NativeBlockState> data, RNG rng, PackRuntime runtime,
|
||||
boolean underwater, boolean caveSkipFluid, EngineMantle mantle) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState bdx = data.get(x, height, z);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
|
||||
if (!IrisSpeleothems.isSpike(bd) && !underwater && !canGoOn(bd, bdx)
|
||||
&& !decorator.isForcePlace() && decorator.getForceBlock() == null) {
|
||||
@@ -138,14 +142,14 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
data.set(x, height, z, fixFacesForHunk(
|
||||
decorator.getForceBlock().getBlockData(irisData), data, x, z, realX, height, realZ, mantle));
|
||||
decorator.getForceBlock().getBlockData(runtime.data()), data, x, z, realX, height, realZ, mantle));
|
||||
}
|
||||
|
||||
if (!decorator.isForcePlace()) {
|
||||
if (decorator.getWhitelist() != null && !matchesPalette(decorator.getWhitelistArray(irisData), bdx)) {
|
||||
if (decorator.getWhitelist() != null && !matchesPalette(decorator.getWhitelistArray(runtime.data()), bdx)) {
|
||||
return;
|
||||
}
|
||||
if (decorator.getBlacklist() != null && matchesPalette(decorator.getBlacklistArray(irisData), bdx)) {
|
||||
if (decorator.getBlacklist() != null && matchesPalette(decorator.getBlacklistArray(runtime.data()), bdx)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -176,7 +180,7 @@ final class DecoratorCore {
|
||||
data.set(x, lowerY, z, lower);
|
||||
data.set(x, upperY, z, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(x, upperY, z), true));
|
||||
} catch (Throwable e) {
|
||||
skip(e, decorator, irisData, realX, lowerY, realZ, null);
|
||||
skip(e, decorator, runtime.data(), realX, lowerY, realZ, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -202,8 +206,8 @@ final class DecoratorCore {
|
||||
|
||||
static void placeSingleAt(IrisDecorator decorator, int x, int z,
|
||||
int realX, int height, int realZ, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, boolean applyFixFaces, EngineMantle mantle) {
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
RNG rng, PackRuntime runtime, boolean applyFixFaces, EngineMantle mantle) {
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
@@ -212,7 +216,7 @@ final class DecoratorCore {
|
||||
return;
|
||||
}
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (height + 1 < data.getHeight() && allowsSurface(decorator, data.get(x, height + 1, z), irisData)) {
|
||||
if (height + 1 < data.getHeight() && allowsSurface(decorator, data.get(x, height + 1, z), runtime.data())) {
|
||||
placeSingleSpike(bd, data, x, z, height, false, false);
|
||||
}
|
||||
return;
|
||||
@@ -225,17 +229,17 @@ final class DecoratorCore {
|
||||
|
||||
static void placeStackUp(IrisDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, PlaceOpts opts) {
|
||||
RNG rng, PackRuntime runtime, PlaceOpts opts) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState support = data.get(x, height, z);
|
||||
if (!allowsSurface(decorator, support, irisData)) {
|
||||
if (!allowsSurface(decorator, support, runtime.data())) {
|
||||
return;
|
||||
}
|
||||
int effectiveMax = opts.underwater ? Math.min(max, opts.fluidHeight - height) : max;
|
||||
int stack = computeStack(decorator, rng, realX, realZ, irisData, effectiveMax);
|
||||
int stack = computeStack(decorator, rng, realX, realZ, runtime, effectiveMax);
|
||||
int placed = 0;
|
||||
boolean hasSpikes = false;
|
||||
NativeBlockState sampledBlock = null;
|
||||
@@ -254,8 +258,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampledBlock;
|
||||
@@ -288,15 +292,15 @@ final class DecoratorCore {
|
||||
|
||||
static void placeStackDown(IrisDecorator decorator, int x, int z, int realX, int realZ,
|
||||
int height, int minHeight, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, int max, PlaceOpts opts, EngineMantle mantle) {
|
||||
if (height < 0 || height >= data.getHeight()) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState support = height + 1 < data.getHeight() ? data.get(x, height + 1, z) : null;
|
||||
if (!allowsSurface(decorator, support, irisData)) {
|
||||
if (!allowsSurface(decorator, support, runtime.data())) {
|
||||
return;
|
||||
}
|
||||
int stack = computeStack(decorator, rng, realX, realZ, irisData, max);
|
||||
int stack = computeStack(decorator, rng, realX, realZ, runtime, max);
|
||||
int placed = 0;
|
||||
boolean hasSpikes = false;
|
||||
NativeBlockState sampledBlock = null;
|
||||
@@ -315,8 +319,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampledBlock;
|
||||
@@ -349,11 +353,11 @@ final class DecoratorCore {
|
||||
static void placeFloatingSimple(IrisDecorator decorator,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, EngineMantle mantle) {
|
||||
if (!hasFloatingSurface(data, xf, height, zf)) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
NativeBlockState bd = decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
if (bd == null) {
|
||||
return;
|
||||
}
|
||||
@@ -363,7 +367,7 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (max > 1 && allowsSurface(decorator, data.get(xf, height, zf), irisData)) {
|
||||
if (max > 1 && allowsSurface(decorator, data.get(xf, height, zf), runtime.data())) {
|
||||
placeSingleSpike(bd, data, xf, zf, height + 1, true, false);
|
||||
}
|
||||
return;
|
||||
@@ -383,7 +387,7 @@ final class DecoratorCore {
|
||||
data.set(xf, lowerY, zf, IrisProceduralBlocks.normalizeWaterlogging(lower, data.get(xf, lowerY, zf), true));
|
||||
data.set(xf, upperY, zf, IrisProceduralBlocks.normalizeWaterlogging(upper, data.get(xf, upperY, zf), true));
|
||||
} catch (Throwable e) {
|
||||
skip(e, decorator, irisData, realX, lowerY, realZ, null);
|
||||
skip(e, decorator, runtime.data(), realX, lowerY, realZ, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -396,11 +400,11 @@ final class DecoratorCore {
|
||||
static int placeFloatingStacked(IrisDecorator decorator,
|
||||
int xf, int zf, int realX, int realZ,
|
||||
int height, int max, Hunk<NativeBlockState> data,
|
||||
RNG rng, IrisData irisData, EngineMantle mantle) {
|
||||
RNG rng, PackRuntime runtime, EngineMantle mantle) {
|
||||
if (!hasFloatingSurface(data, xf, height, zf)) {
|
||||
return 0;
|
||||
}
|
||||
int stack = decorator.getHeight(rng, realX, realZ, irisData);
|
||||
int stack = decorator.getHeight(rng, realX, realZ, runtime);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
@@ -420,8 +424,8 @@ final class DecoratorCore {
|
||||
boolean top = threshold >= decorator.getTopThreshold();
|
||||
if (sampledBlock == null || top != sampledTop) {
|
||||
sampledBlock = top
|
||||
? decorator.pickBlockDataTop(rng, irisData, realX, realZ)
|
||||
: decorator.pickBlockData(rng, irisData, realX, realZ);
|
||||
? decorator.pickBlockDataTop(rng, runtime, realX, realZ)
|
||||
: decorator.pickBlockData(rng, runtime, realX, realZ);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState bd = sampledBlock;
|
||||
@@ -433,7 +437,7 @@ final class DecoratorCore {
|
||||
break;
|
||||
}
|
||||
if (IrisSpeleothems.isSpike(bd)) {
|
||||
if (!allowsSurface(decorator, data.get(xf, height, zf), irisData)
|
||||
if (!allowsSurface(decorator, data.get(xf, height, zf), runtime.data())
|
||||
|| !IrisSpeleothems.canPlace(bd, data, xf, zf, h, true, false)) {
|
||||
break;
|
||||
}
|
||||
@@ -581,8 +585,8 @@ final class DecoratorCore {
|
||||
}
|
||||
|
||||
static int computeStack(IrisDecorator decorator, RNG rng, double realX, double realZ,
|
||||
IrisData irisData, int max) {
|
||||
int stack = decorator.getHeight(rng, realX, realZ, irisData);
|
||||
PackRuntime runtime, int max) {
|
||||
int stack = decorator.getHeight(rng, realX, realZ, runtime);
|
||||
if (decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
|
||||
/** What one engine derives from an {@link IrisDecorator}: the stack, placement and variance generators of each seed. */
|
||||
public final class DecoratorRuntime {
|
||||
private static final int SEED_CAPACITY = 32;
|
||||
|
||||
private final PackRuntime runtime;
|
||||
private final SeedTable<CNG> heightGenerators;
|
||||
private final SeedTable<CNG> layerGenerators;
|
||||
private final SeedTable<CNG> varianceGenerators;
|
||||
|
||||
public DecoratorRuntime(IrisDecorator decorator, PackRuntime runtime) {
|
||||
this.runtime = runtime;
|
||||
this.heightGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createHeightGenerator(seed, runtime));
|
||||
this.layerGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createLayerGenerator(seed, runtime));
|
||||
this.varianceGenerators = new SeedTable<>(SEED_CAPACITY, seed -> decorator.createVarianceGenerator(seed, runtime));
|
||||
}
|
||||
|
||||
/** The scope this runtime was built in, whose pack data resolves the decorator's palettes. */
|
||||
public PackRuntime packRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public CNG heightGenerator(long seed) {
|
||||
return heightGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG layerGenerator(long seed) {
|
||||
return layerGenerators.get(seed);
|
||||
}
|
||||
|
||||
public CNG varianceGenerator(long seed) {
|
||||
return varianceGenerators.get(seed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.SeedTable;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisDepositGenerator}: the clump variants of the engine's deposit seed, at
|
||||
* the configured size and at each scaled size the deposit modifier asks for.
|
||||
*/
|
||||
public final class DepositRuntime {
|
||||
private static final int SCALED_SIZE_CAPACITY = 64;
|
||||
|
||||
private final IrisDepositGenerator deposit;
|
||||
private final PackRuntime runtime;
|
||||
private final long depositSeed;
|
||||
private final SeedTable<KList<IrisObject>> scaledClumps;
|
||||
private volatile KList<IrisObject> clumps;
|
||||
|
||||
public DepositRuntime(IrisDepositGenerator deposit, PackRuntime runtime) {
|
||||
this.deposit = deposit;
|
||||
this.runtime = runtime;
|
||||
this.depositSeed = runtime.engine().getSeedManager().getDeposit();
|
||||
this.scaledClumps = new SeedTable<>(SCALED_SIZE_CAPACITY, sizes -> deposit.createScaledClumps(
|
||||
depositSeed, minSize(sizes), maxSize(sizes), runtime.data()));
|
||||
}
|
||||
|
||||
public KList<IrisObject> clumps() {
|
||||
KList<IrisObject> built = clumps;
|
||||
if (built != null) {
|
||||
return built;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (clumps == null) {
|
||||
clumps = deposit.createClumps(depositSeed, runtime.data());
|
||||
}
|
||||
return clumps;
|
||||
}
|
||||
}
|
||||
|
||||
public KList<IrisObject> scaledClumps(int minSize, int maxSize) {
|
||||
return scaledClumps.get(sizeKey(minSize, maxSize));
|
||||
}
|
||||
|
||||
private static long sizeKey(int minSize, int maxSize) {
|
||||
return ((long) minSize << 32) | (maxSize & 0xffffffffL);
|
||||
}
|
||||
|
||||
private static int minSize(long sizeKey) {
|
||||
return (int) (sizeKey >>> 32);
|
||||
}
|
||||
|
||||
private static int maxSize(long sizeKey) {
|
||||
return (int) sizeKey;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -36,7 +37,8 @@ public class FloatingDecorator {
|
||||
int height, int max, Hunk<NativeBlockState> data, RNG rng,
|
||||
Runnable candidatesNullCallback) {
|
||||
RNG gRNG = new RNG(DecoratorCore.partSeed(engine.getSeedManager().getComponent(), part));
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(target, part, gRNG, rng, engine.getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(engine);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(target, part, gRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
candidatesNullCallback.run();
|
||||
@@ -45,11 +47,11 @@ public class FloatingDecorator {
|
||||
|
||||
if (!decorator.isStacking()) {
|
||||
DecoratorCore.placeFloatingSimple(decorator, xf, zf, realX, realZ, height, max, data,
|
||||
gRNG, engine.getData(), engine.getMantle());
|
||||
gRNG, runtime, engine.getMantle());
|
||||
return max > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
return DecoratorCore.placeFloatingStacked(decorator, xf, zf, realX, realZ, height, max, data,
|
||||
gRNG, engine.getData(), engine.getMantle());
|
||||
gRNG, runtime, engine.getMantle());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.hydrology.plan.HydrologySettings;
|
||||
@@ -32,7 +33,7 @@ public final class HydrologyVegetation {
|
||||
this.shoreRng = new RNG(DecoratorCore.partSeed(this.seed, IrisDecorationPart.SHORE_LINE));
|
||||
}
|
||||
|
||||
public void decorate(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, WaterRole role, Water water, IrisData data) {
|
||||
public void decorate(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, WaterRole role, Water water, PackRuntime runtime) {
|
||||
Placement placement = placement(role);
|
||||
if (placement == Placement.NONE) {
|
||||
return;
|
||||
@@ -45,7 +46,7 @@ public final class HydrologyVegetation {
|
||||
if (ground < 0 || ground + 1 >= output.getHeight()) {
|
||||
return;
|
||||
}
|
||||
Column column = new Column(output, localX, localZ, x, z, ground, water, data);
|
||||
Column column = new Column(output, localX, localZ, x, z, ground, water, runtime);
|
||||
if (placement == Placement.SHORE) {
|
||||
decorateShore(column, decorators.shore);
|
||||
return;
|
||||
@@ -112,7 +113,7 @@ public final class HydrologyVegetation {
|
||||
int count = 0;
|
||||
for (IrisDecorator decorator : bucket) {
|
||||
try {
|
||||
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.data)) {
|
||||
if (!decorator.passesChanceGate(partRng, column.x, column.z, column.runtime)) {
|
||||
continue;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -213,9 +214,10 @@ public final class HydrologyVegetation {
|
||||
private final int z;
|
||||
private final int ground;
|
||||
private final Water water;
|
||||
private final PackRuntime runtime;
|
||||
private final IrisData data;
|
||||
|
||||
private Column(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, int ground, Water water, IrisData data) {
|
||||
private Column(Hunk<NativeBlockState> output, int localX, int localZ, int x, int z, int ground, Water water, PackRuntime runtime) {
|
||||
this.output = output;
|
||||
this.localX = localX;
|
||||
this.localZ = localZ;
|
||||
@@ -223,7 +225,8 @@ public final class HydrologyVegetation {
|
||||
this.z = z;
|
||||
this.ground = ground;
|
||||
this.water = water;
|
||||
this.data = data;
|
||||
this.runtime = runtime;
|
||||
this.data = runtime.data();
|
||||
}
|
||||
|
||||
private boolean accepts(IrisDecorator decorator, NativeBlockState support) {
|
||||
@@ -231,7 +234,7 @@ public final class HydrologyVegetation {
|
||||
}
|
||||
|
||||
private int stack(IrisDecorator decorator, RNG rng, int room) {
|
||||
return decorator.isStacking() ? Math.min(room, DecoratorCore.computeStack(decorator, rng, x, z, data, room)) : 1;
|
||||
return decorator.isStacking() ? Math.min(room, DecoratorCore.computeStack(decorator, rng, x, z, runtime, room)) : 1;
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
|
||||
@@ -243,7 +246,7 @@ public final class HydrologyVegetation {
|
||||
}
|
||||
|
||||
private void placePicked(IrisDecorator decorator, RNG rng, int baseY, int room, Slot slot, NativeBlockState support) {
|
||||
NativeBlockState first = decorator.pickBlockData(rng, data, x, z);
|
||||
NativeBlockState first = decorator.pickBlockData(rng, runtime, x, z);
|
||||
if (first == null) {
|
||||
return;
|
||||
}
|
||||
@@ -260,7 +263,7 @@ public final class HydrologyVegetation {
|
||||
int y = baseY + index;
|
||||
boolean top = (stack == 1 ? 1D : (double) index / (stack - 1)) >= decorator.getTopThreshold();
|
||||
if (top != sampledTop) {
|
||||
sampled = top ? decorator.pickBlockDataTop(rng, data, x, z) : decorator.pickBlockData(rng, data, x, z);
|
||||
sampled = top ? decorator.pickBlockDataTop(rng, runtime, x, z) : decorator.pickBlockData(rng, runtime, x, z);
|
||||
sampledTop = top;
|
||||
}
|
||||
NativeBlockState block = sampled == null ? null : fit(sampled, y, slot, decorator, index == 0 ? support : null);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.terrain.InferredType;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
@@ -47,21 +48,22 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
Hunk<NativeBlockState> data, IrisBiome biome, InferredType inferredType, int height, int max) {
|
||||
boolean caveSkipFluid = IrisSurfaceDecorator.skipsFluid(inferredType);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, height, max, caveSkipFluid);
|
||||
place(decorator, x, z, realX, realZ, data, height, max, caveSkipFluid, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
int height, int max, boolean caveSkipFluid) {
|
||||
int height, int max, boolean caveSkipFluid, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (caveSkipFluid) {
|
||||
NativeBlockState state = data.get(x, height, z);
|
||||
@@ -69,13 +71,13 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
}
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, partRNG, getData(), true, getEngine().getMantle());
|
||||
DecoratorCore.placeSingleAt(decorator, x, z, realX, height, realZ, data, partRNG, runtime, true, getEngine().getMantle());
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.PlaceOpts opts = DecoratorCore.SCRATCH_OPTS.get();
|
||||
opts.reset();
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, partRNG, getData(), max, opts, getEngine().getMantle());
|
||||
DecoratorCore.placeStackDown(decorator, x, z, realX, realZ, height, 0, data, partRNG, runtime, max, opts, getEngine().getMantle());
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -52,8 +52,6 @@ import lombok.experimental.Accessors;
|
||||
@Description("A biome decorator is used for placing flowers, grass, cacti and so on")
|
||||
@Data
|
||||
public class IrisDecorator {
|
||||
private final transient LazyBoundedCache<GeneratorKey, Generators> generators = new LazyBoundedCache<>(32);
|
||||
private transient volatile Generators recentGenerators;
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockDataTops = new AtomicCache<>();
|
||||
private final transient AtomicCache<NativeBlockState[]> blockDataArray = new AtomicCache<>();
|
||||
@@ -118,50 +116,39 @@ public class IrisDecorator {
|
||||
@Description("When the stack passes the top threshold, the top palette will start being used instead of the normal palette.")
|
||||
private double topThreshold = 1.0;
|
||||
|
||||
public int getHeight(RNG rng, double x, double z, IrisData data) {
|
||||
public int getHeight(RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (stackMin == stackMax) {
|
||||
return stackMin;
|
||||
}
|
||||
|
||||
return getHeightGenerator(rng, data)
|
||||
return getHeightGenerator(rng, runtime)
|
||||
.fit(stackMin, stackMax,
|
||||
x / heightVariance.getZoom(),
|
||||
z / heightVariance.getZoom());
|
||||
}
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).height;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() ->
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
|
||||
public CNG getHeightGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).heightGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
public CNG getGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).layer;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() -> style.create(rng.nextParallelRNG(getBlockData(data).size()), data));
|
||||
public CNG getGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).layerGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
public CNG getVarianceGenerator(RNG rng, IrisData data) {
|
||||
AtomicCache<CNG> cache = generators(rng, data).variance;
|
||||
CNG cached = cache.getIfPresent();
|
||||
return cached != null ? cached : cache.aquire(() -> createVarianceGenerator(rng, data));
|
||||
public CNG getVarianceGenerator(RNG rng, PackRuntime runtime) {
|
||||
return runtime.decorator(this).varianceGenerator(rng.getSeed());
|
||||
}
|
||||
|
||||
private Generators generators(RNG rng, IrisData data) {
|
||||
long seed = rng.getSeed();
|
||||
Engine engine = data == null ? null : data.getEngine();
|
||||
Generators recent = recentGenerators;
|
||||
if (recent != null && recent.key.seed == seed && recent.key.data == data && recent.key.engine == engine) {
|
||||
return recent;
|
||||
}
|
||||
Generators selected = generators.computeIfAbsent(new GeneratorKey(seed, data, engine), Generators::new);
|
||||
recentGenerators = selected;
|
||||
return selected;
|
||||
public CNG createHeightGenerator(long seed, PackRuntime runtime) {
|
||||
return heightVariance.create(new RNG(seed).nextParallelRNG(getBlockData(runtime.data()).size() + stackMax + stackMin), runtime);
|
||||
}
|
||||
|
||||
private CNG createVarianceGenerator(RNG rng, IrisData data) {
|
||||
return variance.createNoCache(deriveVarianceSeed(rng, data), data).scale(1D / variance.getZoom());
|
||||
public CNG createLayerGenerator(long seed, PackRuntime runtime) {
|
||||
return style.create(new RNG(seed).nextParallelRNG(getBlockData(runtime.data()).size()), runtime);
|
||||
}
|
||||
|
||||
public CNG createVarianceGenerator(long seed, PackRuntime runtime) {
|
||||
return variance.createNoCache(deriveVarianceSeed(new RNG(seed), runtime.data()), runtime).scale(1D / variance.getZoom());
|
||||
}
|
||||
|
||||
RNG deriveVarianceSeed(RNG rng, IrisData data) {
|
||||
@@ -173,27 +160,38 @@ public class IrisDecorator {
|
||||
return palette;
|
||||
}
|
||||
|
||||
public boolean passesChanceGate(RNG rng, double x, double z, IrisData data) {
|
||||
if (getBlockData(data).isEmpty()) {
|
||||
public boolean passesChanceGate(RNG rng, double x, double z, PackRuntime runtime) {
|
||||
return passesChanceGate(rng, x, z, runtime.decorator(this));
|
||||
}
|
||||
|
||||
/** {@link #passesChanceGate(RNG, double, double, PackRuntime)} for a caller that already holds this decorator's runtime. */
|
||||
public boolean passesChanceGate(RNG rng, double x, double z, DecoratorRuntime decoratorRuntime) {
|
||||
if (getBlockData(decoratorRuntime.packRuntime().data()).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
return getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance;
|
||||
double blocksPerSample = chanceBlocksPerSample();
|
||||
double xx = x / blocksPerSample;
|
||||
double zz = z / blocksPerSample;
|
||||
return decoratorRuntime.layerGenerator(rng.getSeed()).fitDouble(0D, 1D, xx, zz) <= chance;
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) {
|
||||
if (!passesChanceGate(rng, x, z, data)) {
|
||||
/** A style without a seed divides by its zoom here on top of its own scale; a seeded one is read in plain blocks. */
|
||||
private double chanceBlocksPerSample() {
|
||||
return style.isSeeded() ? 1 : style.getZoom();
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData(IrisBiome b, RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (!passesChanceGate(rng, x, z, runtime)) {
|
||||
return null;
|
||||
}
|
||||
if (getBlockData(data).size() == 1) {
|
||||
return getBlockData(data).get(0);
|
||||
if (getBlockData(runtime.data()).size() == 1) {
|
||||
return getBlockData(runtime.data()).get(0);
|
||||
}
|
||||
return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x);
|
||||
return getVarianceGenerator(rng, runtime).fit(getBlockData(runtime.data()), z, x);
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
KList<NativeBlockState> palette = getBlockData(data);
|
||||
public NativeBlockState getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
KList<NativeBlockState> palette = getBlockData(runtime.data());
|
||||
if (palette.isEmpty()) {
|
||||
IrisLogging.warnOnce("decorator-empty:" + b.getName(), "Empty Block Data for " + b.getName());
|
||||
return null;
|
||||
@@ -203,24 +201,25 @@ public class IrisDecorator {
|
||||
return palette.get(0);
|
||||
}
|
||||
|
||||
return getVarianceGenerator(rng, data).fit(palette, z, y, x); //X and Z must be switched
|
||||
return getVarianceGenerator(rng, runtime).fit(palette, z, y, x); //X and Z must be switched
|
||||
}
|
||||
|
||||
public NativeBlockState getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
KList<NativeBlockState> topPalette = getBlockDataTops(data);
|
||||
public NativeBlockState getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
KList<NativeBlockState> topPalette = getBlockDataTops(runtime.data());
|
||||
if (topPalette.isEmpty()) {
|
||||
return getBlockData100(b, rng, x, y, z, data);
|
||||
return getBlockData100(b, rng, x, y, z, runtime);
|
||||
}
|
||||
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
double blocksPerSample = chanceBlocksPerSample();
|
||||
double xx = x / blocksPerSample;
|
||||
double zz = z / blocksPerSample;
|
||||
|
||||
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (getGenerator(rng, runtime).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (topPalette.size() == 1) {
|
||||
return topPalette.get(0);
|
||||
}
|
||||
|
||||
return getVarianceGenerator(rng, data).fit(topPalette, z, y, x); //X and Z must be switched
|
||||
return getVarianceGenerator(rng, runtime).fit(topPalette, z, y, x); //X and Z must be switched
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -336,55 +335,30 @@ public class IrisDecorator {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
public NativeBlockState pickBlockData(RNG rng, IrisData data, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataArray(data);
|
||||
public NativeBlockState pickBlockData(RNG rng, PackRuntime runtime, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataArray(runtime.data());
|
||||
if (arr.length == 0) {
|
||||
return null;
|
||||
}
|
||||
if (arr.length == 1) {
|
||||
return arr[0];
|
||||
}
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, runtime).fit(0, arr.length - 1, z, x))];
|
||||
}
|
||||
|
||||
public NativeBlockState pickBlockDataTop(RNG rng, IrisData data, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataTopsArray(data);
|
||||
public NativeBlockState pickBlockDataTop(RNG rng, PackRuntime runtime, double x, double z) {
|
||||
NativeBlockState[] arr = getBlockDataTopsArray(runtime.data());
|
||||
if (arr.length == 0) {
|
||||
return pickBlockData(rng, data, x, z);
|
||||
return pickBlockData(rng, runtime, x, z);
|
||||
}
|
||||
if (arr.length == 1) {
|
||||
return arr[0];
|
||||
}
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, data).fit(0, arr.length - 1, z, x))];
|
||||
return arr[Math.abs((int) getVarianceGenerator(rng, runtime).fit(0, arr.length - 1, z, x))];
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean isStacking() {
|
||||
return getStackMax() > 1;
|
||||
}
|
||||
|
||||
private static final class Generators {
|
||||
private final GeneratorKey key;
|
||||
private final AtomicCache<CNG> layer = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> variance = new AtomicCache<>();
|
||||
private final AtomicCache<CNG> height = new AtomicCache<>();
|
||||
|
||||
private Generators(GeneratorKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
private record GeneratorKey(long seed, IrisData data, Engine engine) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof GeneratorKey key
|
||||
&& seed == key.seed && data == key.data && engine == key.engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (31 * Long.hashCode(seed) + System.identityHashCode(data))
|
||||
+ System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-37
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.block.IrisBlockData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
@@ -62,12 +63,10 @@ public class IrisDepositGenerator {
|
||||
private static final long FNV_OFFSET_BASIS = 0xcbf29ce484222325L;
|
||||
private static final long FNV_PRIME = 0x100000001b3L;
|
||||
|
||||
private final transient ConcurrentMap<ClumpCacheKey, KList<IrisObject>> objects = new ConcurrentHashMap<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> blockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<Boolean> ore = new AtomicCache<>();
|
||||
private final transient AtomicCache<KSet<String>> replaceableBlockData = new AtomicCache<>();
|
||||
private final transient AtomicCache<KSet<String>> surfaceReplaceableBlockData = new AtomicCache<>();
|
||||
private final transient ConcurrentMap<ClumpCacheKey, KList<IrisObject>> scaledObjects = new ConcurrentHashMap<>();
|
||||
@Required
|
||||
@MinNumber(-8192)
|
||||
@MaxNumber(8192)
|
||||
@@ -145,54 +144,47 @@ public class IrisDepositGenerator {
|
||||
@Description("If set to true, this deposit will replace bedrock")
|
||||
private boolean replaceBedrock = false;
|
||||
|
||||
public IrisObject getClump(Engine engine, RNG rng, IrisData rdata) {
|
||||
public IrisObject getClump(PackRuntime runtime, RNG rng) {
|
||||
if (shape != IrisDepositShape.IRIS) {
|
||||
return generateConfiguredClumpObject(rng, rdata, minSize, maxSize);
|
||||
return generateConfiguredClumpObject(rng, runtime.data(), minSize, maxSize);
|
||||
}
|
||||
|
||||
ClumpCacheKey cacheKey = new ClumpCacheKey(engine.getSeedManager().getDeposit(), minSize, maxSize);
|
||||
KList<IrisObject> objects = this.objects.computeIfAbsent(cacheKey, key -> {
|
||||
RNG rngv = new RNG(key.depositSeed() + stableClumpSalt(rdata));
|
||||
KList<IrisObject> objectsf = new KList<>();
|
||||
|
||||
for (int i = 0; i < varience; i++) {
|
||||
objectsf.add(generateClumpObject(
|
||||
rngv.nextParallelRNG(2349 * i + 3598), rdata, key.minSize(), key.maxSize()));
|
||||
}
|
||||
|
||||
return objectsf;
|
||||
});
|
||||
KList<IrisObject> objects = runtime.deposit(this).clumps();
|
||||
return objects.get(rng.i(0, objects.size()));
|
||||
}
|
||||
|
||||
public IrisObject getClump(Engine engine, RNG rng, IrisData rdata, double sizeMultiplier) {
|
||||
public IrisObject getClump(PackRuntime runtime, RNG rng, double sizeMultiplier) {
|
||||
if (sizeMultiplier == 1D) {
|
||||
return getClump(engine, rng, rdata);
|
||||
return getClump(runtime, rng);
|
||||
}
|
||||
|
||||
int scaledMinSize = scaledDepositSize(minSize, sizeMultiplier);
|
||||
int scaledMaxSize = scaledDepositSize(maxSize, sizeMultiplier);
|
||||
if (shape != IrisDepositShape.IRIS) {
|
||||
return generateConfiguredClumpObject(rng, rdata, scaledMinSize, scaledMaxSize);
|
||||
return generateConfiguredClumpObject(rng, runtime.data(), scaledMinSize, scaledMaxSize);
|
||||
}
|
||||
|
||||
ClumpCacheKey cacheKey = new ClumpCacheKey(
|
||||
engine.getSeedManager().getDeposit(), scaledMinSize, scaledMaxSize);
|
||||
KList<IrisObject> objects = scaledObjects.computeIfAbsent(cacheKey, key -> {
|
||||
long sizeSeed = ((long) key.minSize() << 32) ^ (key.maxSize() & 0xffffffffL);
|
||||
RNG rngv = new RNG(key.depositSeed() + stableClumpSalt(rdata) + sizeSeed);
|
||||
KList<IrisObject> generated = new KList<>();
|
||||
|
||||
for (int i = 0; i < varience; i++) {
|
||||
generated.add(generateClumpObject(
|
||||
rngv.nextParallelRNG(2349 * i + 3598), rdata, key.minSize(), key.maxSize()));
|
||||
}
|
||||
|
||||
return generated;
|
||||
});
|
||||
KList<IrisObject> objects = runtime.deposit(this).scaledClumps(scaledMinSize, scaledMaxSize);
|
||||
return objects.get(rng.i(0, objects.size()));
|
||||
}
|
||||
|
||||
public KList<IrisObject> createClumps(long depositSeed, IrisData rdata) {
|
||||
return createClumpVariants(new RNG(depositSeed + stableClumpSalt(rdata)), rdata, minSize, maxSize);
|
||||
}
|
||||
|
||||
public KList<IrisObject> createScaledClumps(long depositSeed, int scaledMinSize, int scaledMaxSize, IrisData rdata) {
|
||||
long sizeSeed = ((long) scaledMinSize << 32) ^ (scaledMaxSize & 0xffffffffL);
|
||||
return createClumpVariants(new RNG(depositSeed + stableClumpSalt(rdata) + sizeSeed), rdata, scaledMinSize, scaledMaxSize);
|
||||
}
|
||||
|
||||
private KList<IrisObject> createClumpVariants(RNG rngv, IrisData rdata, int clumpMinSize, int clumpMaxSize) {
|
||||
KList<IrisObject> variants = new KList<>();
|
||||
for (int i = 0; i < varience; i++) {
|
||||
variants.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598), rdata, clumpMinSize, clumpMaxSize));
|
||||
}
|
||||
return variants;
|
||||
}
|
||||
|
||||
public int getMaxDimension() {
|
||||
return Math.min(11, (int) Math.ceil(Math.cbrt(maxSize)));
|
||||
}
|
||||
@@ -279,7 +271,7 @@ public class IrisDepositGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Advances {@code rng} exactly as {@link #getClump(Engine, RNG, IrisData)} would and reports the clump's width
|
||||
* Advances {@code rng} exactly as {@link #getClump(PackRuntime, RNG)} would and reports the clump's width
|
||||
* and lowest block offset without building it, so a caller can reject the clump first and replay the build
|
||||
* only for clumps it keeps. Returns null without drawing when the shape has no footprint path.
|
||||
*/
|
||||
@@ -682,9 +674,6 @@ public class IrisDepositGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
record ClumpCacheKey(long depositSeed, int minSize, int maxSize) {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface CellSink {
|
||||
void add(int x, int y, int z);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.pack.value.IrisRange;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
@@ -11,20 +10,24 @@ import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* One ore list (a biome's, region's or dimension's surface or underground ores) indexed by Y. Each Y
|
||||
* holds the generators whose range contains it, in list order, so resolving a block tries exactly
|
||||
* the generators that could place there and still returns the first one that does.
|
||||
* holds the indices of the generators whose range contains it, in list order, so resolving a block tries exactly
|
||||
* the generators that could place there and still returns the first one that does. The seeded chance fields live in
|
||||
* an {@link OreBandsRuntime}, aligned with {@link #generators()}.
|
||||
*/
|
||||
public final class IrisOreBands {
|
||||
public static final IrisOreBands EMPTY = new IrisOreBands(new IrisOreGenerator[0], 0, -1, null);
|
||||
private static final int MAXIMUM_INDEXED_HEIGHT = 8192;
|
||||
|
||||
private final IrisOreGenerator[] generators;
|
||||
private final int[] everyGenerator;
|
||||
private final int minY;
|
||||
private final int maxY;
|
||||
private final IrisOreGenerator[][] byY;
|
||||
private final int[][] byY;
|
||||
|
||||
private IrisOreBands(IrisOreGenerator[] generators, int minY, int maxY, IrisOreGenerator[][] byY) {
|
||||
private IrisOreBands(IrisOreGenerator[] generators, int minY, int maxY, int[][] byY) {
|
||||
this.generators = generators;
|
||||
this.everyGenerator = new int[generators.length];
|
||||
Arrays.setAll(everyGenerator, index -> index);
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
this.byY = byY;
|
||||
@@ -57,19 +60,19 @@ public final class IrisOreBands {
|
||||
height > MAXIMUM_INDEXED_HEIGHT ? null : index(generators, minY, (int) height));
|
||||
}
|
||||
|
||||
private static IrisOreGenerator[][] index(IrisOreGenerator[] generators, int minY, int height) {
|
||||
IrisOreGenerator[][] byY = new IrisOreGenerator[height][];
|
||||
IrisOreGenerator[] scratch = new IrisOreGenerator[generators.length];
|
||||
IrisOreGenerator[] previous = null;
|
||||
private static int[][] index(IrisOreGenerator[] generators, int minY, int height) {
|
||||
int[][] byY = new int[height][];
|
||||
int[] scratch = new int[generators.length];
|
||||
int[] previous = null;
|
||||
for (int offset = 0; offset < height; offset++) {
|
||||
int y = minY + offset;
|
||||
int count = 0;
|
||||
for (IrisOreGenerator generator : generators) {
|
||||
if (generator.getRange().contains(y)) {
|
||||
scratch[count++] = generator;
|
||||
for (int index = 0; index < generators.length; index++) {
|
||||
if (generators[index].getRange().contains(y)) {
|
||||
scratch[count++] = index;
|
||||
}
|
||||
}
|
||||
IrisOreGenerator[] candidates = Arrays.copyOf(scratch, count);
|
||||
int[] candidates = Arrays.copyOf(scratch, count);
|
||||
byY[offset] = previous != null && Arrays.equals(previous, candidates) ? previous : candidates;
|
||||
previous = byY[offset];
|
||||
}
|
||||
@@ -92,13 +95,18 @@ public final class IrisOreBands {
|
||||
return y >= minY && y <= maxY;
|
||||
}
|
||||
|
||||
/** The banded generators in list order; chance fields built for them must keep this order. */
|
||||
public IrisOreGenerator[] generators() {
|
||||
return generators.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* The ore placed at a Y inside {@link #contains(int)}, or null when no generator places one.
|
||||
*/
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data, Engine engine) {
|
||||
IrisOreGenerator[] candidates = byY == null ? generators : byY[y - minY];
|
||||
for (IrisOreGenerator candidate : candidates) {
|
||||
NativeBlockState ore = candidate.generate(x, y, z, rng, data, engine);
|
||||
NativeBlockState generate(int x, int y, int z, RNG rng, IrisOreGenerator.OreChance[] chances, PackRuntime runtime) {
|
||||
int[] candidates = byY == null ? everyGenerator : byY[y - minY];
|
||||
for (int index : candidates) {
|
||||
NativeBlockState ore = generators[index].generate(x, y, z, rng, chances[index], runtime);
|
||||
if (ore != null) {
|
||||
return ore;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.pack.value.IrisRange;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
@@ -56,72 +56,46 @@ public class IrisOreGenerator {
|
||||
@Description("Vertical band (min, max) this ore can generate in, in engine-local Y where 0 is the bottom of the dimension, not world Y.")
|
||||
private IrisRange range = new IrisRange(30, 80);
|
||||
|
||||
private final transient LazyBoundedCache<ChanceKey, OreChance> chanceCache = new LazyBoundedCache<>(32);
|
||||
private transient volatile CachedChance recentChance;
|
||||
|
||||
public void warm(RNG rng, IrisData data) {
|
||||
chance(rng, data);
|
||||
palette.getLayerGenerator(rng, data);
|
||||
public void warm(RNG rng, PackRuntime runtime) {
|
||||
runtime.oreChance(this, rng.getSeed());
|
||||
palette.getLayerGenerator(rng, runtime);
|
||||
}
|
||||
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data) {
|
||||
return generate(x, y, z, rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, IrisData data, Engine engine) {
|
||||
if (threshold <= 0 || !range.contains(y)) {
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, PackRuntime runtime) {
|
||||
if (!canPlaceAt(y)) {
|
||||
return null;
|
||||
}
|
||||
return placeByChance(x, y, z, rng, runtime.oreChance(this, rng.getSeed()), runtime);
|
||||
}
|
||||
|
||||
if (palette.getPalette().isEmpty()) {
|
||||
/** Places with a chance field already resolved for {@code rng}'s seed, as {@link OreBandsRuntime} holds them. */
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng, OreChance chance, PackRuntime runtime) {
|
||||
if (!canPlaceAt(y)) {
|
||||
return null;
|
||||
}
|
||||
return placeByChance(x, y, z, rng, chance, runtime);
|
||||
}
|
||||
|
||||
if (chance(rng, data, engine).sample(x, y, z) > threshold) {
|
||||
private boolean canPlaceAt(int y) {
|
||||
return threshold > 0 && range.contains(y) && !palette.getPalette().isEmpty();
|
||||
}
|
||||
|
||||
private NativeBlockState placeByChance(int x, int y, int z, RNG rng, OreChance chance, PackRuntime runtime) {
|
||||
if (chance.sample(x, y, z) > threshold) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return palette.get(rng, x, y, z, data);
|
||||
return palette.get(rng, x, y, z, runtime);
|
||||
}
|
||||
|
||||
private OreChance chance(RNG rng, IrisData data) {
|
||||
return chance(rng, data, data == null ? null : data.getEngine());
|
||||
}
|
||||
|
||||
private OreChance chance(RNG rng, IrisData data, Engine engine) {
|
||||
long seed = rng.getSeed();
|
||||
CachedChance recent = recentChance;
|
||||
if (recent != null && recent.key.seed == seed && recent.key.data == data && recent.key.engine == engine) {
|
||||
return recent.chance;
|
||||
}
|
||||
ChanceKey key = new ChanceKey(seed, data, engine);
|
||||
OreChance selected = chanceCache.computeIfAbsent(key, ignored -> OreChance.of(chanceStyle.create(rng, data)));
|
||||
recentChance = new CachedChance(key, selected);
|
||||
return selected;
|
||||
}
|
||||
|
||||
private record ChanceKey(long seed, IrisData data, Engine engine) {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof ChanceKey key
|
||||
&& seed == key.seed && data == key.data && engine == key.engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (31 * Long.hashCode(seed) + System.identityHashCode(data))
|
||||
+ System.identityHashCode(engine);
|
||||
}
|
||||
}
|
||||
|
||||
private record CachedChance(ChanceKey key, OreChance chance) {
|
||||
public OreChance createChance(long seed, PackRuntime runtime) {
|
||||
return OreChance.of(chanceStyle.create(new RNG(seed), runtime));
|
||||
}
|
||||
|
||||
/**
|
||||
* The chance field, with its single value resolved once when it is constant (a FLAT style),
|
||||
* which bands such as a full deepslate layer sample at every block.
|
||||
*/
|
||||
private record OreChance(CNG noise, boolean constant, double value) {
|
||||
public record OreChance(CNG noise, boolean constant, double value) {
|
||||
private static OreChance of(CNG noise) {
|
||||
boolean constant = noise.isConstant();
|
||||
return new OreChance(noise, constant, constant ? noise.noise(0D, 0D, 0D) : 0D);
|
||||
|
||||
@@ -19,22 +19,11 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
import art.arcane.iris.generation.geometry.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Shared low-level helpers for building procedural objects in memory: resolving a
|
||||
* single block id or a noise palette into a platform block state, and assembling a
|
||||
* raw block map into a centered IrisObject anchored so its y=0 layer sits one block
|
||||
* above the terrain surface (same convention the tree generator uses).
|
||||
* Block state helpers shared by object placement, decorators, terrain and the procedural objects: reading a state's
|
||||
* properties and material, normalizing waterlogging and spotting blocks that fall.
|
||||
*/
|
||||
public final class IrisProceduralBlocks {
|
||||
public static final String[] FACE_PROPERTIES = {"north", "east", "south", "west", "up", "down"};
|
||||
@@ -57,16 +46,6 @@ public final class IrisProceduralBlocks {
|
||||
return palette != null && palette.getPalette() != null && !palette.getPalette().isEmpty();
|
||||
}
|
||||
|
||||
public static NativeBlockState resolve(String block, IrisMaterialPalette palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
if (paletteSet(palette)) {
|
||||
return palette.get(paletteRng, x, y, z, data);
|
||||
}
|
||||
if (block != null && !block.isEmpty()) {
|
||||
return B.getStateOrNull(block, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasProperty(NativeBlockState state, String property) {
|
||||
String key = state.key();
|
||||
int start = propertyStart(key, property);
|
||||
@@ -158,43 +137,4 @@ public final class IrisProceduralBlocks {
|
||||
String value = submerged && (enabled || authored) ? "true" : "false";
|
||||
return value.equals(current) ? state : state.withProperty("waterlogged", value);
|
||||
}
|
||||
|
||||
public static IrisObject assemble(Map<Vector3i, NativeBlockState> blocks) {
|
||||
if (blocks == null || blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int minZ = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
for (Vector3i v : blocks.keySet()) {
|
||||
minX = Math.min(minX, v.getBlockX());
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
minZ = Math.min(minZ, v.getBlockZ());
|
||||
maxX = Math.max(maxX, v.getBlockX());
|
||||
maxY = Math.max(maxY, v.getBlockY());
|
||||
maxZ = Math.max(maxZ, v.getBlockZ());
|
||||
}
|
||||
|
||||
int w = maxX - minX + 1;
|
||||
int h = maxY - minY + 1;
|
||||
int d = maxZ - minZ + 1;
|
||||
int cx = w / 2;
|
||||
int cy = h / 2;
|
||||
int cz = d / 2;
|
||||
|
||||
IrisObject object = new IrisObject(w, h, d);
|
||||
for (Map.Entry<Vector3i, NativeBlockState> entry : blocks.entrySet()) {
|
||||
Vector3i v = entry.getKey();
|
||||
int nx = v.getBlockX() - minX - cx;
|
||||
int ny = v.getBlockY() - cy + 1;
|
||||
int nz = v.getBlockZ() - minZ - cz;
|
||||
object.getBlocks().put(new IrisBlockVector(nx, ny, nz), entry.getValue());
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.decoration.coral.IrisCoral;
|
||||
import art.arcane.iris.generation.decoration.crystal.IrisCrystal;
|
||||
import art.arcane.iris.generation.decoration.formation.IrisFormation;
|
||||
import art.arcane.iris.generation.decoration.fungus.IrisFungus;
|
||||
import art.arcane.iris.generation.decoration.ruin.IrisRuin;
|
||||
import art.arcane.iris.generation.decoration.tree.IrisProceduralTree;
|
||||
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("procedural-objects")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("Procedurally generated objects placed in a biome or region. Unlike the objects block (which loads iob files), these are generated from scratch at world-gen time.")
|
||||
@Data
|
||||
public class IrisProceduralObjects {
|
||||
@ArrayType(min = 1, type = IrisProceduralTree.class)
|
||||
@Description("Procedurally generated trees.")
|
||||
private KList<IrisProceduralTree> trees = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuin.class)
|
||||
@Description("Procedurally generated ruins (crumbling pillars, walls, arches, rubble).")
|
||||
private KList<IrisRuin> ruins = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFormation.class)
|
||||
@Description("Procedurally generated natural rock formations (spires, hoodoos, arches, sea stacks, boulders, basalt columns).")
|
||||
private KList<IrisFormation> formations = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCoral.class)
|
||||
@Description("Procedurally generated underwater coral structures.")
|
||||
private KList<IrisCoral> coral = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFungus.class)
|
||||
@Description("Procedurally generated mushrooms and shelf fungi.")
|
||||
private KList<IrisFungus> fungi = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCrystal.class)
|
||||
@Description("Procedurally generated crystal clusters (usually placed in caves).")
|
||||
private KList<IrisCrystal> crystals = new KList<>();
|
||||
|
||||
public KList<IrisProceduralPlacement> getAllPlacements() {
|
||||
KList<IrisProceduralPlacement> all = new KList<>();
|
||||
if (trees != null) {
|
||||
all.addAll(trees);
|
||||
}
|
||||
if (ruins != null) {
|
||||
all.addAll(ruins);
|
||||
}
|
||||
if (formations != null) {
|
||||
all.addAll(formations);
|
||||
}
|
||||
if (coral != null) {
|
||||
all.addAll(coral);
|
||||
}
|
||||
if (fungi != null) {
|
||||
all.addAll(fungi);
|
||||
}
|
||||
if (crystals != null) {
|
||||
all.addAll(crystals);
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getAllPlacements().isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* A procedurally generated, placeable thing in a biome or region (trees, ruins,
|
||||
* formations, coral, fungi, crystals). Implementations bake a deterministic pool
|
||||
* of in-memory IrisObject variants and expose the placement controls the engine
|
||||
* needs to scatter them, exactly like an object placement but generated from
|
||||
* scratch instead of loaded from an iob file.
|
||||
*/
|
||||
public interface IrisProceduralPlacement {
|
||||
String getName();
|
||||
|
||||
double getChance();
|
||||
|
||||
int getDensity();
|
||||
|
||||
boolean isPlausible();
|
||||
|
||||
IrisObjectPlacement asPlacement();
|
||||
|
||||
IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room);
|
||||
|
||||
KList<IrisObject> getVariantObjects(IrisData data);
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -42,27 +43,28 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, limit);
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, limit, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max, int limit) {
|
||||
IrisBiome biome, int height, int max, int limit, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (!decorator.isForcePlace() && !decorator.getSlopeCondition().isDefault()
|
||||
&& !decorator.getSlopeCondition().isValid(getComplex().getSlopeStream().get(realX, realZ))) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null) {
|
||||
data.set(x, height, z, block);
|
||||
}
|
||||
@@ -70,13 +72,13 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
int stack = Math.min(limit - height,
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height));
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height));
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = stack == 1 ? 1.0 : ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
+9
-7
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -42,25 +43,26 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, maxBaseY);
|
||||
place(decorator, x, z, realX, realZ, data, biome, height, max, maxBaseY, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max, int maxBaseY) {
|
||||
IrisBiome biome, int height, int max, int maxBaseY, PackRuntime runtime) {
|
||||
if (!decorator.isStacking()) {
|
||||
int targetY = height + 1;
|
||||
if (DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null) {
|
||||
data.set(x, targetY, z, block);
|
||||
}
|
||||
@@ -69,7 +71,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
int stack = Math.min(maxBaseY - height,
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height));
|
||||
DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height));
|
||||
for (int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
int targetY = h + 1;
|
||||
@@ -78,8 +80,8 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
double threshold = stack == 1 ? 1.0 : ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-8
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.volmlib.util.hunk.Hunk;
|
||||
@@ -78,7 +79,8 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
int max
|
||||
) {
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null) {
|
||||
return;
|
||||
@@ -90,14 +92,14 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
|
||||
try {
|
||||
placePicked(decorator, x, z, realX, realZ, data, biome, height, max);
|
||||
placePicked(decorator, x, z, realX, realZ, data, biome, height, max, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void placePicked(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
IrisBiome biome, int height, int max) {
|
||||
IrisBiome biome, int height, int max, PackRuntime runtime) {
|
||||
NativeBlockState support = data.get(x, height, z);
|
||||
if (support == null || !support.isSolid()) {
|
||||
return;
|
||||
@@ -111,7 +113,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
|| !DecoratorCore.canReplaceStackTarget(data.get(x, targetY, z), false)) {
|
||||
return;
|
||||
}
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockData100(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)
|
||||
&& IrisSugarCane.canPlace(block, data, x, targetY, z, realX, realZ, getEngine())) {
|
||||
data.set(x, targetY, z, block);
|
||||
@@ -120,7 +122,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
int stack = DecoratorCore.computeStack(decorator, partRNG, realX, realZ, getData(), max - height);
|
||||
int stack = DecoratorCore.computeStack(decorator, partRNG, realX, realZ, runtime, max - height);
|
||||
|
||||
if (stack == 1) {
|
||||
int targetY = height + 1;
|
||||
@@ -128,7 +130,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeBlockState block = decorator.getBlockDataForTop(biome, partRNG, realX, height, realZ, getData());
|
||||
NativeBlockState block = decorator.getBlockDataForTop(biome, partRNG, realX, height, realZ, runtime);
|
||||
if (block != null && DecoratorCore.isValidShorelineSupport(decorator, block, support)
|
||||
&& IrisSugarCane.canPlace(block, data, x, targetY, z, realX, realZ, getEngine())) {
|
||||
data.set(x, targetY, z, block);
|
||||
@@ -146,8 +148,8 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
NativeBlockState block = threshold >= decorator.getTopThreshold()
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, getData())
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, getData());
|
||||
? decorator.getBlockDataForTop(biome, partRNG, realX, h, realZ, runtime)
|
||||
: decorator.getBlockData100(biome, partRNG, realX, h, realZ, runtime);
|
||||
if (block == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
@@ -79,7 +80,7 @@ final class IrisSugarCane {
|
||||
}
|
||||
IrisBiome biome = complex.getTrueBiomeStream().get(x, z);
|
||||
KList<NativeBlockState> layers = biome.generateSeaLayers(x, z,
|
||||
new RNG(engine.getSeedManager().getTerrain()), fluidHeight - terrainHeight, engine.getData());
|
||||
new RNG(engine.getSeedManager().getTerrain()), fluidHeight - terrainHeight, PackRuntime.of(engine));
|
||||
int depth = fluidHeight - y;
|
||||
return supportsAdjacent(layers.hasIndex(depth) ? layers.get(depth) : complex.resolveSeaFluid(x, z));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.context.ChunkContext;
|
||||
@@ -73,21 +74,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
}
|
||||
boolean caveSkipFluid = skipsFluid(inferredType);
|
||||
RNG rng = getRNG(realX, realZ);
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, getData(), realX, realZ);
|
||||
PackRuntime runtime = PackRuntime.of(getEngine(), getData());
|
||||
IrisDecorator decorator = DecoratorCore.pickDecorator(biome, getPart(), partRNG, rng, runtime, realX, realZ);
|
||||
|
||||
if (decorator == null || !isSlopeValid(decorator, realX, height, realZ)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
place(decorator, x, z, realX, realZ, data, height, max, underwater, fluidHeight, caveSkipFluid);
|
||||
place(decorator, x, z, realX, realZ, data, height, max, underwater, fluidHeight, caveSkipFluid, runtime);
|
||||
} catch (Throwable e) {
|
||||
DecoratorCore.skip(e, decorator, getData(), realX, height, realZ, biome);
|
||||
}
|
||||
}
|
||||
|
||||
private void place(IrisDecorator decorator, int x, int z, int realX, int realZ, Hunk<NativeBlockState> data,
|
||||
int height, int max, boolean underwater, int fluidHeight, boolean caveSkipFluid) {
|
||||
int height, int max, boolean underwater, int fluidHeight, boolean caveSkipFluid, PackRuntime runtime) {
|
||||
AquaticPlacementSnapshot aquaticSnapshot = captureAquaticPlacement(
|
||||
decorator, getData(), data, x, z, height, max);
|
||||
if (decorator.isStacking()) {
|
||||
@@ -97,13 +99,17 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
opts.fluidHeight = fluidHeight;
|
||||
opts.caveSkipFluid = caveSkipFluid;
|
||||
opts.mantle = getEngine().getMantle();
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, partRNG, getData(), opts);
|
||||
try {
|
||||
DecoratorCore.placeStackUp(decorator, x, z, realX, realZ, height, max, data, partRNG, runtime, opts);
|
||||
} finally {
|
||||
opts.mantle = null;
|
||||
}
|
||||
aquaticSnapshot.restoreIfUnsupported(data, x, z);
|
||||
return;
|
||||
}
|
||||
|
||||
DecoratorCore.placeSurfaceSingle(decorator, x, z, realX, height, realZ,
|
||||
data, partRNG, getData(), underwater, caveSkipFluid, getEngine().getMantle());
|
||||
data, partRNG, runtime, underwater, caveSkipFluid, getEngine().getMantle());
|
||||
aquaticSnapshot.restoreIfUnsupported(data, x, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* What one engine derives from an {@link IrisOreBands} for one seed: the chance field of every banded generator,
|
||||
* resolved once so placing ores block by block reads plain fields instead of looking each generator up.
|
||||
*/
|
||||
public final class OreBandsRuntime {
|
||||
private final IrisOreBands bands;
|
||||
private final PackRuntime runtime;
|
||||
private final IrisOreGenerator.OreChance[] chances;
|
||||
|
||||
public OreBandsRuntime(IrisOreBands bands, long seed, PackRuntime runtime) {
|
||||
this.bands = bands;
|
||||
this.runtime = runtime;
|
||||
IrisOreGenerator[] generators = bands.generators();
|
||||
this.chances = new IrisOreGenerator.OreChance[generators.length];
|
||||
for (int index = 0; index < generators.length; index++) {
|
||||
chances[index] = runtime.oreChance(generators[index], seed);
|
||||
}
|
||||
}
|
||||
|
||||
public IrisOreBands bands() {
|
||||
return bands;
|
||||
}
|
||||
|
||||
public boolean hasOres() {
|
||||
return bands.hasOres();
|
||||
}
|
||||
|
||||
public int lowestY() {
|
||||
return bands.lowestY();
|
||||
}
|
||||
|
||||
public int highestY() {
|
||||
return bands.highestY();
|
||||
}
|
||||
|
||||
public boolean contains(int y) {
|
||||
return bands.contains(y);
|
||||
}
|
||||
|
||||
/** The ore placed at a Y inside {@link #contains(int)}, or null when no generator places one. */
|
||||
public NativeBlockState generate(int x, int y, int z, RNG rng) {
|
||||
return bands.generate(x, y, z, rng, chances, runtime);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.coral;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CoralCanvas {
|
||||
public enum Role {
|
||||
STRUCTURE,
|
||||
TIP
|
||||
}
|
||||
|
||||
private static final long BIAS = 1L << 20;
|
||||
private static final long MASK = (1L << 21) - 1L;
|
||||
|
||||
private final Map<Long, Role> cells = new HashMap<>();
|
||||
|
||||
public void set(int x, int y, int z, Role role) {
|
||||
if (y < 0) {
|
||||
return;
|
||||
}
|
||||
long key = encode(x, y, z);
|
||||
Role existing = cells.get(key);
|
||||
if (existing == Role.TIP && role == Role.STRUCTURE) {
|
||||
return;
|
||||
}
|
||||
cells.put(key, role);
|
||||
}
|
||||
|
||||
public Map<Long, Role> getCells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
public static long encode(int x, int y, int z) {
|
||||
long ex = (x + BIAS) & MASK;
|
||||
long ey = (y + BIAS) & MASK;
|
||||
long ez = (z + BIAS) & MASK;
|
||||
return (ex << 42) | (ey << 21) | ez;
|
||||
}
|
||||
|
||||
public static int[] decode(long key) {
|
||||
int ez = (int) ((key & MASK) - BIAS);
|
||||
int ey = (int) (((key >> 21) & MASK) - BIAS);
|
||||
int ex = (int) (((key >> 42) & MASK) - BIAS);
|
||||
return new int[]{ex, ey, ez};
|
||||
}
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.coral;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CoralGenerator {
|
||||
private static final double GOLDEN_ANGLE = 137.50776405003785;
|
||||
|
||||
private CoralGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCoral coral, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(coral.getHeightMin(), coral.getHeightMax());
|
||||
int hi = Math.max(coral.getHeightMin(), coral.getHeightMax());
|
||||
int height = Math.max(2, rng.i(lo, hi + 1));
|
||||
long shapeSeed = rng.getSeed() + variantIndex * 31L;
|
||||
|
||||
CoralCanvas canvas = new CoralCanvas();
|
||||
switch (coral.getForm()) {
|
||||
case BRANCHING -> buildBranching(canvas, coral, height, shapeSeed, rng);
|
||||
case FAN -> buildFan(canvas, coral, height, shapeSeed);
|
||||
case BRAIN -> buildBrain(canvas, coral, height, shapeSeed);
|
||||
case PILLAR -> buildPillar(canvas, coral, height, shapeSeed);
|
||||
case TENDRIL -> buildTendril(canvas, coral, height, shapeSeed, rng);
|
||||
}
|
||||
|
||||
Map<Vector3i, NativeBlockState> resolved = resolve(canvas, coral, data);
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildBranching(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
int stalkTop = Math.max(1, (int) Math.round(height * 0.5));
|
||||
for (int y = 0; y < stalkTop; y++) {
|
||||
placeWavy(canvas, coral, 0, y, 0, y, seed, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
|
||||
int count = Math.max(1, coral.getBranchCount());
|
||||
for (int b = 0; b < count; b++) {
|
||||
double az = branchAzimuth(coral, b, count, rng);
|
||||
int startY = stalkTop - 1 + (int) Math.round((b % 2) * 1.0);
|
||||
double[] tip = rasterizeArm(canvas, coral, 0, startY, 0, az,
|
||||
coral.getBranchElevation(), coral.getBranchLength(), seed + b * 131L);
|
||||
|
||||
placeTipCluster(canvas, coral, (int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
coral.getTipClusterRadius(), seed + b * 977L);
|
||||
|
||||
if (coral.isSubBranches()) {
|
||||
int subCount = Math.max(1, coral.getSubBranchCount());
|
||||
for (int s = 0; s < subCount; s++) {
|
||||
double subAz = az + (s - (subCount - 1) / 2.0) * 35.0;
|
||||
double subLen = coral.getBranchLength() * coral.getSubBranchScale();
|
||||
double[] subTip = rasterizeArm(canvas, coral,
|
||||
(int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
subAz, coral.getBranchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
|
||||
placeTipCluster(canvas, coral, (int) Math.round(subTip[0]), (int) Math.round(subTip[1]), (int) Math.round(subTip[2]),
|
||||
Math.max(0, coral.getTipClusterRadius() - 1), seed + b * 977L + s * 53L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildFan(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int half = Math.max(1, coral.getFanWidth());
|
||||
int tippedWidth = -1;
|
||||
for (int y = height - 1; y >= 0; y--) {
|
||||
double t = y / (double) Math.max(1, height - 1);
|
||||
double profile = Math.sin(Math.PI * t);
|
||||
int w = (int) Math.round(half * profile);
|
||||
for (int dx = -w; dx <= w; dx++) {
|
||||
canvas.set(dx, y, 0, CoralCanvas.Role.STRUCTURE);
|
||||
if (Math.abs(dx) > tippedWidth) {
|
||||
placeTip(canvas, coral, dx, y, 0, seed + dx);
|
||||
}
|
||||
}
|
||||
tippedWidth = Math.max(tippedWidth, w);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildBrain(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getBrainRadius());
|
||||
int ry = Math.max(1, Math.min(r, (int) Math.round(height * 0.6)));
|
||||
double rough = coral.getBrainRoughness();
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
for (int dy = 0; dy <= ry * 2; dy++) {
|
||||
double nx = dx / (double) r;
|
||||
double ny = (dy - ry) / (double) ry;
|
||||
double nz = dz / (double) r;
|
||||
double d = nx * nx + ny * ny + nz * nz;
|
||||
double wobble = (TreeFunctions.valueNoise3D(dx, dy, dz, seed) - 0.5) * 2.0 * rough;
|
||||
if (d <= 1.0 + wobble) {
|
||||
canvas.set(dx, dy, dz, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPillar(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getPillarRadius());
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
if (dx * dx + dz * dz <= r * r) {
|
||||
canvas.set(dx, y, dz, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.getTipClusterRadius(), seed);
|
||||
}
|
||||
|
||||
private static void buildTendril(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
int count = Math.max(1, coral.getTendrilCount());
|
||||
double radius = Math.max(0.0, coral.getSpread());
|
||||
for (int c = 0; c < count; c++) {
|
||||
double az = Math.toRadians(c * (360.0 / count));
|
||||
double bx = Math.cos(az) * radius * 0.5;
|
||||
double bz = Math.sin(az) * radius * 0.5;
|
||||
int tx = (int) Math.round(bx);
|
||||
int tz = (int) Math.round(bz);
|
||||
int top = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
placeWavy(canvas, coral, tx, y, tz, y * (c + 1), seed + c * 311L, CoralCanvas.Role.STRUCTURE);
|
||||
top = y;
|
||||
}
|
||||
placeTip(canvas, coral, tx, top, tz, seed + c * 311L);
|
||||
}
|
||||
}
|
||||
|
||||
private static double[] rasterizeArm(CoralCanvas canvas, IrisCoral coral, int ox, int oy, int oz,
|
||||
double azimuthDeg, double elevationDeg, double length, long seed) {
|
||||
double azRad = Math.toRadians(azimuthDeg);
|
||||
double elRad = Math.toRadians(elevationDeg);
|
||||
double dx = length * Math.cos(elRad) * Math.sin(azRad);
|
||||
double dy = length * Math.sin(elRad);
|
||||
double dz = length * Math.cos(elRad) * Math.cos(azRad);
|
||||
int steps = Math.max(1, (int) Math.round(Math.max(Math.abs(dy), Math.max(Math.abs(dx), Math.abs(dz)))));
|
||||
|
||||
double[] tip = new double[]{ox, oy, oz};
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
double t = i / (double) steps;
|
||||
double sway = swayOffset(coral, t * length, seed);
|
||||
int x = (int) Math.round(ox + dx * t + sway);
|
||||
int y = (int) Math.round(oy + dy * t);
|
||||
int z = (int) Math.round(oz + dz * t - sway);
|
||||
canvas.set(x, y, z, CoralCanvas.Role.STRUCTURE);
|
||||
tip[0] = x;
|
||||
tip[1] = y;
|
||||
tip[2] = z;
|
||||
}
|
||||
return tip;
|
||||
}
|
||||
|
||||
private static void placeWavy(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
|
||||
double sway = swayOffset(coral, phase, seed);
|
||||
int sx = (int) Math.round(sway);
|
||||
int sz = (int) Math.round(swayOffset(coral, phase + 53.0, seed + 7L));
|
||||
canvas.set(x + sx, y, z + sz, role);
|
||||
}
|
||||
|
||||
private static double swayOffset(IrisCoral coral, double phase, long seed) {
|
||||
double amount = Math.max(0.0, Math.min(1.0, coral.getSway()));
|
||||
if (amount <= 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
double n = TreeFunctions.valueNoise1D(phase * 0.35, seed) - 0.5;
|
||||
return n * 2.0 * amount * (1.0 + coral.getSpread() * 0.25);
|
||||
}
|
||||
|
||||
private static void placeTipCluster(CoralCanvas canvas, IrisCoral coral, int cx, int cy, int cz, int radius, long seed) {
|
||||
if (radius <= 0) {
|
||||
placeTip(canvas, coral, cx, cy, cz, seed);
|
||||
return;
|
||||
}
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dy = -radius; dy <= radius; dy++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
if (dx * dx + dy * dy + dz * dz <= radius * radius) {
|
||||
canvas.set(cx + dx, cy + dy, cz + dz, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
placeTip(canvas, coral, cx, cy + radius + 1, cz, seed);
|
||||
}
|
||||
|
||||
private static void placeTip(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, long seed) {
|
||||
if (!hasTip(coral)) {
|
||||
return;
|
||||
}
|
||||
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.getTipChance()) {
|
||||
canvas.set(x, y, z, CoralCanvas.Role.TIP);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasTip(IrisCoral coral) {
|
||||
return IrisProceduralBlocks.paletteSet(coral.getTipPalette())
|
||||
|| (coral.getTipBlock() != null && !coral.getTipBlock().isEmpty());
|
||||
}
|
||||
|
||||
private static double branchAzimuth(IrisCoral coral, int index, int count, RNG rng) {
|
||||
return switch (coral.getBranchAzimuth()) {
|
||||
case GOLDEN_ANGLE -> index * GOLDEN_ANGLE;
|
||||
case EVEN -> index * (360.0 / count);
|
||||
case RANDOM -> rng.d(0.0, 360.0);
|
||||
};
|
||||
}
|
||||
|
||||
private static Map<Vector3i, NativeBlockState> resolve(CoralCanvas canvas, IrisCoral coral, IrisData data) {
|
||||
Map<Vector3i, NativeBlockState> out = new HashMap<>();
|
||||
RNG paletteRng = new RNG(coral.getSeed());
|
||||
for (Map.Entry<Long, CoralCanvas.Role> entry : canvas.getCells().entrySet()) {
|
||||
int[] xyz = CoralCanvas.decode(entry.getKey());
|
||||
int x = xyz[0];
|
||||
int y = xyz[1];
|
||||
int z = xyz[2];
|
||||
NativeBlockState state;
|
||||
if (entry.getValue() == CoralCanvas.Role.TIP) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getTipBlock(), coral.getTipPalette(), data, x, y, z, paletteRng);
|
||||
if (state == null) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
} else {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
if (coral.isWaterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
|
||||
try {
|
||||
state = state.withProperty("waterlogged", "true");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
out.put(new Vector3i(x, y, z), state);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.coral;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("coral")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated coral reef structure. Iris bakes a pool of deterministic variants from these settings and scatters them across the seafloor at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Mirrors the procedural tree system but tuned for underwater reefs: structural blocks are waterlogged so the coral stays alive, and placement defaults to anchoring on the terrain beneath the water surface.")
|
||||
@Data
|
||||
public class IrisCoral implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "coral";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per chunk for this coral to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this coral. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("The placement mode used to anchor the coral to the seafloor.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Description("Rotate this coral's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this coral may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Description("If true (default for coral), the coral anchors on the terrain height beneath the water, so it grows up from the seafloor rather than floating at the water surface.")
|
||||
private boolean underwater = true;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the seafloor.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Description("If true (default), every resolved coral block that is waterloggable is forced waterlogged so the coral does not die in water (coral fans, sea pickles and kelp also waterlog). Set false to place dead/dry coral.")
|
||||
private boolean waterlogged = true;
|
||||
|
||||
@Description("The overall silhouette this coral grows into (branching, fan, brain, pillar, tendril). Each form runs a different generation routine.")
|
||||
private IrisCoralForm form = IrisCoralForm.BRANCHING;
|
||||
|
||||
@Required
|
||||
@Description("The structural coral block (the living wood of the reef), e.g. minecraft:tube_coral_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:tube_coral_block";
|
||||
|
||||
@Description("A noise-driven palette for the structural coral block. When set this overrides the single block, letting the reef mix tube/brain/bubble/fire/horn coral_block tones across its body.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Description("Optional tip block placed at branch tips and at the very top of the structure, e.g. coral fans or minecraft:sea_pickle. Ignored when tipPalette is set. Null disables tips.")
|
||||
@RegistryListBlockType
|
||||
private String tipBlock = null;
|
||||
|
||||
@Description("A noise-driven palette for the tip block. When set this overrides the single tipBlock, letting tips mix fan / pickle decorations.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per eligible tip position to place a tip block (coral fan / sea pickle).")
|
||||
private double tipChance = 0.6;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum overall height of the coral in blocks.")
|
||||
private int heightMin = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum overall height of the coral in blocks.")
|
||||
private int heightMax = 8;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Horizontal spread of the structure in blocks. For BRANCHING this is how far arms reach out, for BRAIN/PILLAR/FAN it widens the base footprint.")
|
||||
private double spread = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Lateral noise wobble (0-1) applied to branches and tendrils so they are not ruler-straight. 0 is perfectly straight, 1 is heavily wandering.")
|
||||
private double sway = 0.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Description("BRANCHING only: how many arms sprout from the central stalk.")
|
||||
private int branchCount = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("BRANCHING only: the length of each arm in blocks before reaching its tip.")
|
||||
private double branchLength = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(90)
|
||||
@Description("BRANCHING only: the upward elevation in degrees of each arm from horizontal. 90 is straight up, 0 is flat out.")
|
||||
private double branchElevation = 55;
|
||||
|
||||
@Description("BRANCHING only: how the arms are distributed around the stalk by azimuth.")
|
||||
private IrisCoralBranchAzimuth branchAzimuth = IrisCoralBranchAzimuth.GOLDEN_ANGLE;
|
||||
|
||||
@Description("BRANCHING only: if true, each arm splits once into a small fan of sub-arms for a bushier reef.")
|
||||
private boolean subBranches = true;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(5)
|
||||
@Description("BRANCHING only: how many sub-arms each arm splits into when subBranches is true.")
|
||||
private int subBranchCount = 2;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("BRANCHING only: the length of each sub-arm as a fraction of its parent arm.")
|
||||
private double subBranchScale = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(4)
|
||||
@Description("BRANCHING and PILLAR only: the radius of the small coral tip cluster grown at each tip.")
|
||||
private int tipClusterRadius = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Description("BRAIN only: the horizontal radius of the brain-coral blob in blocks.")
|
||||
private int brainRadius = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("BRAIN only: how strongly 3D value noise perturbs the ellipsoid surface, for a wrinkled organic blob. 0 is a smooth dome.")
|
||||
private double brainRoughness = 0.35;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Description("PILLAR only: the radius of the stout vertical column in blocks.")
|
||||
private int pillarRadius = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Description("FAN only: the half-width of the upright fan plane in blocks (the disc widens toward its mid-height).")
|
||||
private int fanWidth = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Description("TENDRIL only: how many thin wavy stalks rise from the base.")
|
||||
private int tendrilCount = 4;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CoralGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.coral;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("The overall silhouette a procedural coral grows into. Each form drives a completely different generation routine in the coral generator, from tree-like branching arms to rounded brain blobs and thin wavy tendrils.")
|
||||
public enum IrisCoralForm {
|
||||
@Description("A tree-like coral built from a stout central stalk that sprouts several upward-leaning arms (distributed by golden angle or randomly), each optionally splitting once into sub-arms, with small coral tip clusters (fans / sea pickles) at the ends. The most structurally complex form and the closest analogue to a procedural tree.")
|
||||
BRANCHING,
|
||||
|
||||
@Description("A thin, single-block-thick vertical fan plane that rises and widens with height like a sheet of fire or horn coral. Reads as a flat decorative blade rather than a volume.")
|
||||
FAN,
|
||||
|
||||
@Description("A rounded, noise-perturbed ellipsoid blob of brain coral that bulges out of the seafloor like a boulder, with an irregular wrinkled surface driven by 3D value noise.")
|
||||
BRAIN,
|
||||
|
||||
@Description("A stout, thick vertical column of coral block topped with a dense tip cluster. Wider and blunter than a tendril, reading as a solid coral pillar or stack.")
|
||||
PILLAR,
|
||||
|
||||
@Description("Several very thin (one block wide) wavy stalks that rise upward and wander laterally using value noise, like a clump of swaying coral whips or kelp-thin growths.")
|
||||
TENDRIL
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
|
||||
public final class CrystalBaseBuilder {
|
||||
private CrystalBaseBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, long seed) {
|
||||
double radius = crystal.getBaseRadius();
|
||||
if (radius <= 0.0) {
|
||||
canvas.set(0, 0, 0, CrystalRole.BASE);
|
||||
return;
|
||||
}
|
||||
|
||||
double noiseStrength = crystal.getBaseNoise();
|
||||
int reach = (int) Math.ceil(radius + 1.0);
|
||||
for (int x = -reach; x <= reach; x++) {
|
||||
for (int y = -reach; y <= reach; y++) {
|
||||
for (int z = -reach; z <= reach; z++) {
|
||||
double distance = Math.sqrt((double) x * x + (double) y * y + (double) z * z);
|
||||
double wobble = (TreeFunctions.valueNoise3D(x, y, z, seed) - 0.5) * 2.0 * noiseStrength * radius;
|
||||
if (distance <= radius + wobble) {
|
||||
canvas.set(x, y, z, CrystalRole.BASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CrystalCanvas {
|
||||
private final Map<Vector3i, CrystalRole> cells = new HashMap<>();
|
||||
|
||||
public void set(int x, int y, int z, CrystalRole role) {
|
||||
Vector3i key = new Vector3i(x, y, z);
|
||||
CrystalRole existing = cells.get(key);
|
||||
if (existing == null || rank(role) > rank(existing)) {
|
||||
cells.put(key, role);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean has(int x, int y, int z) {
|
||||
return cells.containsKey(new Vector3i(x, y, z));
|
||||
}
|
||||
|
||||
public Map<Vector3i, CrystalRole> getCells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
private static int rank(CrystalRole role) {
|
||||
return switch (role) {
|
||||
case BASE -> 0;
|
||||
case SHARD -> 1;
|
||||
case TIP -> 2;
|
||||
};
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CrystalGenerator {
|
||||
private CrystalGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCrystal crystal, int variantIndex, RNG rng, IrisData data) {
|
||||
CrystalCanvas canvas = new CrystalCanvas();
|
||||
long structureSeed = rng.getSeed();
|
||||
|
||||
CrystalBaseBuilder.build(canvas, crystal, structureSeed + 977L);
|
||||
CrystalShardBuilder.build(canvas, crystal, rng);
|
||||
|
||||
Map<Vector3i, NativeBlockState> resolved = new HashMap<>();
|
||||
RNG paletteRng = new RNG(crystal.getSeed());
|
||||
RNG tipRng = new RNG(crystal.getSeed() + (variantIndex * 31337L) + 4099L);
|
||||
|
||||
for (Map.Entry<Vector3i, CrystalRole> entry : canvas.getCells().entrySet()) {
|
||||
Vector3i position = entry.getKey();
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
NativeBlockState blockData = resolveRole(crystal, entry.getValue(), data, x, y, z, paletteRng, tipRng);
|
||||
if (blockData == null) {
|
||||
continue;
|
||||
}
|
||||
resolved.put(position, blockData);
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static NativeBlockState resolveRole(IrisCrystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
return switch (role) {
|
||||
case BASE -> resolveBase(crystal, data, x, y, z, paletteRng);
|
||||
case SHARD -> resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
case TIP -> resolveTip(crystal, data, x, y, z, paletteRng, tipRng);
|
||||
};
|
||||
}
|
||||
|
||||
private static NativeBlockState resolveBase(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.getBasePalette())
|
||||
|| (crystal.getBaseBlock() != null && !crystal.getBaseBlock().isEmpty());
|
||||
if (hasBase) {
|
||||
NativeBlockState base = IrisProceduralBlocks.resolve(crystal.getBaseBlock(), crystal.getBasePalette(), data, x, y, z, paletteRng);
|
||||
if (base != null) {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static NativeBlockState resolveShard(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(crystal.getBlock(), crystal.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static NativeBlockState resolveTip(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.getTipPalette())
|
||||
|| (crystal.getTipBlock() != null && !crystal.getTipBlock().isEmpty());
|
||||
|
||||
if (hasTip) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
NativeBlockState tip = IrisProceduralBlocks.resolve(crystal.getTipBlock(), crystal.getTipPalette(), data, x, y, z, paletteRng);
|
||||
if (tip != null) {
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
if (crystal.isGlow() && crystal.getGlowBlock() != null && !crystal.getGlowBlock().isEmpty()) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
NativeBlockState glow = IrisProceduralBlocks.resolve(crystal.getGlowBlock(), null, data, x, y, z, paletteRng);
|
||||
if (glow != null) {
|
||||
return glow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
|
||||
public final class CrystalGeometry {
|
||||
private CrystalGeometry() {
|
||||
}
|
||||
|
||||
public static double[] surfaceNormal(IrisCrystalSurface surface) {
|
||||
return switch (surface) {
|
||||
case FLOOR -> new double[]{0.0, 1.0, 0.0};
|
||||
case CEILING -> new double[]{0.0, -1.0, 0.0};
|
||||
case WALL -> {
|
||||
double len = Math.sqrt(1.0 + 0.5 * 0.5);
|
||||
yield new double[]{1.0 / len, 0.5 / len, 0.0};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static double[] orthonormalBasisU(double[] normal) {
|
||||
double[] reference = Math.abs(normal[1]) > 0.99 ? new double[]{1.0, 0.0, 0.0} : new double[]{0.0, 1.0, 0.0};
|
||||
double[] u = cross(reference, normal);
|
||||
normalize(u);
|
||||
return u;
|
||||
}
|
||||
|
||||
public static double[] orthonormalBasisV(double[] normal, double[] u) {
|
||||
double[] v = cross(normal, u);
|
||||
normalize(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
public static double[] coneDirection(double[] normal, double[] u, double[] v, double coneAngleRadians, double azimuthRadians) {
|
||||
double sin = Math.sin(coneAngleRadians);
|
||||
double cos = Math.cos(coneAngleRadians);
|
||||
double ca = Math.cos(azimuthRadians);
|
||||
double sa = Math.sin(azimuthRadians);
|
||||
double[] dir = new double[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
dir[i] = cos * normal[i] + sin * (ca * u[i] + sa * v[i]);
|
||||
}
|
||||
normalize(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static double[] cross(double[] a, double[] b) {
|
||||
return new double[]{
|
||||
a[1] * b[2] - a[2] * b[1],
|
||||
a[2] * b[0] - a[0] * b[2],
|
||||
a[0] * b[1] - a[1] * b[0]
|
||||
};
|
||||
}
|
||||
|
||||
public static void normalize(double[] vec) {
|
||||
double len = Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
|
||||
if (len < 1e-9) {
|
||||
vec[0] = 0.0;
|
||||
vec[1] = 1.0;
|
||||
vec[2] = 0.0;
|
||||
return;
|
||||
}
|
||||
vec[0] /= len;
|
||||
vec[1] /= len;
|
||||
vec[2] /= len;
|
||||
}
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class CrystalShardBuilder {
|
||||
private static final double GOLDEN_ANGLE = 137.50776405003785;
|
||||
|
||||
private CrystalShardBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, RNG rng) {
|
||||
double[] normal = CrystalGeometry.surfaceNormal(crystal.getGrowthSurface());
|
||||
double[] u = CrystalGeometry.orthonormalBasisU(normal);
|
||||
double[] v = CrystalGeometry.orthonormalBasisV(normal, u);
|
||||
|
||||
int countLo = Math.min(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int countHi = Math.max(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int shardCount = Math.max(1, rng.i(countLo, countHi + 1));
|
||||
|
||||
int lengthLo = Math.min(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
int lengthHi = Math.max(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
|
||||
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.getSpreadAngle())));
|
||||
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.getJitter()));
|
||||
double emitRadius = Math.max(0.0, crystal.getBaseRadius() * 0.6);
|
||||
|
||||
for (int i = 0; i < shardCount; i++) {
|
||||
double azimuth = azimuth(crystal.getDistribution(), i, rng);
|
||||
azimuth += rng.d(-Math.PI, Math.PI) * jitterAmount * 0.5;
|
||||
|
||||
double cone = spreadRadians * fanFraction(shardCount, i, rng);
|
||||
cone += rng.d(-spreadRadians, spreadRadians) * jitterAmount * 0.5;
|
||||
cone = Math.max(0.0, Math.min(Math.PI / 2.0, cone));
|
||||
|
||||
double[] direction = CrystalGeometry.coneDirection(normal, u, v, cone, azimuth);
|
||||
|
||||
double ox = normal[0] * emitRadius + u[0] * Math.cos(azimuth) * emitRadius + v[0] * Math.sin(azimuth) * emitRadius;
|
||||
double oy = normal[1] * emitRadius + u[1] * Math.cos(azimuth) * emitRadius + v[1] * Math.sin(azimuth) * emitRadius;
|
||||
double oz = normal[2] * emitRadius + u[2] * Math.cos(azimuth) * emitRadius + v[2] * Math.sin(azimuth) * emitRadius;
|
||||
|
||||
int length = Math.max(1, rng.i(lengthLo, lengthHi + 1));
|
||||
rasterizeShard(canvas, crystal, ox, oy, oz, direction, length);
|
||||
}
|
||||
}
|
||||
|
||||
private static void rasterizeShard(CrystalCanvas canvas, IrisCrystal crystal, double ox, double oy, double oz, double[] direction, int length) {
|
||||
double baseRadius = Math.max(0.5, crystal.getShardBaseRadius());
|
||||
double taper = Math.max(0.0, Math.min(1.0, crystal.getShardTaper()));
|
||||
|
||||
int samples = Math.max(1, length * 3);
|
||||
|
||||
for (int s = 0; s <= samples; s++) {
|
||||
double t = s / (double) samples;
|
||||
double cx = ox + direction[0] * length * t;
|
||||
double cy = oy + direction[1] * length * t;
|
||||
double cz = oz + direction[2] * length * t;
|
||||
|
||||
double radius = baseRadius * (1.0 - taper * t);
|
||||
if (t >= 1.0) {
|
||||
radius = 0.0;
|
||||
}
|
||||
radius = Math.max(0.0, radius);
|
||||
|
||||
int reach = (int) Math.floor(radius);
|
||||
int centerX = (int) Math.round(cx);
|
||||
int centerY = (int) Math.round(cy);
|
||||
int centerZ = (int) Math.round(cz);
|
||||
|
||||
if (reach <= 0) {
|
||||
canvas.set(centerX, centerY, centerZ, CrystalRole.SHARD);
|
||||
} else {
|
||||
for (int dx = -reach; dx <= reach; dx++) {
|
||||
for (int dy = -reach; dy <= reach; dy++) {
|
||||
for (int dz = -reach; dz <= reach; dz++) {
|
||||
double dist = Math.sqrt((double) dx * dx + (double) dy * dy + (double) dz * dz);
|
||||
if (dist <= radius) {
|
||||
canvas.set(centerX + dx, centerY + dy, centerZ + dz, CrystalRole.SHARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int tipX = (int) Math.round(ox + direction[0] * length);
|
||||
int tipY = (int) Math.round(oy + direction[1] * length);
|
||||
int tipZ = (int) Math.round(oz + direction[2] * length);
|
||||
canvas.set(tipX, tipY, tipZ, CrystalRole.TIP);
|
||||
}
|
||||
|
||||
private static double azimuth(IrisCrystalDistribution distribution, int index, RNG rng) {
|
||||
if (distribution == IrisCrystalDistribution.GOLDEN_ANGLE) {
|
||||
return Math.toRadians(index * GOLDEN_ANGLE);
|
||||
}
|
||||
return rng.d(0.0, Math.PI * 2.0);
|
||||
}
|
||||
|
||||
private static double fanFraction(int count, int index, RNG rng) {
|
||||
if (count <= 1) {
|
||||
return rng.d(0.0, 1.0);
|
||||
}
|
||||
double base = index / (double) (count - 1);
|
||||
return Math.max(0.0, Math.min(1.0, base * 0.7 + rng.d(0.0, 0.3)));
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("crystal")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated crystal cluster: a budding base blob with faceted, tapered shards radiating from it (geode / amethyst-style). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Built for caves.")
|
||||
@Data
|
||||
public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "crystal";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per chunk for this crystal cluster to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.2;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this crystal cluster. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("The placement mode used to anchor the crystal cluster to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Description("Rotate this crystal cluster's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this crystal cluster may place on the terrain surface, under carvings, or both. Crystals are meant for caves, so this defaults to CARVING_ONLY.")
|
||||
private CarvingMode carvingSupport = CarvingMode.CARVING_ONLY;
|
||||
|
||||
@Description("If true, the crystal cluster anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Description("The surface this crystal grows from (FLOOR shards up, CEILING shards down, WALL shards outward). This orients the baked geometry only.")
|
||||
private IrisCrystalSurface growthSurface = IrisCrystalSurface.FLOOR;
|
||||
|
||||
@Required
|
||||
@Description("The primary crystal shard block, e.g. minecraft:amethyst_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:amethyst_block";
|
||||
|
||||
@Description("A noise-driven palette for the crystal shards (a prismatic mix, e.g. amethyst_block, calcite, tinted_glass). When set this overrides the single block, letting the shards mix blocks by noise. Palette wins.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Description("Optional block placed at the very tip of each shard for a different colored or sparkling point (e.g. minecraft:amethyst_cluster or glowstone). Ignored when tipPalette is set. If unset and glow is true, a light-emitting block is sprinkled among the tips instead.")
|
||||
@RegistryListBlockType
|
||||
private String tipBlock = null;
|
||||
|
||||
@Description("A noise-driven palette for the shard tips. When set this overrides the single tipBlock. Palette wins.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per shard that its very tip is replaced by the tip block (or glow block).")
|
||||
private double tipChance = 0.6;
|
||||
|
||||
@Description("If true and no tipBlock/tipPalette is set, sprinkle a light-emitting block (the glowBlock) among the shard tips for a sparkling geode.")
|
||||
private boolean glow = false;
|
||||
|
||||
@Description("The light-emitting block sprinkled among the tips when glow is true and no tip block is configured.")
|
||||
@RegistryListBlockType
|
||||
private String glowBlock = "minecraft:glowstone";
|
||||
|
||||
@Description("Optional block for the budding base blob the shards grow from, e.g. minecraft:budding_amethyst or calcite. Ignored when basePalette is set. If unset, the base is built from the primary shard block.")
|
||||
@RegistryListBlockType
|
||||
private String baseBlock = "minecraft:budding_amethyst";
|
||||
|
||||
@Description("A noise-driven palette for the budding base blob. When set this overrides the single baseBlock. Palette wins.")
|
||||
private IrisMaterialPalette basePalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Radius in blocks of the budding base blob the shards radiate from. 0 places no base blob (shards spring from a single point).")
|
||||
private double baseRadius = 1.6;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How strongly value noise perturbs the surface of the base blob, for a lumpy organic budding base rather than a clean sphere.")
|
||||
private double baseNoise = 0.35;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum number of shards radiating from the base.")
|
||||
private int shardCountMin = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum number of shards radiating from the base.")
|
||||
private int shardCountMax = 11;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum length in blocks of a shard, measured from the base out to its pointed tip.")
|
||||
private int shardLengthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum length in blocks of a shard, measured from the base out to its pointed tip.")
|
||||
private int shardLengthMax = 8;
|
||||
|
||||
@MinNumber(0.5)
|
||||
@Description("Starting radius in blocks of a shard at its thick base end. The shard tapers from this down to a single block at the tip.")
|
||||
private double shardBaseRadius = 1.4;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How aggressively each shard narrows from base to tip. 0 keeps a near-constant column; 1 tapers fully to a sharp point at the very tip. Each shard always ends in a single pointed block.")
|
||||
private double shardTaper = 0.85;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(90)
|
||||
@Description("The half-angle in degrees of the cone the shards fan within around the surface normal. 0 makes all shards parallel to the normal; larger values splay them outward into a starburst.")
|
||||
private double spreadAngle = 45;
|
||||
|
||||
@Description("How the shard azimuths are distributed around the normal (RANDOM for a chaotic clump, GOLDEN_ANGLE for an evenly spaced rosette).")
|
||||
private IrisCrystalDistribution distribution = IrisCrystalDistribution.GOLDEN_ANGLE;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Per-shard angular randomness (0-1) added on top of the chosen distribution so the cluster never looks mechanically regular. 0 is perfectly distributed; 1 is heavily jittered.")
|
||||
private double jitter = 0.25;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CrystalGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.crystal;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("The surface a crystal cluster grows from. This only orients the baked geometry (which way the shards point); placement of the object into a cave is handled by the placement system, not here.")
|
||||
public enum IrisCrystalSurface {
|
||||
@Description("Grows from a cave floor. The budding base sits at the bottom and the shards point upward, fanning within the spread cone around the up axis. Built with positive py so the cluster grows up from the base layer.")
|
||||
FLOOR,
|
||||
|
||||
@Description("Grows from a cave ceiling. The budding base sits at the top and the shards point downward like stalactites, fanning within the spread cone around the down axis. Built with negative py so the cluster grows down from the ceiling.")
|
||||
CEILING,
|
||||
|
||||
@Description("Grows from a cave wall. The budding base hugs the wall and the shards point outward and slightly upward, fanning within the spread cone around a tilted normal so the cluster reads as a wall sconce of shards.")
|
||||
WALL
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public final class FormationBlockResolver {
|
||||
private final IrisFormation formation;
|
||||
private final IrisData data;
|
||||
private final RNG paletteRng;
|
||||
private final Int2ObjectOpenHashMap<RNG> strataRngs = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public FormationBlockResolver(IrisFormation formation, IrisData data) {
|
||||
this.formation = formation;
|
||||
this.data = data;
|
||||
paletteRng = new RNG(formation.getSeed());
|
||||
}
|
||||
|
||||
public NativeBlockState resolve(FormationCanvas.Role role, Vector3i raw) {
|
||||
int x = raw.getBlockX();
|
||||
int y = raw.getBlockY();
|
||||
int z = raw.getBlockZ();
|
||||
|
||||
if (role == FormationCanvas.Role.CAP && capDefined(formation)) {
|
||||
NativeBlockState cap = IrisProceduralBlocks.resolve(formation.getCapBlock(), formation.getCapPalette(), data, x, y, z, paletteRng);
|
||||
if (cap != null) {
|
||||
return cap;
|
||||
}
|
||||
}
|
||||
|
||||
if (strataDefined(formation)) {
|
||||
IrisMaterialPalette strata = formation.getStrataPalette();
|
||||
int thickness = Math.max(1, formation.getStrataThickness());
|
||||
int band = Math.floorDiv(y, thickness);
|
||||
RNG strataRng = strataRngs.get(band);
|
||||
if (strataRng == null) {
|
||||
strataRng = new RNG(formation.getSeed() + band * 31L);
|
||||
strataRngs.put(band, strataRng);
|
||||
}
|
||||
NativeBlockState strataState = strata.get(strataRng, x, band, z, data);
|
||||
if (strataState != null) {
|
||||
return strataState;
|
||||
}
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.resolve(formation.getBlock(), formation.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static boolean capDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getCapPalette()) || (f.getCapBlock() != null && !f.getCapBlock().isEmpty());
|
||||
}
|
||||
|
||||
private static boolean strataDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getStrataPalette());
|
||||
}
|
||||
}
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FormationCanvas {
|
||||
public enum Role {
|
||||
BODY,
|
||||
CAP
|
||||
}
|
||||
|
||||
private final Map<Vector3i, Role> cells = new HashMap<>();
|
||||
|
||||
public void setBody(int x, int y, int z) {
|
||||
Vector3i key = new Vector3i(x, y, z);
|
||||
if (cells.get(key) == Role.CAP) {
|
||||
return;
|
||||
}
|
||||
cells.put(key, Role.BODY);
|
||||
}
|
||||
|
||||
public void setCap(int x, int y, int z) {
|
||||
cells.put(new Vector3i(x, y, z), Role.CAP);
|
||||
}
|
||||
|
||||
public void remove(int x, int y, int z) {
|
||||
cells.remove(new Vector3i(x, y, z));
|
||||
}
|
||||
|
||||
public boolean has(int x, int y, int z) {
|
||||
return cells.containsKey(new Vector3i(x, y, z));
|
||||
}
|
||||
|
||||
public Map<Vector3i, Role> getCells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return cells.isEmpty();
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FormationGenerator {
|
||||
private FormationGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFormation f, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(f.getHeightMin(), f.getHeightMax());
|
||||
int hi = Math.max(f.getHeightMin(), f.getHeightMax());
|
||||
int height = Math.max(3, rng.i(lo, hi + 1));
|
||||
|
||||
return generate(f, variantIndex, rng, data, height);
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFormation f, int variantIndex, RNG rng, IrisData data, int height) {
|
||||
int wLo = Math.min(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
int wHi = Math.max(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
double baseRadius = Math.max(1, rng.i(wLo, wHi + 1));
|
||||
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
|
||||
switch (f.getForm()) {
|
||||
case SPIRE -> FormationShapeBuilder.spire(canvas, f, height, baseRadius, rng);
|
||||
case HOODOO -> FormationShapeBuilder.hoodoo(canvas, f, height, baseRadius, rng);
|
||||
case ARCH -> FormationShapeBuilder.arch(canvas, f, height, baseRadius, rng);
|
||||
case SEA_STACK -> FormationShapeBuilder.seaStack(canvas, f, height, baseRadius, rng);
|
||||
case BOULDER -> FormationShapeBuilder.boulder(canvas, f, height, baseRadius, rng);
|
||||
case BASALT_COLUMN -> FormationShapeBuilder.basaltColumns(canvas, f, height, baseRadius, rng);
|
||||
case ICEBERG -> FormationShapeBuilder.iceberg(canvas, f, height, baseRadius, rng);
|
||||
case FISSURE -> FormationShapeBuilder.fissure(canvas, f, height, baseRadius, rng);
|
||||
case SPIRAL -> FormationShapeBuilder.spiral(canvas, f, height, baseRadius, rng);
|
||||
case OVERHANG -> FormationShapeBuilder.overhang(canvas, f, height, baseRadius, rng);
|
||||
}
|
||||
|
||||
if (canvas.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<Vector3i, NativeBlockState> resolved = new HashMap<>();
|
||||
FormationBlockResolver resolver = new FormationBlockResolver(f, data);
|
||||
for (Map.Entry<Vector3i, FormationCanvas.Role> entry : canvas.getCells().entrySet()) {
|
||||
NativeBlockState bd = resolver.resolve(entry.getValue(), entry.getKey());
|
||||
if (bd == null) {
|
||||
continue;
|
||||
}
|
||||
resolved.put(entry.getKey(), bd);
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
|
||||
public final class FormationProfiles {
|
||||
private FormationProfiles() {
|
||||
}
|
||||
|
||||
public static double radiusAt(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
double clamped = Math.max(0.0, Math.min(1.0, t));
|
||||
return switch (f.getProfile()) {
|
||||
case CONSTANT -> baseRadius;
|
||||
case LINEAR -> baseRadius + (topRadius - baseRadius) * clamped;
|
||||
case TAPER -> baseRadius + (topRadius - baseRadius) * smoothstep(clamped);
|
||||
case PARABOLIC -> parabolic(f, baseRadius, topRadius, clamped);
|
||||
case BULGE -> baseRadius + (Math.max(baseRadius, topRadius) - baseRadius) * bell(clamped) + (topRadius - baseRadius) * clamped * 0.25;
|
||||
};
|
||||
}
|
||||
|
||||
private static double parabolic(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
double waist = Math.max(0.0, Math.min(1.0, f.getProfileWaist()));
|
||||
double floor = Math.max(0.0, Math.min(1.0, f.getProfileWaistFloor()));
|
||||
double denom = Math.pow(Math.max(waist, 1.0 - waist), 2);
|
||||
if (denom == 0) {
|
||||
denom = 1;
|
||||
}
|
||||
double envelope = baseRadius + (topRadius - baseRadius) * t;
|
||||
double pinch = floor + (1.0 - floor) * (Math.pow(t - waist, 2) / denom);
|
||||
return Math.max(0.5, envelope * pinch);
|
||||
}
|
||||
|
||||
private static double smoothstep(double t) {
|
||||
return 3.0 * t * t - 2.0 * t * t * t;
|
||||
}
|
||||
|
||||
private static double bell(double t) {
|
||||
return Math.exp(-Math.pow(t - 0.5, 2) / (2.0 * 0.22 * 0.22));
|
||||
}
|
||||
}
|
||||
-428
@@ -1,428 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FormationShapeBuilder {
|
||||
private FormationShapeBuilder() {
|
||||
}
|
||||
|
||||
public static void spire(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth();
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
int previousX = 0;
|
||||
int previousZ = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
double shear = Math.tan(lean) * y;
|
||||
int centerX = (int) Math.round(Math.cos(azimuth) * shear);
|
||||
int centerZ = (int) Math.round(Math.sin(azimuth) * shear);
|
||||
boolean cap = y >= height - 2;
|
||||
for (int x = Math.min(previousX, centerX); x <= Math.max(previousX, centerX); x++) {
|
||||
setSpireCenter(canvas, x, y, previousZ, cap);
|
||||
}
|
||||
for (int z = Math.min(previousZ, centerZ); z <= Math.max(previousZ, centerZ); z++) {
|
||||
setSpireCenter(canvas, centerX, y, z, cap);
|
||||
}
|
||||
previousX = centerX;
|
||||
previousZ = centerZ;
|
||||
}
|
||||
}
|
||||
|
||||
public static void seaStack(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = Math.max(1.0, baseRadius * 0.55);
|
||||
if (f.getTopWidth() > 0) {
|
||||
topRadius = f.getTopWidth();
|
||||
}
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
}
|
||||
|
||||
public static void hoodoo(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth() > 0 ? f.getTopWidth() : Math.max(1.0, baseRadius * 0.7);
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, false);
|
||||
|
||||
int capRadius = f.getHoodooCapRadius();
|
||||
if (capRadius <= 0) {
|
||||
return;
|
||||
}
|
||||
int capHeight = Math.max(1, f.getHoodooCapHeight());
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double shear = Math.tan(lean) * height;
|
||||
double topOffX = Math.cos(azimuth) * shear;
|
||||
double topOffZ = Math.sin(azimuth) * shear;
|
||||
double wideRadius = topRadius + capRadius;
|
||||
|
||||
for (int cy = 0; cy < capHeight; cy++) {
|
||||
int y = height + cy;
|
||||
double shrink = capHeight <= 1 ? 0 : (cy / (double) (capHeight - 1)) * 0.5;
|
||||
double r = wideRadius * (1.0 - shrink);
|
||||
disc(canvas, f, (int) Math.round(topOffX), y, (int) Math.round(topOffZ), r, true, rng);
|
||||
}
|
||||
}
|
||||
|
||||
public static void boulder(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double rx = baseRadius;
|
||||
double ry = Math.max(2.0, height * 0.5);
|
||||
double rz = baseRadius * (0.8 + rng.d(0.0, 0.3));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
long noiseSeed = f.getSeed() + 4201L;
|
||||
|
||||
int maxR = (int) Math.ceil(Math.max(rx, Math.max(ry, rz))) + 2;
|
||||
for (int x = -maxR; x <= maxR; x++) {
|
||||
for (int y = 0; y <= (int) Math.ceil(ry * 2) + 1; y++) {
|
||||
for (int z = -maxR; z <= maxR; z++) {
|
||||
double nx = x / rx;
|
||||
double ny = (y - ry) / ry;
|
||||
double nz = z / rz;
|
||||
double d = nx * nx + ny * ny + nz * nz;
|
||||
double wobble = (TreeFunctions.valueNoise3D(x, y, z, noiseSeed) - 0.5) * roughness * 0.9;
|
||||
if (d + wobble <= 1.0) {
|
||||
canvas.setBody(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void arch(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double span = Math.max(2.0, f.getArchSpan());
|
||||
double tubeRadius = Math.max(0.75, f.getArchThickness() * 0.5);
|
||||
double asymmetry = Math.max(0.0, Math.min(1.0, f.getArchAsymmetry()));
|
||||
double leftFootX = -span * 0.5 - tubeRadius - rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double rightFootX = span * 0.5 + tubeRadius + rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double leftFootZ = rng.d(-tubeRadius * 0.45, tubeRadius * 0.45) * asymmetry;
|
||||
double rightFootZ = rng.d(-tubeRadius * 0.45, tubeRadius * 0.45) * asymmetry;
|
||||
double crownZ = rng.d(-span * 0.2, span * 0.2) * asymmetry;
|
||||
double crownShiftX = rng.d(-span * 0.12, span * 0.12) * asymmetry;
|
||||
double depthTwist = rng.d(-span * 0.1, span * 0.1) * asymmetry;
|
||||
double crownPosition = 0.5 + rng.d(-0.12, 0.12) * asymmetry;
|
||||
double leftSteepness = 0.58 + rng.d(-0.16, 0.16) * asymmetry;
|
||||
double rightSteepness = 0.58 + rng.d(-0.16, 0.16) * asymmetry;
|
||||
double radiusWave = rng.d(-0.22, 0.22) * asymmetry;
|
||||
double radiusPhase = rng.d(0.0, Math.PI * 2.0);
|
||||
double crownCenterY = Math.max(tubeRadius + 2.0, height - 1.0 - tubeRadius);
|
||||
double footRadius = tubeRadius + Math.min(tubeRadius * 0.45, baseRadius * 0.18);
|
||||
long noiseSeed = rng.nextLong();
|
||||
int steps = Math.max(24, (int) Math.ceil((rightFootX - leftFootX + height) * 4.0));
|
||||
|
||||
ball(canvas, f, (int) Math.round(leftFootX), (int) Math.round(footRadius),
|
||||
(int) Math.round(leftFootZ), footRadius, false, noiseSeed, rng);
|
||||
ball(canvas, f, (int) Math.round(rightFootX), (int) Math.round(footRadius),
|
||||
(int) Math.round(rightFootZ), footRadius, false, noiseSeed, rng);
|
||||
|
||||
for (int step = 0; step <= steps; step++) {
|
||||
double t = step / (double) steps;
|
||||
double normalizedRise;
|
||||
double steepness;
|
||||
if (t <= crownPosition) {
|
||||
normalizedRise = Math.sin((t / crownPosition) * Math.PI * 0.5);
|
||||
steepness = leftSteepness;
|
||||
} else {
|
||||
normalizedRise = Math.sin(((1.0 - t) / (1.0 - crownPosition)) * Math.PI * 0.5);
|
||||
steepness = rightSteepness;
|
||||
}
|
||||
double rise = Math.pow(Math.max(0.0, normalizedRise), steepness);
|
||||
double x = leftFootX + (rightFootX - leftFootX) * t
|
||||
+ Math.sin(Math.PI * t) * crownShiftX;
|
||||
double inverse = 1.0 - t;
|
||||
double z = inverse * inverse * leftFootZ + 2.0 * inverse * t * crownZ + t * t * rightFootZ
|
||||
+ Math.sin(Math.PI * 2.0 * t) * depthTwist;
|
||||
double y = tubeRadius + (crownCenterY - tubeRadius) * rise;
|
||||
double radius = tubeRadius * (1.0 + radiusWave * Math.sin(Math.PI * t)
|
||||
* Math.sin(Math.PI * 2.0 * t + radiusPhase));
|
||||
radius = Math.max(tubeRadius * 0.68, Math.min(tubeRadius * 1.32, radius));
|
||||
ball(canvas, f, (int) Math.round(x), (int) Math.round(y), (int) Math.round(z),
|
||||
radius, false, noiseSeed, rng);
|
||||
}
|
||||
if (asymmetry == 0.0) {
|
||||
mirrorAcrossX(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
public static void basaltColumns(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getBasaltColumns());
|
||||
int colRadius = Math.max(1, f.getBasaltColumnRadius());
|
||||
double variance = Math.max(0.0, Math.min(1.0, f.getBasaltHeightVariance()));
|
||||
int spread = (int) Math.ceil(baseRadius);
|
||||
|
||||
for (int c = 0; c < count; c++) {
|
||||
double angle = rng.d(0.0, Math.PI * 2.0);
|
||||
double dist = rng.d(0.0, spread);
|
||||
int ox = (int) Math.round(Math.cos(angle) * dist);
|
||||
int oz = (int) Math.round(Math.sin(angle) * dist);
|
||||
double hVar = 1.0 - variance + rng.d(0.0, variance * 2.0);
|
||||
int colHeight = Math.max(3, (int) Math.round(height * hVar));
|
||||
|
||||
for (int y = 0; y < colHeight; y++) {
|
||||
for (int x = -colRadius; x <= colRadius; x++) {
|
||||
for (int z = -colRadius; z <= colRadius; z++) {
|
||||
if (Math.abs(x) + Math.abs(z) > colRadius) {
|
||||
continue;
|
||||
}
|
||||
canvas.setBody(ox + x, y, oz + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (colRadius > 0) {
|
||||
canvas.setCap(ox, colHeight - 1, oz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void iceberg(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double bodyHeight = Math.max(2.0, height * 0.42);
|
||||
double radiusX = baseRadius * rng.d(1.15, 1.5);
|
||||
double radiusZ = baseRadius * rng.d(1.0, 1.35);
|
||||
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.getRoughness());
|
||||
|
||||
int peaks = Math.max(1, f.getIcebergPeaks());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
for (int i = 0; i < peaks; i++) {
|
||||
double angle = phase + (Math.PI * 2.0 * i / peaks) + rng.d(-0.35, 0.35);
|
||||
double distance = rng.d(0.0, baseRadius * 0.62);
|
||||
int offsetX = (int) Math.round(Math.cos(angle) * distance);
|
||||
int offsetZ = (int) Math.round(Math.sin(angle) * distance);
|
||||
int peakHeight = Math.max(3, (int) Math.round(height * rng.d(0.58, 1.0)));
|
||||
double peakRadius = Math.max(1.0, baseRadius * rng.d(0.28, 0.58));
|
||||
double leanDistance = rng.d(0.0, Math.max(1.0, baseRadius * 0.45));
|
||||
taperedPeak(canvas, f, peakHeight, peakRadius, offsetX, offsetZ, angle, leanDistance, rng);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fissure(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getFractureCount());
|
||||
double separation = Math.max(1.0, f.getFractureSeparation());
|
||||
double shardRadius = Math.max(1.0, baseRadius / Math.max(1.6, count * 0.72));
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
double lane = i - ((count - 1) / 2.0);
|
||||
double offset = lane * (shardRadius * 2.0 + separation);
|
||||
int offsetX = (int) Math.round(Math.cos(phase) * offset);
|
||||
int offsetZ = (int) Math.round(Math.sin(phase) * offset);
|
||||
double outwardAngle = lane < 0 ? phase + Math.PI : phase;
|
||||
int shardHeight = Math.max(3, (int) Math.round(height * rng.d(0.62, 1.0)));
|
||||
double leanDistance = rng.d(separation * 0.4, separation + baseRadius * 0.8);
|
||||
taperedPeak(canvas, f, shardHeight, shardRadius, offsetX, offsetZ, outwardAngle, leanDistance, rng);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spiral(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double turns = Math.max(0.25, f.getSpiralTurns());
|
||||
double startRadius = Math.max(1.0, f.getSpiralRadius());
|
||||
double startThickness = Math.max(1.0, f.getSpiralThickness());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
for (int step = 0; step <= steps; step++) {
|
||||
double t = step / (double) steps;
|
||||
double angle = phase + Math.PI * 2.0 * turns * t;
|
||||
double radius = startRadius * (1.0 - 0.72 * t);
|
||||
int x = (int) Math.round(Math.cos(angle) * radius);
|
||||
int y = (int) Math.round(t * (height - 1));
|
||||
int z = (int) Math.round(Math.sin(angle) * radius);
|
||||
double thickness = Math.max(0.75, startThickness * (1.0 - 0.48 * t));
|
||||
ball(canvas, f, x, y, z, thickness, step == steps, noiseSeed, rng);
|
||||
}
|
||||
|
||||
double footRadius = Math.max(1.0, Math.min(baseRadius, startThickness + 1.0));
|
||||
disc(canvas, f, (int) Math.round(Math.cos(phase) * startRadius), 0,
|
||||
(int) Math.round(Math.sin(phase) * startRadius), footRadius, false, rng);
|
||||
}
|
||||
|
||||
public static void overhang(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double reach = Math.max(1.0, f.getOverhangReach());
|
||||
double drop = Math.max(0.0, f.getOverhangDrop());
|
||||
double phase = Math.toRadians(f.getLeanAzimuth()) + rng.d(-0.18, 0.18);
|
||||
double trunkHeight = Math.max(3.0, height * 0.62);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
for (int step = 0; step <= steps; step++) {
|
||||
double t = step / (double) steps;
|
||||
double extension;
|
||||
double y;
|
||||
if (t <= 0.58) {
|
||||
double rise = t / 0.58;
|
||||
extension = reach * 0.16 * rise * rise;
|
||||
y = trunkHeight * rise;
|
||||
} else {
|
||||
double hook = (t - 0.58) / 0.42;
|
||||
extension = reach * (0.16 + 0.84 * Math.sin(hook * Math.PI * 0.5));
|
||||
y = trunkHeight + Math.sin(hook * Math.PI) * height * 0.18 - drop * hook * hook;
|
||||
}
|
||||
int x = (int) Math.round(Math.cos(phase) * extension);
|
||||
int z = (int) Math.round(Math.sin(phase) * extension);
|
||||
double thickness = Math.max(0.9, baseRadius * (1.0 - 0.64 * t));
|
||||
ball(canvas, f, x, Math.max(0, (int) Math.round(y)), z, thickness, step == steps, noiseSeed, rng);
|
||||
}
|
||||
}
|
||||
|
||||
private static void column(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
long noiseSeed = f.getSeed() + 9001L;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : (y / (double) (height - 1));
|
||||
double radius = FormationProfiles.radiusAt(f, baseRadius, topRadius, t);
|
||||
double shear = Math.tan(lean) * y;
|
||||
int cx = extraBaseX + (int) Math.round(Math.cos(azimuth) * shear);
|
||||
int cz = extraBaseZ + (int) Math.round(Math.sin(azimuth) * shear);
|
||||
boolean cap = capTop && y >= height - 2;
|
||||
ringDisc(canvas, f, cx, y, cz, radius, roughness, jitter, noiseSeed, cap, rng);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setSpireCenter(FormationCanvas canvas, int x, int y, int z, boolean cap) {
|
||||
if (cap) {
|
||||
canvas.setCap(x, y, z);
|
||||
} else {
|
||||
canvas.setBody(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ringDisc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
double dist = Math.sqrt(x * x + z * z);
|
||||
double perturb = (TreeFunctions.valueNoise3D(cx + x, y, cz + z, noiseSeed) - 0.5) * roughness * (radius + 1.0);
|
||||
double effective = radius + perturb;
|
||||
if (dist <= effective) {
|
||||
if (jitter > 0 && dist > effective - 1.0 && rng.chance(jitter * 0.5)) {
|
||||
continue;
|
||||
}
|
||||
if (cap) {
|
||||
canvas.setCap(cx + x, y, cz + z);
|
||||
} else {
|
||||
canvas.setBody(cx + x, y, cz + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void disc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
if (Math.sqrt(x * x + z * z) <= radius) {
|
||||
if (cap) {
|
||||
canvas.setCap(cx + x, y, cz + z);
|
||||
} else {
|
||||
canvas.setBody(cx + x, y, cz + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void taperedPeak(FormationCanvas canvas, IrisFormation f, int height, double radius,
|
||||
int offsetX, int offsetZ, double leanAngle, double leanDistance, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : y / (double) (height - 1);
|
||||
int x = offsetX + (int) Math.round(Math.cos(leanAngle) * leanDistance * t * t);
|
||||
int z = offsetZ + (int) Math.round(Math.sin(leanAngle) * leanDistance * t * t);
|
||||
double layerRadius = Math.max(0.45, radius * Math.pow(1.0 - t, 0.72));
|
||||
ringDisc(canvas, f, x, y, z, layerRadius, roughness, jitter, noiseSeed, y >= height - 2, rng);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ellipsoid(FormationCanvas canvas, double radiusX, double radiusY, double radiusZ,
|
||||
double centerY, long noiseSeed, double configuredRoughness) {
|
||||
double roughness = Math.max(0.0, Math.min(1.0, configuredRoughness));
|
||||
int maxX = (int) Math.ceil(radiusX) + 1;
|
||||
int maxY = (int) Math.ceil(radiusY) + 1;
|
||||
int maxZ = (int) Math.ceil(radiusZ) + 1;
|
||||
for (int x = -maxX; x <= maxX; x++) {
|
||||
for (int y = 0; y <= maxY; y++) {
|
||||
for (int z = -maxZ; z <= maxZ; z++) {
|
||||
double nx = x / radiusX;
|
||||
double ny = (y - centerY) / radiusY;
|
||||
double nz = z / radiusZ;
|
||||
double distance = nx * nx + ny * ny + nz * nz;
|
||||
double wobble = (TreeFunctions.valueNoise3D(x, y, z, noiseSeed) - 0.5) * roughness * 0.55;
|
||||
if (distance + wobble <= 1.0) {
|
||||
canvas.setBody(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ball(FormationCanvas canvas, IrisFormation f, int centerX, int centerY, int centerZ,
|
||||
double radius, boolean cap, long noiseSeed, RNG rng) {
|
||||
int extent = (int) Math.ceil(radius);
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
for (int x = -extent; x <= extent; x++) {
|
||||
for (int y = -extent; y <= extent; y++) {
|
||||
for (int z = -extent; z <= extent; z++) {
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
double perturb = (TreeFunctions.valueNoise3D(centerX + x, centerY + y, centerZ + z, noiseSeed) - 0.5)
|
||||
* roughness * Math.max(1.0, radius * 0.6);
|
||||
double effectiveRadius = radius + perturb;
|
||||
if (distance > effectiveRadius + 0.2) {
|
||||
continue;
|
||||
}
|
||||
if (jitter > 0.0 && distance > effectiveRadius - 0.75 && rng.chance(jitter * 0.35)) {
|
||||
continue;
|
||||
}
|
||||
int targetY = centerY + y;
|
||||
if (targetY < 0) {
|
||||
continue;
|
||||
}
|
||||
if (cap) {
|
||||
canvas.setCap(centerX + x, targetY, centerZ + z);
|
||||
} else {
|
||||
canvas.setBody(centerX + x, targetY, centerZ + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void mirrorAcrossX(FormationCanvas canvas) {
|
||||
Map<Vector3i, FormationCanvas.Role> cells = new HashMap<>(canvas.getCells());
|
||||
for (Map.Entry<Vector3i, FormationCanvas.Role> entry : cells.entrySet()) {
|
||||
Vector3i position = entry.getKey();
|
||||
if (entry.getValue() == FormationCanvas.Role.CAP) {
|
||||
canvas.setCap(-position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
} else {
|
||||
canvas.setBody(-position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-317
@@ -1,317 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("formation")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated natural formation, including rock landmarks and magical glacial silhouettes. Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file.")
|
||||
@Data
|
||||
public class IrisFormation implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "formation";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per chunk for this formation to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.02;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this formation. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("The placement mode used to anchor the formation to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Description("Rotate this formation's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this formation may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Description("Horizontal buffer, in blocks, beyond each lowest solid foundation block that must also be solid, un-carved ground.")
|
||||
private int surfaceSupportBuffer = 3;
|
||||
|
||||
@Description("If true, the formation anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Description("The overall silhouette of the formation. Drives which sculpting routine the generator uses.")
|
||||
private IrisFormationForm form = IrisFormationForm.SPIRE;
|
||||
|
||||
@Required
|
||||
@Description("The main rock block, e.g. minecraft:stone. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:stone";
|
||||
|
||||
@Description("A noise-driven palette for the main rock body. When set this overrides the single block, letting the body mix blocks by noise.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Description("Optional caprock block placed on the top crown of the formation (and the wide overhanging cap for HOODOO). Ignored when capPalette is set. When null and capPalette is unset, the formation uses its main rock everywhere.")
|
||||
@RegistryListBlockType
|
||||
private String capBlock = null;
|
||||
|
||||
@Description("A noise-driven palette for the caprock. When set this overrides the single capBlock.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
|
||||
@Description("Optional palette of strata (horizontal colored bands) blended into the rock body by y level. When set, every strataThickness blocks of height switches to the next strata block, producing the signature banded look. Falls back to the main block where unset.")
|
||||
private IrisMaterialPalette strataPalette = null;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Description("The thickness in blocks of each horizontal strata band when strataPalette is set.")
|
||||
private int strataThickness = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum total height of the formation in blocks.")
|
||||
private int heightMin = 14;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum total height of the formation in blocks.")
|
||||
private int heightMax = 26;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum base radius (half-width) of the formation in blocks.")
|
||||
private int baseWidthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum base radius (half-width) of the formation in blocks.")
|
||||
private int baseWidthMax = 6;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("The target radius (half-width) at the very top of the formation in blocks, before the profile is applied. 0 means taper to a point.")
|
||||
private int topWidth = 0;
|
||||
|
||||
@Description("The function used to shape the formation radius over its height.")
|
||||
private IrisFormationProfile profile = IrisFormationProfile.TAPER;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The normalized height (0 base, 1 top) of the pinched waist for the PARABOLIC profile (used by HOODOO).")
|
||||
private double profileWaist = 0.55;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The minimum radius fraction at the waist for the PARABOLIC profile. Lower values pinch the waist tighter.")
|
||||
private double profileWaistFloor = 0.35;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("How far the formation leans, in degrees from vertical. 0 is perfectly upright. The whole body is sheared by this amount over its height.")
|
||||
private double lean = 0;
|
||||
|
||||
@Description("Compass direction in degrees the formation leans toward when lean is non-zero.")
|
||||
private double leanAzimuth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Surface roughness from 0 (a clean smooth solid) to 1 (heavily eroded and pitted). Driven by 3D value noise that perturbs the radius so the formation never reads as a clean cylinder.")
|
||||
private double roughness = 0.3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Per-block surface jitter from 0 (none) to 1 (maximum). Randomly carves and adds isolated edge blocks to break up the silhouette.")
|
||||
private double jitter = 0.15;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Extra wide cap radius in blocks added on top for the HOODOO form, producing the overhanging mushroom caprock. 0 disables the overhang.")
|
||||
private int hoodooCapRadius = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(6)
|
||||
@Description("The height in blocks of the HOODOO overhanging caprock slab.")
|
||||
private int hoodooCapHeight = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("How wide the ARCH opening is in blocks (the gap between the two legs). The arch span is rasterized over this width.")
|
||||
private int archSpan = 10;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("The thickness in blocks of the ARCH legs and spanning curve.")
|
||||
private int archThickness = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How strongly an ARCH varies its leg steepness, crown position, depth bow and tube width between deterministic variants. 0 is symmetric and 1 is highly organic.")
|
||||
private double archAsymmetry = 0.35;
|
||||
|
||||
@MinNumber(2)
|
||||
@MaxNumber(12)
|
||||
@Description("How many separate columns make up a BASALT_COLUMN cluster. Each column gets a randomized height around the formation height range.")
|
||||
private int basaltColumns = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("The radius (half-width) in blocks of each individual column in a BASALT_COLUMN cluster.")
|
||||
private int basaltColumnRadius = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How much the heights of individual BASALT_COLUMN columns vary from each other, from 0 (all equal) to 1 (highly varied).")
|
||||
private double basaltHeightVariance = 0.45;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Description("How many tapered summits crown an ICEBERG formation.")
|
||||
private int icebergPeaks = 3;
|
||||
|
||||
@MinNumber(2)
|
||||
@MaxNumber(8)
|
||||
@Description("How many separated shards form a FISSURE.")
|
||||
private int fractureCount = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Description("Open-air separation in blocks between the shards of a FISSURE.")
|
||||
private int fractureSeparation = 2;
|
||||
|
||||
@MinNumber(0.25)
|
||||
@MaxNumber(6)
|
||||
@Description("How many complete turns a SPIRAL makes from base to tip.")
|
||||
private double spiralTurns = 1.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Description("The starting distance in blocks between a SPIRAL and its open center.")
|
||||
private int spiralRadius = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Description("The radius in blocks of the tube swept along a SPIRAL.")
|
||||
private int spiralThickness = 2;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Description("How far the hooked arm of an OVERHANG projects from its base.")
|
||||
private int overhangReach = 8;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Description("How many blocks the tip of an OVERHANG curls downward.")
|
||||
private int overhangDrop = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("For cave placements in an authored subterrain room, size the formation to this fraction of the room vault. Zero uses heightMin and heightMax.")
|
||||
private double roomHeightFraction = 0;
|
||||
|
||||
@Override
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
if (room == null || roomHeightFraction <= 0) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
return baked == null || baked.isEmpty() ? null : baked.get(rng.i(baked.size()));
|
||||
}
|
||||
IrisObject object = FormationGenerator.generate(this, rng.i(Math.max(1, variants)), rng, data,
|
||||
Math.max(1, (int) Math.floor(room.vaultHeight() * Math.min(1D, roomHeightFraction))));
|
||||
if (object != null) {
|
||||
object.setLoadKey("procedural/" + name + "/" + room.featureId());
|
||||
object.setLoader(data);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = FormationGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setSurfaceSupportBuffer(surfaceSupportBuffer);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("The overall silhouette of a procedural natural formation. Each form drives a distinct sculpting routine in the formation generator.")
|
||||
public enum IrisFormationForm {
|
||||
@Description("A tall, slender needle of rock that tapers smoothly to a point at the top (a sharp pinnacle or stone spire).")
|
||||
SPIRE,
|
||||
@Description("A column with a pinched, eroded waist and a wide overhanging caprock balanced on top (the classic desert hoodoo / mushroom rock).")
|
||||
HOODOO,
|
||||
@Description("Two stout legs joined by a spanning curved bridge of rock overhead (a natural stone arch).")
|
||||
ARCH,
|
||||
@Description("A chunky, blocky stack that tapers gently as it rises, like an isolated pillar of rock standing in water (a sea stack).")
|
||||
SEA_STACK,
|
||||
@Description("A rounded, lumpy boulder formed from a noise-perturbed ellipsoid that sits low on the terrain.")
|
||||
BOULDER,
|
||||
@Description("A tightly packed cluster of several vertical, near-hexagonal columns of varying height (a basalt column formation / giant's causeway).")
|
||||
BASALT_COLUMN,
|
||||
@Description("A broad, faceted mound crowned by several irregular tapered peaks, suitable for icebergs and glacial outcrops.")
|
||||
ICEBERG,
|
||||
@Description("Several separated, outward-leaning shards divided by open cracks.")
|
||||
FISSURE,
|
||||
@Description("A tapered tube swept around a tightening helix, leaving open air through its curled center.")
|
||||
SPIRAL,
|
||||
@Description("A grounded pillar that bends into a long hooked cantilever and curls downward at its tip.")
|
||||
OVERHANG
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.formation;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("A width-shaping function evaluated over normalized height (0 at the base, 1 at the top). Controls how the formation radius scales between baseWidth at the bottom and topWidth at the top.")
|
||||
public enum IrisFormationProfile {
|
||||
@Description("Same radius at every height (a straight cylinder of constant baseWidth).")
|
||||
CONSTANT,
|
||||
@Description("Radius ramps straight from baseWidth at the bottom to topWidth at the top.")
|
||||
LINEAR,
|
||||
@Description("Radius shrinks smoothly toward a point as height increases (an ease that drives the SPIRE needle and gentle SEA_STACK taper).")
|
||||
TAPER,
|
||||
@Description("Radius pinches to a narrow waist near profileWaist then widens again toward the top (the eroded waist used by HOODOO columns).")
|
||||
PARABOLIC,
|
||||
@Description("Radius bulges out to its maximum in the middle of the height range and narrows at both ends (a barrel / bulged column).")
|
||||
BULGE
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class FungusCapBuilder {
|
||||
private FungusCapBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
|
||||
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.getCapOverhang()));
|
||||
int thickness = Math.max(1, Math.min(3, fungus.getCapThickness()));
|
||||
double squish = Math.max(0.0, Math.min(1.0, fungus.getCapSquish()));
|
||||
double droop = Math.max(0.0, fungus.getCapDroop());
|
||||
IrisFungusCapShape shape = fungus.getCapShape() == null ? IrisFungusCapShape.DOME : fungus.getCapShape();
|
||||
int icx = (int) Math.round(cx);
|
||||
int icz = (int) Math.round(cz);
|
||||
|
||||
boolean hasGill = blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
|
||||
double apexRise = apexRise(shape, radius) * (1.0 - 0.6 * squish);
|
||||
double droopReach = Math.tan(Math.toRadians(droop)) * radius;
|
||||
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
double dist = Math.sqrt(dx * dx + dz * dz);
|
||||
if (dist > radius + 0.5) {
|
||||
continue;
|
||||
}
|
||||
double normalized = dist / Math.max(1.0, radius);
|
||||
double surfaceTop = baseY + capSurface(shape, normalized, apexRise);
|
||||
surfaceTop -= droopReach * Math.pow(normalized, 3);
|
||||
|
||||
int topYi = (int) Math.round(surfaceTop);
|
||||
for (int layer = 0; layer < thickness; layer++) {
|
||||
int y = topYi - layer;
|
||||
if (y < baseY - thickness) {
|
||||
continue;
|
||||
}
|
||||
Vector3i pos = new Vector3i(icx + dx, y, icz + dz);
|
||||
FungusCellRole role = FungusCellRole.CAP;
|
||||
|
||||
boolean underside = layer == thickness - 1;
|
||||
boolean topFace = layer == 0;
|
||||
|
||||
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
role = FungusCellRole.GILL;
|
||||
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
|
||||
roles.putIfAbsent(pos, role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static double apexRise(IrisFungusCapShape shape, int radius) {
|
||||
return switch (shape) {
|
||||
case DOME -> radius * 0.85;
|
||||
case CONICAL -> radius * 1.4;
|
||||
case FUNNEL -> radius * 0.5;
|
||||
case FLAT -> radius * 0.35;
|
||||
case FLAT_WIDE -> radius * 0.2;
|
||||
};
|
||||
}
|
||||
|
||||
private static double capSurface(IrisFungusCapShape shape, double normalized, double apexRise) {
|
||||
double n = Math.max(0.0, Math.min(1.0, normalized));
|
||||
return switch (shape) {
|
||||
case DOME -> apexRise * Math.sqrt(Math.max(0.0, 1.0 - n * n));
|
||||
case CONICAL -> apexRise * (1.0 - n);
|
||||
case FUNNEL -> apexRise * (n * n);
|
||||
case FLAT -> apexRise * Math.max(0.0, 1.0 - Math.pow(n, 4));
|
||||
case FLAT_WIDE -> apexRise * Math.max(0.0, 1.0 - Math.pow(n, 6));
|
||||
};
|
||||
}
|
||||
|
||||
private static double rollNoise(int x, int y, int z, long seed) {
|
||||
return TreeFunctions.valueNoise3D(x, y, z, seed);
|
||||
}
|
||||
|
||||
private static double spotNoise(int x, int y, int z, long seed) {
|
||||
return TreeFunctions.valueNoise3D(Math.floorDiv(x, 2), y, Math.floorDiv(z, 2), seed);
|
||||
}
|
||||
|
||||
static boolean blockOrPaletteSet(String block, IrisMaterialPalette palette) {
|
||||
if (IrisProceduralBlocks.paletteSet(palette)) {
|
||||
return true;
|
||||
}
|
||||
return block != null && !block.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class FungusGenerator {
|
||||
private FungusGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFungus fungus, int height, RNG rng, IrisData data) {
|
||||
Map<Vector3i, FungusCellRole> roles = new HashMap<>();
|
||||
long baseSeed = rng.getSeed();
|
||||
|
||||
if (fungus.isShelf()) {
|
||||
FungusShelfBuilder.build(roles, fungus, rng, baseSeed);
|
||||
} else {
|
||||
buildUpright(roles, fungus, height, rng, baseSeed);
|
||||
}
|
||||
|
||||
if (roles.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RNG paletteRng = new RNG(fungus.getSeed());
|
||||
Map<Vector3i, NativeBlockState> resolved = new HashMap<>();
|
||||
for (Map.Entry<Vector3i, FungusCellRole> entry : roles.entrySet()) {
|
||||
Vector3i pos = entry.getKey();
|
||||
NativeBlockState bd = resolveRole(fungus, entry.getValue(), data, pos, paletteRng);
|
||||
if (bd == null) {
|
||||
continue;
|
||||
}
|
||||
resolved.put(pos, bd);
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int height, RNG rng, long baseSeed) {
|
||||
int stemHeight = Math.max(1, height);
|
||||
double[] top = FungusStemBuilder.build(roles, fungus, stemHeight, baseSeed);
|
||||
|
||||
int radius = pickRadius(fungus, rng);
|
||||
double cx = top[0];
|
||||
double cz = top[2];
|
||||
int capBaseY = (int) Math.round(top[1]);
|
||||
FungusCapBuilder.build(roles, fungus, radius, cx, capBaseY, cz, baseSeed + 5557L);
|
||||
}
|
||||
|
||||
private static int pickRadius(IrisFungus fungus, RNG rng) {
|
||||
int lo = Math.min(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
int hi = Math.max(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
lo = Math.max(1, lo);
|
||||
hi = Math.max(lo, hi);
|
||||
return rng.i(lo, hi + 1);
|
||||
}
|
||||
|
||||
private static NativeBlockState resolveRole(IrisFungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
|
||||
int x = pos.getBlockX();
|
||||
int y = pos.getBlockY();
|
||||
int z = pos.getBlockZ();
|
||||
return switch (role) {
|
||||
case STEM -> IrisProceduralBlocks.resolve(fungus.getStem(), fungus.getStemPalette(), data, x, y, z, paletteRng);
|
||||
case CAP -> IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
case GILL -> {
|
||||
NativeBlockState gill = IrisProceduralBlocks.resolve(fungus.getGillBlock(), fungus.getGillPalette(), data, x, y, z, paletteRng);
|
||||
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
case SPOT -> {
|
||||
NativeBlockState spot = IrisProceduralBlocks.resolve(fungus.getSpotBlock(), fungus.getSpotPalette(), data, x, y, z, paletteRng);
|
||||
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class FungusShelfBuilder {
|
||||
private FungusShelfBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, RNG rng, long seed) {
|
||||
int radius = Math.max(1, fungus.getShelfRadius());
|
||||
double azimuth = rng.d(0.0, Math.PI * 2.0);
|
||||
double fanX = Math.sin(azimuth);
|
||||
double fanZ = Math.cos(azimuth);
|
||||
int stubHeight = Math.max(0, Math.min(2, fungus.getStemWidth()));
|
||||
|
||||
for (int y = 0; y < stubHeight; y++) {
|
||||
roles.put(new Vector3i(0, y, 0), FungusCellRole.STEM);
|
||||
}
|
||||
|
||||
int fanY = stubHeight;
|
||||
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
double dist = Math.sqrt(dx * dx + dz * dz);
|
||||
if (dist > radius + 0.5) {
|
||||
continue;
|
||||
}
|
||||
double forward = dx * fanX + dz * fanZ;
|
||||
if (forward < -0.5) {
|
||||
continue;
|
||||
}
|
||||
double normalized = dist / Math.max(1.0, radius);
|
||||
int lift = (int) Math.round(radius * 0.25 * (1.0 - normalized));
|
||||
int y = fanY + lift;
|
||||
|
||||
FungusCellRole role = FungusCellRole.CAP;
|
||||
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
roles.putIfAbsent(new Vector3i(dx, y, dz), role);
|
||||
|
||||
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
roles.putIfAbsent(new Vector3i(dx, y - 1, dz), FungusCellRole.GILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static double rollNoise(int x, int y, int z, long seed) {
|
||||
return TreeFunctions.valueNoise3D(x, y, z, seed);
|
||||
}
|
||||
|
||||
private static double spotNoise(int x, int y, int z, long seed) {
|
||||
return TreeFunctions.valueNoise3D(Math.floorDiv(x, 2), y, Math.floorDiv(z, 2), seed);
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class FungusStemBuilder {
|
||||
private FungusStemBuilder() {
|
||||
}
|
||||
|
||||
public static double[] build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int stemHeight, long seed) {
|
||||
int width = Math.max(1, Math.min(3, fungus.getStemWidth()));
|
||||
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.getStemCurve())));
|
||||
double leanRad = Math.toRadians(fungus.getStemLeanAzimuth());
|
||||
double leanX = Math.sin(leanRad);
|
||||
double leanZ = Math.cos(leanRad);
|
||||
double waveAmp = Math.max(0.0, fungus.getStemWaveAmplitude());
|
||||
double wavePeriods = fungus.getStemWavePeriods() == 0 ? 1.0 : fungus.getStemWavePeriods();
|
||||
double waveAzimuth = Math.toRadians(fungus.getStemLeanAzimuth() + 90.0);
|
||||
double waveX = Math.sin(waveAzimuth);
|
||||
double waveZ = Math.cos(waveAzimuth);
|
||||
double wavePhase = TreeFunctions.valueNoise1D(seed, seed) * Math.PI * 2.0;
|
||||
|
||||
double topCx = 0.0;
|
||||
double topCz = 0.0;
|
||||
int topY = Math.max(0, stemHeight - 1);
|
||||
|
||||
for (int y = 0; y < stemHeight; y++) {
|
||||
double t = stemHeight <= 1 ? 0.0 : y / (double) (stemHeight - 1);
|
||||
double lean = maxLean * (t * t);
|
||||
double wave = waveAmp * Math.sin(2.0 * Math.PI * wavePeriods * t + wavePhase);
|
||||
double cx = lean * leanX + wave * waveX;
|
||||
double cz = lean * leanZ + wave * waveZ;
|
||||
|
||||
int ox = (width % 2 == 1 ? (int) Math.round(cx) : (int) Math.floor(cx) + 1) - width / 2;
|
||||
int oz = (width % 2 == 1 ? (int) Math.round(cz) : (int) Math.floor(cz) + 1) - width / 2;
|
||||
for (int dx = 0; dx < width; dx++) {
|
||||
for (int dz = 0; dz < width; dz++) {
|
||||
roles.put(new Vector3i(ox + dx, y, oz + dz), FungusCellRole.STEM);
|
||||
}
|
||||
}
|
||||
|
||||
topCx = cx;
|
||||
topCz = cz;
|
||||
}
|
||||
|
||||
return new double[]{topCx, topY, topCz};
|
||||
}
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("fungus")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated fungus (giant mushroom or shelf fungus). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. The fungus is built as a stem column with a cap dome grown on top, mirroring the trunk-and-canopy model used by procedural trees.")
|
||||
@Data
|
||||
public class IrisFungus implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "fungus";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per chunk for this fungus to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this fungus. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("The placement mode used to anchor the fungus to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Description("Rotate this fungus's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this fungus may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Description("If true, the fungus anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Description("The stem block, e.g. minecraft:mushroom_stem. Ignored when stemPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String stem = "minecraft:mushroom_stem";
|
||||
|
||||
@Description("A noise-driven palette for the stem. When set this overrides the single stem block, letting the stem mix blocks by noise.")
|
||||
private IrisMaterialPalette stemPalette = null;
|
||||
|
||||
@Required
|
||||
@Description("The cap block, e.g. minecraft:red_mushroom_block. Ignored when capPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String cap = "minecraft:red_mushroom_block";
|
||||
|
||||
@Description("A noise-driven palette for the cap. When set this overrides the single cap block, letting the cap mix blocks by noise.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum total stem height in blocks. Variants spread between this and stemHeightMax.")
|
||||
private int stemHeightMin = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum total stem height in blocks. Variants spread between stemHeightMin and this.")
|
||||
private int stemHeightMax = 9;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(3)
|
||||
@Description("Base stem width in blocks. 1 is a single column, 2 is a 2x2 stem, 3 is a chunky 3x3 trunk.")
|
||||
private int stemWidth = 1;
|
||||
|
||||
@Description("How far the stem leans away from vertical, in degrees. 0 is perfectly upright; small values give an organic tilt.")
|
||||
private double stemCurve = 0;
|
||||
|
||||
@Description("Compass direction in degrees the stem leans toward when stemCurve is non-zero.")
|
||||
private double stemLeanAzimuth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Amplitude in blocks of a gentle sideways wave applied up the stem so it is not a perfectly straight ruler.")
|
||||
private double stemWaveAmplitude = 0.4;
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@Description("The number of full sine wobbles applied over the stem height for the stem wave.")
|
||||
private double stemWavePeriods = 1;
|
||||
|
||||
@Description("The silhouette of the cap (dome, flat umbrella, funnel, cone, or wide shallow slab).")
|
||||
private IrisFungusCapShape capShape = IrisFungusCapShape.DOME;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum cap radius in blocks (measured from the cap center to its rim).")
|
||||
private int capRadiusMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum cap radius in blocks (measured from the cap center to its rim).")
|
||||
private int capRadiusMax = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(3)
|
||||
@Description("How many blocks thick the cap shell is. 1 is a thin skin, 3 is a fleshy slab.")
|
||||
private int capThickness = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Vertical flatten factor for the cap. 0 leaves the cap at full height, 1 squashes it flat into a disc.")
|
||||
private double capSquish = 0.4;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("How far the cap rim droops downward, in degrees, curling the edge of the cap toward the ground.")
|
||||
private double capDroop = 20;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("How far the cap radius extends past the stem before the rim begins, in blocks. Larger values make the cap overhang the stem more.")
|
||||
private double capOverhang = 2;
|
||||
|
||||
@Description("Optional block forming the gill layer on the underside of the cap (gills or a glow layer), e.g. minecraft:brown_mushroom_block or minecraft:shroomlight. Ignored when gillPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
private String gillBlock = null;
|
||||
|
||||
@Description("A noise-driven palette for the underside gill layer. When set this overrides the single gillBlock.")
|
||||
private IrisMaterialPalette gillPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The fraction of underside cap blocks replaced by the gill block when a gill block or palette is set.")
|
||||
private double gillChance = 0.85;
|
||||
|
||||
@Description("Optional block speckled across the top of the cap by noise (white toadstool dots, warts, glowing spots), e.g. minecraft:bone_block or minecraft:white_concrete. Ignored when spotPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
private String spotBlock = null;
|
||||
|
||||
@Description("A noise-driven palette for the cap top spots. When set this overrides the single spotBlock.")
|
||||
private IrisMaterialPalette spotPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The fraction of top cap blocks replaced by the spot block, selected by value noise so spots cluster naturally.")
|
||||
private double spotChance = 0.18;
|
||||
|
||||
@Description("If true, generate a bracket / shelf fungus instead of an upright mushroom: a small flat fan that grows sideways off a very short or absent stem, like a polypore clinging to a trunk.")
|
||||
private boolean shelf = false;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("The radius in blocks of the sideways fan when shelf is true.")
|
||||
private int shelfRadius = 3;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
int lo = Math.min(stemHeightMin, stemHeightMax);
|
||||
int hi = Math.max(stemHeightMin, stemHeightMax);
|
||||
RNG heightRng = new RNG(seed);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = FungusGenerator.generate(this, Math.max(1, height), new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.fungus;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("The silhouette of the mushroom cap. Each shape drives how the cap radius and thickness vary from its apex down to the rim, giving the fungus a distinct profile.")
|
||||
public enum IrisFungusCapShape {
|
||||
@Description("A rounded hemisphere cap that bulges up and curls slightly under at the rim, the classic red toadstool dome.")
|
||||
DOME,
|
||||
@Description("A wide, nearly flat umbrella that holds its full radius almost to the edge before dropping, the brown-mushroom plate look.")
|
||||
FLAT,
|
||||
@Description("An upturned bowl whose rim lifts higher than its center, cupping upward like a chanterelle or funnel mushroom.")
|
||||
FUNNEL,
|
||||
@Description("A tall pointed cone that tapers from a broad base to a sharp apex, the witch-hat parasol silhouette.")
|
||||
CONICAL,
|
||||
@Description("A very wide but shallow slab, a low overhanging shelf-like roof that spreads far past the stem with minimal vertical rise.")
|
||||
FLAT_WIDE
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("ruin")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated ruin: a crumbling man-made structure (pillar, wall, arch, foundation slab, or rubble pile). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Weathering swaps blocks for mossy or cracked variants by noise, erosion deletes blocks so the shape reads as collapsed, and a buried fraction sinks the ruin into the terrain.")
|
||||
@Data
|
||||
public class IrisRuin implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key (procedural/<name>#<index>).")
|
||||
private String name = "ruin";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance (0-1) per chunk for this ruin to attempt placement. Use density to attempt more than one per chunk once the chance check passes.")
|
||||
private double chance = 0.05;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk. Defaults to a single ruin per qualifying chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this ruin. Higher means more variety (different heights, gap patterns, erosion seeds) at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants. Every random choice (size, weathering mask, erosion mask, accents) is derived from this.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("The placement mode used to anchor the ruin to the terrain. MIN_HEIGHT plants the lowest footprint corner on the ground (good for slabs and rubble on slopes); CENTER_HEIGHT averages the footprint (good for tall pillars and arches).")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.MIN_HEIGHT;
|
||||
|
||||
@Description("Rotate this ruin's placement so variants do not all face the same way.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min terrain height at which this ruin may place.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this ruin may place on the terrain surface, under carvings (caves), or both. SURFACE_ONLY keeps ruins above ground.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Description("If true the ruin anchors on the terrain height ignoring the water surface, so it can sit submerged. If false (default) it anchors to the surface and avoids water.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Description("The primary structural block, e.g. minecraft:cobblestone or minecraft:stone_bricks. Ignored when blockPalette is set. This is the bulk material of the ruin before weathering swaps some of it out.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:cobblestone";
|
||||
|
||||
@Description("A noise-driven palette for the primary block. When set this overrides the single block, letting the structure mix materials by noise. Palette wins over the block string via IrisProceduralBlocks.resolve.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Description("The overall silhouette of the ruin: PILLAR (broken column), WALL (gapped segment), ARCH (two legs plus a curved span), FLOOR_SLAB (foundation patch), or RUBBLE (low scattered pile).")
|
||||
private IrisRuinForm form = IrisRuinForm.PILLAR;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum structure height in blocks (PILLAR/WALL/ARCH height, slab thickness for FLOOR_SLAB, mound height for RUBBLE). Variants interpolate between this and heightMax.")
|
||||
private int heightMin = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum structure height in blocks. Variants interpolate between heightMin and this so taller and shorter ruins coexist.")
|
||||
private int heightMax = 9;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum footprint width (X axis) in blocks: column/leg thickness for PILLAR/ARCH, wall thickness for WALL, slab width for FLOOR_SLAB, blob width for RUBBLE.")
|
||||
private int widthMin = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum footprint width (X axis) in blocks. Variants interpolate between widthMin and this.")
|
||||
private int widthMax = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum footprint length (Z axis) in blocks: wall run length, arch leg spacing, slab length, rubble blob length.")
|
||||
private int lengthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum footprint length (Z axis) in blocks. Variants interpolate between lengthMin and this.")
|
||||
private int lengthMax = 7;
|
||||
|
||||
@Description("A palette of weathered variants (mossy/cracked block ids) blended over the structure by noise. When set this drives weathering; otherwise weatheredBlock is used.")
|
||||
private IrisMaterialPalette weatheringPalette = null;
|
||||
|
||||
@Description("A single weathered block id used when weatheringPalette is not set, e.g. minecraft:mossy_cobblestone. Applied to a noise-selected fraction of the structure, biased toward the lower rows.")
|
||||
@RegistryListBlockType
|
||||
private String weatheredBlock = "minecraft:mossy_cobblestone";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How much of the structure is replaced by weathered blocks (0 none, 1 nearly all). The replacement mask is value-noise driven and weighted so lower rows weather more than upper rows, mimicking moss climbing from the ground.")
|
||||
private double mossiness = 0.45;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(8)
|
||||
@Description("The scale of the weathering noise. Higher values produce smaller, busier moss/crack patches; lower values produce broad continuous weathered zones.")
|
||||
private double weatheringScale = 1.0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How crumbled the ruin is (0 intact, 1 mostly gone). Blocks whose value-noise falls below this threshold are deleted, so the shape reads as collapsed. Structural integrity is preserved: the bottom row and core legs are never eroded away.")
|
||||
private double erosion = 0.25;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(8)
|
||||
@Description("The scale of the erosion noise. Higher values knock out small speckled holes; lower values carve larger missing chunks out of the silhouette.")
|
||||
private double erosionScale = 1.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How far the structure extends below the surface as a fraction of its height (0 sits fully on top, 1 sinks it a full height into the ground). The buried rows live at negative y so the ruin reads as settled and partly swallowed by the terrain.")
|
||||
private double buriedFraction = 0.2;
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuinDecorator.class)
|
||||
@Description("Accent decorators applied after the ruin is built and eroded (moss carpets and lanterns on broken tops, vines and lichen on the faces, rubble and growth scattered around the base).")
|
||||
private KList<IrisRuinDecorator> accents = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = RuinGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("ruin-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("An accent block applied to a generated ruin after it is built and eroded, such as moss carpets on broken tops, vines on the faces, or rubble scattered around the base.")
|
||||
@Data
|
||||
public class IrisRuinDecorator {
|
||||
@Description("Where on the ruin this accent is placed. TOP sits on the highest block of each column, SURFACE clings to air-facing vertical faces, BASE_SCATTER rings the ground footprint around the base.")
|
||||
private IrisRuinDecoratorTarget target = IrisRuinDecoratorTarget.TOP;
|
||||
|
||||
@Required
|
||||
@Description("The block id to place, e.g. minecraft:moss_carpet or minecraft:vine. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "";
|
||||
|
||||
@Description("A noise-driven palette for this decorator. When set this overrides the single block, letting the accent mix blocks by noise. Resolved through IrisProceduralBlocks.resolve so the palette wins over the string.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance (0-1) per candidate position for this decorator to actually place. 1 covers every candidate, lower values leave sparse, patchy accents.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("For the BASE_SCATTER target, how many blocks beyond the ruin footprint the scatter ring extends outward in each direction. Higher values fling rubble and growth further from the structure.")
|
||||
private int scatterRadius = 2;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("The overall silhouette of a procedural ruin. Each form rasterizes a different crumbling man-made shape from the same size, weathering, and erosion settings.")
|
||||
public enum IrisRuinForm {
|
||||
@Description("A broken vertical column. A square trunk (widthMin..widthMax footprint) rises to a randomized height then snaps off with a jagged crown, leaving a toppled stub. Use for ancient pillars and obelisk stumps.")
|
||||
PILLAR,
|
||||
@Description("A standing wall segment. A flat slab spanning lengthMin..lengthMax long and heightMin..heightMax tall, thickness widthMin..widthMax, punched through with noise-driven gaps and a ragged top edge. Use for collapsed building sides and fortifications.")
|
||||
WALL,
|
||||
@Description("A freestanding arch. Two legs spaced by lengthMin..lengthMax joined at the top by a rasterized semicircular span (the lintel), so the structure literally arches. Use for gateways, aqueduct bays, and ruined doorways.")
|
||||
ARCH,
|
||||
@Description("A flat foundation patch. A single (or few) block-thick slab covering a widthMin..lengthMax footprint at ground level, heavily eroded into an irregular outline. Use for floor remnants, plazas, and building foundations.")
|
||||
FLOOR_SLAB,
|
||||
@Description("A low scattered debris pile. A noise blob of partial blocks mounded near the ground, tallest at the center and thinning toward the edges. Use for collapsed-structure rubble and scree.")
|
||||
RUBBLE
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
final class RuinBlockCanvas {
|
||||
enum Role {
|
||||
STRUCTURE,
|
||||
ACCENT
|
||||
}
|
||||
|
||||
static final class Cell {
|
||||
private Role role;
|
||||
private boolean structural;
|
||||
private NativeBlockState accentData;
|
||||
|
||||
Cell(Role role, boolean structural) {
|
||||
this.role = role;
|
||||
this.structural = structural;
|
||||
}
|
||||
|
||||
Role role() {
|
||||
return role;
|
||||
}
|
||||
|
||||
boolean structural() {
|
||||
return structural;
|
||||
}
|
||||
|
||||
NativeBlockState accentData() {
|
||||
return accentData;
|
||||
}
|
||||
|
||||
void promote(Role next, boolean structuralNext) {
|
||||
this.role = next;
|
||||
this.structural = this.structural || structuralNext;
|
||||
}
|
||||
|
||||
void makeAccent(NativeBlockState data) {
|
||||
this.role = Role.ACCENT;
|
||||
this.structural = false;
|
||||
this.accentData = data;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<Vector3i, Cell> cells = new HashMap<>();
|
||||
|
||||
Map<Vector3i, Cell> cells() {
|
||||
return cells;
|
||||
}
|
||||
|
||||
void set(int x, int y, int z, Role role, boolean structural) {
|
||||
Vector3i key = new Vector3i(x, y, z);
|
||||
Cell existing = cells.get(key);
|
||||
if (existing == null) {
|
||||
cells.put(key, new Cell(role, structural));
|
||||
} else {
|
||||
existing.promote(role, structural);
|
||||
}
|
||||
}
|
||||
|
||||
void accent(int x, int y, int z, NativeBlockState data) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
cells.put(new Vector3i(x, y, z), accentCell(data));
|
||||
}
|
||||
|
||||
private static Cell accentCell(NativeBlockState data) {
|
||||
Cell cell = new Cell(Role.ACCENT, false);
|
||||
cell.makeAccent(data);
|
||||
return cell;
|
||||
}
|
||||
|
||||
boolean has(int x, int y, int z) {
|
||||
return cells.containsKey(new Vector3i(x, y, z));
|
||||
}
|
||||
|
||||
Cell get(int x, int y, int z) {
|
||||
return cells.get(new Vector3i(x, y, z));
|
||||
}
|
||||
|
||||
void remove(int x, int y, int z) {
|
||||
cells.remove(new Vector3i(x, y, z));
|
||||
}
|
||||
}
|
||||
-124
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
final class RuinDecoratorApplier {
|
||||
private static final int[][] HORIZONTAL = {{1, 0, 0}, {-1, 0, 0}, {0, 0, 1}, {0, 0, -1}};
|
||||
|
||||
private RuinDecoratorApplier() {
|
||||
}
|
||||
|
||||
static void apply(RuinBlockCanvas canvas, IrisRuinDecorator decorator, IrisData data, long seed, RNG rng) {
|
||||
List<Vector3i> candidates = switch (decorator.getTarget()) {
|
||||
case TOP -> topCandidates(canvas);
|
||||
case SURFACE -> surfaceCandidates(canvas);
|
||||
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.getScatterRadius()));
|
||||
};
|
||||
|
||||
candidates.sort(Comparator.comparingInt(Vector3i::getX)
|
||||
.thenComparingInt(Vector3i::getY).thenComparingInt(Vector3i::getZ));
|
||||
RNG paletteRng = new RNG(seed);
|
||||
for (Vector3i v : candidates) {
|
||||
if (!rng.chance(decorator.getChance())) {
|
||||
continue;
|
||||
}
|
||||
NativeBlockState bd = IrisProceduralBlocks.resolve(decorator.getBlock(), decorator.getPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (bd != null) {
|
||||
canvas.accent(v.getBlockX(), v.getBlockY(), v.getBlockZ(), bd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Vector3i> topCandidates(RuinBlockCanvas canvas) {
|
||||
Map<Long, Integer> highest = new HashMap<>();
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
long key = columnKey(v.getBlockX(), v.getBlockZ());
|
||||
Integer current = highest.get(key);
|
||||
if (current == null || v.getBlockY() > current) {
|
||||
highest.put(key, v.getBlockY());
|
||||
}
|
||||
}
|
||||
List<Vector3i> out = new ArrayList<>();
|
||||
for (Map.Entry<Long, Integer> entry : highest.entrySet()) {
|
||||
int x = (int) (entry.getKey() >> 32);
|
||||
int z = (int) (entry.getKey() & 0xFFFFFFFFL);
|
||||
int y = entry.getValue() + 1;
|
||||
if (!canvas.has(x, y, z)) {
|
||||
out.add(new Vector3i(x, y, z));
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static List<Vector3i> surfaceCandidates(RuinBlockCanvas canvas) {
|
||||
List<Vector3i> out = new ArrayList<>();
|
||||
for (Vector3i v : new ArrayList<>(canvas.cells().keySet())) {
|
||||
for (int[] dir : HORIZONTAL) {
|
||||
int nx = v.getBlockX() + dir[0];
|
||||
int ny = v.getBlockY();
|
||||
int nz = v.getBlockZ() + dir[2];
|
||||
if (!canvas.has(nx, ny, nz)) {
|
||||
out.add(new Vector3i(nx, ny, nz));
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static List<Vector3i> baseScatterCandidates(RuinBlockCanvas canvas, int radius) {
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minZ = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxZ = Integer.MIN_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
minX = Math.min(minX, v.getBlockX());
|
||||
minZ = Math.min(minZ, v.getBlockZ());
|
||||
maxX = Math.max(maxX, v.getBlockX());
|
||||
maxZ = Math.max(maxZ, v.getBlockZ());
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
}
|
||||
|
||||
List<Vector3i> out = new ArrayList<>();
|
||||
for (int x = minX - radius; x <= maxX + radius; x++) {
|
||||
for (int z = minZ - radius; z <= maxZ + radius; z++) {
|
||||
if (!canvas.has(x, minY, z) && !canvas.has(x, minY + 1, z)) {
|
||||
out.add(new Vector3i(x, minY, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static long columnKey(int x, int z) {
|
||||
return ((long) x << 32) | (z & 0xFFFFFFFFL);
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralBlocks;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.iris.generation.decoration.tree.TreeFunctions;
|
||||
import art.arcane.volmlib.util.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class RuinGenerator {
|
||||
private RuinGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisRuin ruin, int variantIndex, RNG rng, IrisData data) {
|
||||
int count = Math.max(1, ruin.getVariants());
|
||||
int height = pick(ruin.getHeightMin(), ruin.getHeightMax(), variantIndex, count, rng);
|
||||
int width = pick(ruin.getWidthMin(), ruin.getWidthMax(), variantIndex, count, rng);
|
||||
int length = pick(ruin.getLengthMin(), ruin.getLengthMax(), variantIndex, count, rng);
|
||||
|
||||
RuinBlockCanvas canvas = new RuinBlockCanvas();
|
||||
switch (ruin.getForm()) {
|
||||
case PILLAR -> RuinShapes.pillar(canvas, Math.max(1, width), Math.max(2, height), rng);
|
||||
case WALL -> RuinShapes.wall(canvas, Math.max(1, width), Math.max(2, length), Math.max(2, height), rng);
|
||||
case ARCH -> RuinShapes.arch(canvas, Math.max(1, width), Math.max(3, length), Math.max(3, height), rng);
|
||||
case FLOOR_SLAB -> RuinShapes.floorSlab(canvas, Math.max(3, width), Math.max(3, length), Math.max(1, Math.min(height, 2)));
|
||||
case RUBBLE -> RuinShapes.rubble(canvas, Math.max(3, width), Math.max(3, length), Math.max(1, Math.min(height, 4)), rng);
|
||||
}
|
||||
|
||||
applyBurial(ruin, canvas, height);
|
||||
applyErosion(ruin, canvas);
|
||||
applyAccents(ruin, canvas, rng, data);
|
||||
|
||||
return resolve(ruin, canvas, data);
|
||||
}
|
||||
|
||||
private static int pick(int lo, int hi, int variantIndex, int count, RNG rng) {
|
||||
int min = Math.min(lo, hi);
|
||||
int max = Math.max(lo, hi);
|
||||
if (min == max || count <= 1) {
|
||||
return rng.i(min, max + 1);
|
||||
}
|
||||
double step = (max - min) / (double) (count - 1);
|
||||
double base = min + step * variantIndex;
|
||||
double jitter = rng.d(-step * 0.3, step * 0.3);
|
||||
return (int) Math.round(Math.max(min, Math.min(max, base + jitter)));
|
||||
}
|
||||
|
||||
private static void applyBurial(IrisRuin ruin, RuinBlockCanvas canvas, int height) {
|
||||
double fraction = clamp01(ruin.getBuriedFraction());
|
||||
if (fraction <= 0.0) {
|
||||
return;
|
||||
}
|
||||
int sink = (int) Math.round(height * fraction);
|
||||
if (sink <= 0) {
|
||||
return;
|
||||
}
|
||||
Map<Vector3i, RuinBlockCanvas.Cell> moved = new HashMap<>();
|
||||
for (Map.Entry<Vector3i, RuinBlockCanvas.Cell> entry : canvas.cells().entrySet()) {
|
||||
Vector3i v = entry.getKey();
|
||||
moved.put(new Vector3i(v.getBlockX(), v.getBlockY() - sink, v.getBlockZ()), entry.getValue());
|
||||
}
|
||||
canvas.cells().clear();
|
||||
canvas.cells().putAll(moved);
|
||||
}
|
||||
|
||||
private static void applyErosion(IrisRuin ruin, RuinBlockCanvas canvas) {
|
||||
double erosion = clamp01(ruin.getErosion());
|
||||
if (erosion <= 0.0) {
|
||||
return;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getErosionScale());
|
||||
long erosionSeed = ruin.getSeed() * 0x2545F4914F6CDD1DL + 17L;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
}
|
||||
|
||||
List<Vector3i> doomed = new ArrayList<>();
|
||||
for (Map.Entry<Vector3i, RuinBlockCanvas.Cell> entry : canvas.cells().entrySet()) {
|
||||
Vector3i v = entry.getKey();
|
||||
RuinBlockCanvas.Cell cell = entry.getValue();
|
||||
if (cell.structural() || v.getBlockY() <= minY) {
|
||||
continue;
|
||||
}
|
||||
int sx = (int) Math.round(v.getBlockX() * scale);
|
||||
int sy = (int) Math.round(v.getBlockY() * scale);
|
||||
int sz = (int) Math.round(v.getBlockZ() * scale);
|
||||
double n = TreeFunctions.valueNoise3D(sx, sy, sz, erosionSeed);
|
||||
if (n < erosion) {
|
||||
doomed.add(v);
|
||||
}
|
||||
}
|
||||
for (Vector3i v : doomed) {
|
||||
canvas.cells().remove(v);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyAccents(IrisRuin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
|
||||
if (ruin.getAccents() == null || ruin.getAccents().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int decoratorIndex = 0;
|
||||
for (art.arcane.iris.generation.decoration.ruin.IrisRuinDecorator decorator : ruin.getAccents()) {
|
||||
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.getSeed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
|
||||
decoratorIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private static IrisObject resolve(IrisRuin ruin, RuinBlockCanvas canvas, IrisData data) {
|
||||
if (canvas.cells().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getWeatheringScale());
|
||||
double mossiness = clamp01(ruin.getMossiness());
|
||||
long weatherSeed = ruin.getSeed() * 0x9E3779B97F4A7C15L + 101L;
|
||||
RNG paletteRng = new RNG(ruin.getSeed());
|
||||
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
maxY = Math.max(maxY, v.getBlockY());
|
||||
}
|
||||
int span = Math.max(1, maxY - minY);
|
||||
|
||||
Map<Vector3i, NativeBlockState> blocks = new HashMap<>();
|
||||
for (Map.Entry<Vector3i, RuinBlockCanvas.Cell> entry : canvas.cells().entrySet()) {
|
||||
Vector3i v = entry.getKey();
|
||||
RuinBlockCanvas.Cell cell = entry.getValue();
|
||||
NativeBlockState bd;
|
||||
if (cell.role() == RuinBlockCanvas.Role.ACCENT) {
|
||||
bd = cell.accentData();
|
||||
} else {
|
||||
bd = structuralBlock(ruin, cell, v, data, paletteRng, scale, mossiness, weatherSeed, minY, span);
|
||||
}
|
||||
if (bd != null) {
|
||||
blocks.put(v, bd);
|
||||
}
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.assemble(blocks);
|
||||
}
|
||||
|
||||
private static NativeBlockState structuralBlock(IrisRuin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
|
||||
boolean weathered = false;
|
||||
if (mossiness > 0.0) {
|
||||
int sx = (int) Math.round(v.getBlockX() * scale);
|
||||
int sy = (int) Math.round(v.getBlockY() * scale);
|
||||
int sz = (int) Math.round(v.getBlockZ() * scale);
|
||||
double n = TreeFunctions.valueNoise3D(sx, sy, sz, weatherSeed);
|
||||
double normalized = (v.getBlockY() - minY) / (double) span;
|
||||
double gradient = 1.0 - 0.6 * normalized;
|
||||
weathered = n < mossiness * gradient;
|
||||
}
|
||||
|
||||
if (weathered) {
|
||||
NativeBlockState wd = IrisProceduralBlocks.resolve(ruin.getWeatheredBlock(), ruin.getWeatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (wd != null) {
|
||||
return wd;
|
||||
}
|
||||
}
|
||||
return IrisProceduralBlocks.resolve(ruin.getBlock(), ruin.getBlockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
}
|
||||
|
||||
private static double clamp01(double value) {
|
||||
if (value < 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
if (value > 1.0) {
|
||||
return 1.0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.ruin;
|
||||
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
final class RuinShapes {
|
||||
private RuinShapes() {
|
||||
}
|
||||
|
||||
static void pillar(RuinBlockCanvas canvas, int width, int height, RNG rng) {
|
||||
int half = (width - 1) / 2;
|
||||
int broken = Math.max(2, height - rng.i(0, Math.max(1, height / 3)));
|
||||
for (int y = 0; y < broken; y++) {
|
||||
boolean bottom = y == 0;
|
||||
int jitter = y >= broken - 1 ? rng.i(0, 2) : 0;
|
||||
for (int x = -half; x <= half; x++) {
|
||||
for (int z = -half; z <= half; z++) {
|
||||
if (y == broken - 1 && jitter > 0 && (Math.abs(x) == half || Math.abs(z) == half) && rng.chance(0.5)) {
|
||||
continue;
|
||||
}
|
||||
canvas.set(x, y, z, RuinBlockCanvas.Role.STRUCTURE, bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int stub = rng.i(0, 3);
|
||||
if (stub > 0) {
|
||||
int dir = rng.i(0, 4);
|
||||
int dx = dir == 0 ? 1 : (dir == 1 ? -1 : 0);
|
||||
int dz = dir == 2 ? 1 : (dir == 3 ? -1 : 0);
|
||||
for (int s = 1; s <= stub; s++) {
|
||||
canvas.set((half + s) * dx, 0, (half + s) * dz, RuinBlockCanvas.Role.STRUCTURE, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wall(RuinBlockCanvas canvas, int thickness, int length, int height, RNG rng) {
|
||||
int half = (length - 1) / 2;
|
||||
int tHalf = (thickness - 1) / 2;
|
||||
long edgeSeed = rng.lmax();
|
||||
for (int z = -half; z <= half; z++) {
|
||||
int top = height - jaggedDrop(z, height, edgeSeed);
|
||||
for (int y = 0; y < top; y++) {
|
||||
if (y > 0 && rng.chance(0.10)) {
|
||||
continue;
|
||||
}
|
||||
for (int x = -tHalf; x <= thickness - 1 - tHalf; x++) {
|
||||
canvas.set(x, y, z, RuinBlockCanvas.Role.STRUCTURE, y == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void arch(RuinBlockCanvas canvas, int thickness, int span, int height, RNG rng) {
|
||||
int legSpacing = Math.max(2, span);
|
||||
int legGap = (legSpacing - 1) / 2;
|
||||
int tHalf = (thickness - 1) / 2;
|
||||
int legTop = Math.max(2, height - Math.max(2, (legSpacing / 2)));
|
||||
|
||||
for (int side = -1; side <= 1; side += 2) {
|
||||
int legZ = side * legGap;
|
||||
for (int y = 0; y < legTop; y++) {
|
||||
for (int x = -tHalf; x <= thickness - 1 - tHalf; x++) {
|
||||
canvas.set(x, y, legZ, RuinBlockCanvas.Role.STRUCTURE, y <= 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double radius = legGap;
|
||||
int crown = legTop + (int) Math.round(radius);
|
||||
for (int z = -legGap; z <= legGap; z++) {
|
||||
double inside = radius * radius - (z * z);
|
||||
if (inside < 0) {
|
||||
continue;
|
||||
}
|
||||
int y = legTop + (int) Math.round(Math.sqrt(inside));
|
||||
for (int yy = legTop; yy <= y && yy <= crown; yy++) {
|
||||
boolean keystone = Math.abs(z) <= 1;
|
||||
for (int x = -tHalf; x <= thickness - 1 - tHalf; x++) {
|
||||
canvas.set(x, yy, z, RuinBlockCanvas.Role.STRUCTURE, keystone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void floorSlab(RuinBlockCanvas canvas, int width, int length, int thickness) {
|
||||
int xHalf = (width - 1) / 2;
|
||||
int zHalf = (length - 1) / 2;
|
||||
for (int y = 0; y < thickness; y++) {
|
||||
for (int x = -xHalf; x <= width - 1 - xHalf; x++) {
|
||||
for (int z = -zHalf; z <= length - 1 - zHalf; z++) {
|
||||
canvas.set(x, y, z, RuinBlockCanvas.Role.STRUCTURE, y == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rubble(RuinBlockCanvas canvas, int width, int length, int peak, RNG rng) {
|
||||
int xHalf = (width - 1) / 2;
|
||||
int zHalf = (length - 1) / 2;
|
||||
long blobSeed = rng.lmax();
|
||||
double rx = Math.max(1.0, width / 2.0);
|
||||
double rz = Math.max(1.0, length / 2.0);
|
||||
|
||||
for (int x = -xHalf; x <= width - 1 - xHalf; x++) {
|
||||
for (int z = -zHalf; z <= length - 1 - zHalf; z++) {
|
||||
double radial = (x * x) / (rx * rx) + (z * z) / (rz * rz);
|
||||
if (radial > 1.2) {
|
||||
continue;
|
||||
}
|
||||
double falloff = Math.max(0.0, 1.0 - radial);
|
||||
double noise = art.arcane.iris.generation.decoration.tree.TreeFunctions.valueNoise3D(x, 0, z, blobSeed);
|
||||
int columnHeight = (int) Math.round(peak * falloff * (0.6 + 0.4 * noise));
|
||||
for (int y = 0; y <= columnHeight; y++) {
|
||||
if (y > 0 && rng.chance(0.25)) {
|
||||
continue;
|
||||
}
|
||||
canvas.set(x, y, z, RuinBlockCanvas.Role.STRUCTURE, y == 0 && radial < 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int jaggedDrop(int z, int height, long seed) {
|
||||
double n = art.arcane.iris.generation.decoration.tree.TreeFunctions.valueNoise1D(z * 0.9, seed);
|
||||
return (int) Math.round(n * Math.max(1, height - 1) * 0.6);
|
||||
}
|
||||
}
|
||||
-344
@@ -1,344 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.iris.generation.cave.CarvingMode;
|
||||
import art.arcane.iris.generation.decoration.IrisProceduralPlacement;
|
||||
import art.arcane.iris.generation.subterrain.SubterrainRoom;
|
||||
import art.arcane.iris.generation.decoration.IrisStiltSettings;
|
||||
import art.arcane.iris.generation.decoration.IrisVacuumSettings;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObject;
|
||||
import art.arcane.iris.structure.object.IrisObjectLimit;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.structure.object.IrisObjectRotation;
|
||||
import art.arcane.iris.structure.object.IrisObjectTranslate;
|
||||
import art.arcane.iris.structure.object.ObjectPlaceMode;
|
||||
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("procedural-tree")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A single procedurally generated tree. Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file.")
|
||||
@Data
|
||||
public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Description("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "procedural-tree";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per chunk for this tree to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Description("How many distinct variants to pre-bake for this tree. Higher means more variety at a small memory cost.")
|
||||
private int variants = 8;
|
||||
|
||||
@Description("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Description("If true (default) leaves are placed with vanilla distance-from-wood values and persistent=false so leaf decay behaves naturally and the tree reads as plausible. If false, leaves are forced persistent and never decay (a raw object dump).")
|
||||
private boolean plausible = true;
|
||||
|
||||
@Description("The placement mode used to anchor the tree to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Description("Rotate this tree's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Description("Limit the max or min height of placement.")
|
||||
private IrisObjectLimit clamp = new IrisObjectLimit();
|
||||
|
||||
@Description("Whether this tree may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Description("If true, the tree anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Description("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Description("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private IrisStiltSettings stiltSettings;
|
||||
|
||||
@Description("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private IrisVacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Description("The trunk (log) block, e.g. minecraft:oak_log. Ignored when trunkPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String trunk = "minecraft:oak_log";
|
||||
|
||||
@Description("A noise-driven palette for the trunk. When set this overrides the single trunk block, letting the trunk mix blocks by noise.")
|
||||
private IrisMaterialPalette trunkPalette = null;
|
||||
|
||||
@Required
|
||||
@Description("The leaf block, e.g. minecraft:oak_leaves. Ignored when leavesPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String leaves = "minecraft:oak_leaves";
|
||||
|
||||
@Description("A noise-driven palette for the leaves. When set this overrides the single leaf block, letting the canopy mix leaf (or other) blocks by noise. Only blocks that are actually leaves get vanilla decay distances.")
|
||||
private IrisMaterialPalette leavesPalette = null;
|
||||
|
||||
@Description("The named canopy profile that drives default crown radii and shape.")
|
||||
private IrisTreeProfile profile = IrisTreeProfile.OAK;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Minimum trunk height in blocks.")
|
||||
private int heightMin = 8;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum trunk height in blocks.")
|
||||
private int heightMax = 12;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Base trunk width in blocks. 1 is a single column, 2 is a 2x2 trunk, etc.")
|
||||
private int trunkWidth = 1;
|
||||
|
||||
@Description("The function used to shape trunk width over height.")
|
||||
private IrisTreeFunction trunkShape = IrisTreeFunction.CONSTANT;
|
||||
|
||||
@Description("Width multiplier at the base for the LINEAR trunk shape.")
|
||||
private double shapeStart = 1;
|
||||
|
||||
@Description("Width multiplier at the top for the LINEAR trunk shape.")
|
||||
private double shapeEnd = 1;
|
||||
|
||||
@Description("Steepness for the SIGMOID trunk shape.")
|
||||
private double shapeSteepness = 5;
|
||||
|
||||
@Description("Base for the LOG trunk shape.")
|
||||
private double shapeBase = 2.718281828;
|
||||
|
||||
@Description("Period for the SINE trunk shape.")
|
||||
private double shapePeriod = 1;
|
||||
|
||||
@Description("Amplitude for the SINE trunk shape.")
|
||||
private double shapeAmplitude = 0.2;
|
||||
|
||||
@Description("Pinch position (0-1) for the PARABOLIC trunk shape.")
|
||||
private double shapePeakOffset = 0.5;
|
||||
|
||||
@Description("Minimum width fraction at the waist for the PARABOLIC trunk shape.")
|
||||
private double shapeFloor = 0.5;
|
||||
|
||||
@Description("Compass direction in degrees the trunk leans toward.")
|
||||
private double leanAzimuth = 0;
|
||||
|
||||
@Description("How far the trunk leans, in degrees from vertical. 0 is perfectly upright.")
|
||||
private double leanAngle = 0;
|
||||
|
||||
@Description("How the lean accumulates over height.")
|
||||
private IrisTreeFunction trunkCurve = IrisTreeFunction.LINEAR;
|
||||
|
||||
@Description("Steepness for the SIGMOID trunk curve.")
|
||||
private double curveSteepness = 8;
|
||||
|
||||
@Description("How the lean azimuth itself changes over height (for spiraling or wandering trunks).")
|
||||
private IrisTreeAzimuthMode leanAzimuthMode = IrisTreeAzimuthMode.CONSTANT;
|
||||
|
||||
@Description("Azimuth at the base for the LINEAR azimuth mode.")
|
||||
private double azimuthStart = 0;
|
||||
|
||||
@Description("Azimuth at the top for the LINEAR azimuth mode.")
|
||||
private double azimuthEnd = 0;
|
||||
|
||||
@Description("Number of full turns for the SPIRAL azimuth mode.")
|
||||
private double azimuthTurns = 1;
|
||||
|
||||
@Description("Amplitude for the SINE azimuth mode.")
|
||||
private double azimuthAmplitude = 90;
|
||||
|
||||
@Description("Period for the SINE azimuth mode.")
|
||||
private double azimuthPeriod = 1;
|
||||
|
||||
@Description("Offset for the SINE azimuth mode.")
|
||||
private double azimuthOffset = 0;
|
||||
|
||||
@Description("Scale for the NOISE azimuth mode.")
|
||||
private double azimuthScale = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Number of branches per whorl ring for the WHORL branch azimuth mode.")
|
||||
private int azimuthWhorlCount = 5;
|
||||
|
||||
@Description("Optional accent leaf block scattered through the canopy (blossoms, shroomlight).")
|
||||
@RegistryListBlockType
|
||||
private String secondaryLeaves = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The fraction of leaves replaced by the secondary leaf block(s).")
|
||||
private double secondaryLeafFraction = 0.35;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeSecondaryLeaf.class)
|
||||
@Description("Optional weighted set of accent leaf blocks. When set this overrides the single secondaryLeaves block.")
|
||||
private KList<IrisTreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
|
||||
|
||||
@Description("A noise-driven palette for the secondary (accent) leaves. When set this overrides both secondaryLeaves and weightedSecondaryLeaves.")
|
||||
private IrisMaterialPalette secondaryLeavesPalette = null;
|
||||
|
||||
@Description("Optional secondary trunk block used over a height band (for color-banded trunks). Ignored when secondaryTrunkPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String secondaryTrunk = null;
|
||||
|
||||
@Description("A noise-driven palette for the secondary trunk band. When set this overrides the single secondaryTrunk block.")
|
||||
private IrisMaterialPalette secondaryTrunkPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The normalized height where the secondary trunk band starts.")
|
||||
private double secondaryTrunkStart = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The normalized height where the secondary trunk band ends.")
|
||||
private double secondaryTrunkEnd = 1;
|
||||
|
||||
@Description("If true, a root system extends below (and around) the base so the tree connects to the ground on uneven terrain.")
|
||||
private boolean roots = true;
|
||||
|
||||
@Description("How the root system is built when roots is true.")
|
||||
private IrisTreeRootStyle rootStyle = IrisTreeRootStyle.BUTTRESS;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Root depth in blocks, also used for ground-contact extension up to 16 blocks. 0 scales with tree height.")
|
||||
private int rootDepth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Horizontal reach of buttress and stilt roots. 0 uses a compact radius based on trunk width. Taproots ignore this field.")
|
||||
private double rootFlare = 0;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(6)
|
||||
@Description("How many separate trunks the tree splits into above forkHeight. 1 is a single trunk.")
|
||||
private int trunkForks = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The normalized height where the trunk splits into forks.")
|
||||
private double forkHeight = 0.5;
|
||||
|
||||
@Description("The outward lean angle in degrees of each fork.")
|
||||
private double forkAngle = 25;
|
||||
|
||||
@Description("The leaf crown configuration.")
|
||||
private IrisTreeCanopy canopy = new IrisTreeCanopy();
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeDecorator.class)
|
||||
@Description("Accent decorators applied after the tree is built (fruit, vines, snow, glow).")
|
||||
private KList<IrisTreeDecorator> decorators = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
int lo = Math.min(heightMin, heightMax);
|
||||
int hi = Math.max(heightMin, heightMax);
|
||||
RNG heightRng = new RNG(seed);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = ProceduralTreeGenerator.generate(this, Math.max(2, height), new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey(getVariantLoadKey(i));
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
if (new java.io.File("plugins/Iris/goldendebug.txt").isFile()) {
|
||||
for (IrisObject object : baked) {
|
||||
long[] digest = new long[]{0L};
|
||||
object.getBlocks().forEach((vector, state) -> {
|
||||
long position = ((long) vector.getBlockX() << 40) ^ ((long) vector.getBlockY() << 20) ^ vector.getBlockZ();
|
||||
digest[0] ^= Long.rotateLeft(position * 0x9E3779B97F4A7C15L ^ state.key().hashCode(), (int) (position & 63));
|
||||
});
|
||||
IrisLogging.debug("Goldendebug bake: " + object.getLoadKey() + " blocks=" + object.getBlocks().size() + " digest=" + Long.toHexString(digest[0]));
|
||||
}
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng, SubterrainRoom room) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public String getVariantLoadKey(int index) {
|
||||
if (index < 0) {
|
||||
throw new IllegalArgumentException("index must not be negative");
|
||||
}
|
||||
return "procedural/tree/" + name + "#" + index;
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("Controls the compass direction (azimuth) of trunk lean as it rises, or the direction each branch is thrown.")
|
||||
public enum IrisTreeAzimuthMode {
|
||||
@Description("A single fixed azimuth.")
|
||||
CONSTANT,
|
||||
@Description("Azimuth ramps straight from start to end with height.")
|
||||
LINEAR,
|
||||
@Description("Azimuth winds around the trunk a number of turns (corkscrew).")
|
||||
SPIRAL,
|
||||
@Description("Azimuth oscillates with a sine wave.")
|
||||
SINE,
|
||||
@Description("Azimuth wanders using deterministic noise.")
|
||||
NOISE,
|
||||
@Description("Each branch picks a uniformly random azimuth (falls back to constant for trunk lean).")
|
||||
RANDOM,
|
||||
@Description("Phyllotaxis: each successive branch is offset by the 137.5 degree golden angle for the most natural spiral packing (branches).")
|
||||
GOLDEN_ANGLE,
|
||||
@Description("Each successive branch is thrown to the opposite side (180 degrees apart).")
|
||||
ALTERNATING,
|
||||
@Description("Branches are grouped into evenly spaced whorls of azimuthWhorlCount around each ring.")
|
||||
WHORL,
|
||||
@Description("Azimuth zigzags by +/- amplitude on alternating branches.")
|
||||
ZIGZAG
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("Controls how the chance of spawning a branch varies with trunk height (0 at the base, 1 at the top).")
|
||||
public enum IrisTreeBranchProbability {
|
||||
@Description("Same branch chance at every height.")
|
||||
CONSTANT,
|
||||
@Description("Ramps straight from base chance to crown chance.")
|
||||
LINEAR,
|
||||
@Description("S-curve that switches on around a midpoint height.")
|
||||
SIGMOID,
|
||||
@Description("Chance rises with height raised to an exponent, clustering branches near the crown.")
|
||||
TOP_HEAVY,
|
||||
@Description("Bell curve peaking in a height band.")
|
||||
GAUSSIAN,
|
||||
@Description("Irregular organic branching from deterministic noise.")
|
||||
NOISE,
|
||||
@Description("Chance falls with height (1-t)^exponent, clustering branches near the base.")
|
||||
BOTTOM_HEAVY,
|
||||
@Description("Regular whorl rings of branches at evenly spaced heights (periods controls count).")
|
||||
PERIODIC,
|
||||
@Description("Branches only within a height window around mean +/- std.")
|
||||
BAND,
|
||||
@Description("Inverse of GAUSSIAN: branches avoid the mean band and favor base and crown.")
|
||||
INVERSE_GAUSSIAN,
|
||||
@Description("Exponential decay from the base upward (constant * e^-exponent*t).")
|
||||
EXPONENTIAL_DECAY
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-branches")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("A branch system that throws limbs out of the trunk and places a leaf ball at each tip. When present, branches drive the canopy and only the topmost crown disc of the profile is still placed.")
|
||||
@Data
|
||||
public class IrisTreeBranches {
|
||||
@Description("How branch spawn chance varies over trunk height.")
|
||||
private IrisTreeBranchProbability probabilityFunction = IrisTreeBranchProbability.TOP_HEAVY;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch chance for the CONSTANT probability function.")
|
||||
private double probabilityConstant = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch chance at the base for the LINEAR probability function.")
|
||||
private double probabilityBase = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch chance at the crown for the LINEAR probability function.")
|
||||
private double probabilityCrown = 1;
|
||||
|
||||
@Description("Steepness for the SIGMOID probability function.")
|
||||
private double probabilitySteepness = 10;
|
||||
|
||||
@Description("Midpoint height (0-1) for the SIGMOID probability function.")
|
||||
private double probabilityMidpoint = 0.7;
|
||||
|
||||
@Description("Exponent for the TOP_HEAVY probability function.")
|
||||
private double probabilityExponent = 2;
|
||||
|
||||
@Description("Mean height (0-1) for the GAUSSIAN probability function.")
|
||||
private double probabilityMean = 0.7;
|
||||
|
||||
@Description("Standard deviation for the GAUSSIAN probability function.")
|
||||
private double probabilityStd = 0.15;
|
||||
|
||||
@Description("Noise scale for the NOISE probability function.")
|
||||
private double probabilityScale = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Number of whorl rings over the trunk height for the PERIODIC probability function.")
|
||||
private double probabilityPeriods = 5;
|
||||
|
||||
@Description("How branch length varies over trunk height.")
|
||||
private IrisTreeFunction lengthFunction = IrisTreeFunction.LINEAR;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch length at the base for the LINEAR length function.")
|
||||
private double lengthBase = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch length at the crown for the LINEAR length function.")
|
||||
private double lengthCrown = 4;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Branch length for the CONSTANT length function.")
|
||||
private double lengthConstant = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Maximum branch length for the SIGMOID, LOG and PARABOLIC length functions.")
|
||||
private double lengthMax = 4;
|
||||
|
||||
@Description("Steepness for the SIGMOID length function.")
|
||||
private double lengthSteepness = 5;
|
||||
|
||||
@Description("How the compass direction of each branch is chosen.")
|
||||
private IrisTreeAzimuthMode azimuthMode = IrisTreeAzimuthMode.RANDOM;
|
||||
|
||||
@Description("Fixed azimuth in degrees when azimuthMode is CONSTANT.")
|
||||
private double azimuth = 0;
|
||||
|
||||
@Description("Elevation angle in degrees from horizontal. 0 is flat, positive points up, negative droops down.")
|
||||
private double elevation = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("How much each branch sags/droops along its length (catenary). 0 is a straight branch; higher values arc the branch and its tip downward.")
|
||||
private double sag = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(6)
|
||||
@Description("How many recursive levels of sub-branches to grow. 0 is none, 1 is a single level, 2+ produces fractal branching.")
|
||||
private int branchDepth = 1;
|
||||
|
||||
@Description("If true, branches are clamped to never droop below horizontal (useful for upright species).")
|
||||
private boolean leafStartUp = false;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Leaf ball radius placed at each branch tip.")
|
||||
private int clusterRadius = 2;
|
||||
|
||||
@Description("How the branch tip leaf cluster fills.")
|
||||
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@Description("Fill density for the branch tip leaf cluster when clusterMode is density or noise.")
|
||||
private double clusterDensity = 0.85;
|
||||
|
||||
@Description("Optional one level of recursive sub-branches sprouting from each branch tip.")
|
||||
private IrisTreeSubBranches subBranches = null;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-canopy")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("The leaf crown of a procedural tree. Built from stacked dome-shaped discs (driven by the profile or by explicit layers) and optionally a branch system.")
|
||||
@Data
|
||||
public class IrisTreeCanopy {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(180)
|
||||
@Description("Elevation angle in degrees from vertical for each leaf dome. 90 is a flat disc, below 90 domes downward into a sphere, above 90 flares outward into an umbrella.")
|
||||
private double startAngle = 90;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Vertical scale of the canopy volume. Lower values flatten the crown.")
|
||||
private double squish = 1;
|
||||
|
||||
@Description("How leaves fill each canopy disc.")
|
||||
private IrisTreeLeafMode mode = IrisTreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("Fill probability used by the density and noise leaf modes.")
|
||||
private double leafDensity = 0.85;
|
||||
|
||||
@MinNumber(0.1)
|
||||
@Description("Horizontal X stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
|
||||
private double crownStretchX = 1;
|
||||
|
||||
@MinNumber(0.1)
|
||||
@Description("Horizontal Z stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
|
||||
private double crownStretchZ = 1;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeLayer.class)
|
||||
@Description("Optional explicit crown discs. When provided these replace the profile-driven layers and let you sculpt the silhouette by hand.")
|
||||
private KList<IrisTreeLayer> layers = new KList<>();
|
||||
|
||||
@Description("Optional branch system. When present, branches build most of the canopy and only the topmost profile disc is still placed as a crown.")
|
||||
private IrisTreeBranches branches = null;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MaxNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.RegistryListBlockType;
|
||||
import art.arcane.iris.pack.schema.annotation.Required;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("An accent block applied to a generated tree such as fruit on branch tips, vines on the trunk, snow on the crown, or a glowing underside.")
|
||||
@Data
|
||||
public class IrisTreeDecorator {
|
||||
@Description("Where this decorator is placed on the tree.")
|
||||
private IrisTreeDecoratorTarget target = IrisTreeDecoratorTarget.BRANCH_TIP;
|
||||
|
||||
@Required
|
||||
@Description("The block id to place, e.g. minecraft:magma_block. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "";
|
||||
|
||||
@Description("A noise-driven palette for this decorator. When set this overrides the single block.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Description("The chance per candidate position for this decorator to place.")
|
||||
private double chance = 0.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Description("Maximum strand length downward for the CANOPY_HANG target (random 1..length per column).")
|
||||
private int length = 1;
|
||||
|
||||
@Description("If true the block's facing is oriented away from the trunk (for trunk-mounted fences/gates/banners).")
|
||||
private boolean axisAware = false;
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("Where a tree decorator block is placed.")
|
||||
public enum IrisTreeDecoratorTarget {
|
||||
@Description("At the tip of each generated branch (vines, fruit, lanterns).")
|
||||
BRANCH_TIP,
|
||||
@Description("On air-facing sides of trunk and branch blocks (vines, moss).")
|
||||
TRUNK_SURFACE,
|
||||
@Description("On top of the highest block in each column (snow, sculk).")
|
||||
CANOPY_TOP,
|
||||
@Description("One block below the lowest leaf in each column (glowing underside).")
|
||||
CANOPY_BOTTOM,
|
||||
@Description("Around the y=0 ring at the base of the trunk (roots, mushrooms).")
|
||||
TRUNK_BASE,
|
||||
@Description("On air-facing sides of leaf blocks (berries, lights nestled in the foliage).")
|
||||
LEAF_SURFACE,
|
||||
@Description("Hanging strands of up to 'length' blocks below the lowest leaf in each column (vines, icicles).")
|
||||
CANOPY_HANG,
|
||||
@Description("On the top face of trunk and branch blocks (moss, snow on limbs).")
|
||||
BRANCH_SURFACE,
|
||||
@Description("One block above the very top of the trunk (nest, beehive, beacon).")
|
||||
TRUNK_TOP,
|
||||
@Description("Scattered across the ground footprint around the base, wider than the trunk-base ring.")
|
||||
GROUND_SCATTER
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("A shaping function evaluated over normalized height (0 at the base, 1 at the top). Used for trunk width, trunk curve and branch length.")
|
||||
public enum IrisTreeFunction {
|
||||
@Description("Same value at every height.")
|
||||
CONSTANT,
|
||||
@Description("Ramps straight from start to end.")
|
||||
LINEAR,
|
||||
@Description("S-curve transition controlled by steepness.")
|
||||
SIGMOID,
|
||||
@Description("Logarithmic falloff controlled by base.")
|
||||
LOG,
|
||||
@Description("Sine ripple controlled by period and amplitude.")
|
||||
SINE,
|
||||
@Description("Parabolic pinch, narrowest at peakOffset.")
|
||||
PARABOLIC,
|
||||
@Description("Geometric (exponential) interpolation from start to end.")
|
||||
EXPONENTIAL,
|
||||
@Description("Square-root ease: fast change low, slow high.")
|
||||
SQRT,
|
||||
@Description("Hard step that jumps from start to end at the threshold (peakOffset).")
|
||||
STEP,
|
||||
@Description("Bell bulge peaking in the middle of the height range.")
|
||||
BELL,
|
||||
@Description("Smoothstep ease-in-out (3t^2 - 2t^3).")
|
||||
EASE_IN_OUT
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
import art.arcane.iris.pack.schema.annotation.MinNumber;
|
||||
import art.arcane.iris.pack.schema.annotation.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-layer")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Description("An explicit canopy disc at a given vertical offset and radius. Define a list of these to bypass the profile and sculpt the crown by hand.")
|
||||
@Data
|
||||
public class IrisTreeLayer {
|
||||
@Description("The vertical offset of this disc, measured in blocks above the trunk base.")
|
||||
private int yOffset = 0;
|
||||
|
||||
@MinNumber(0.5)
|
||||
@Description("The radius of this leaf disc in blocks.")
|
||||
private double radius = 2;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("How leaves fill a disc or cluster.")
|
||||
public enum IrisTreeLeafMode {
|
||||
@Description("Corner-trimmed disc/sphere for a rounded silhouette.")
|
||||
TRIMMED,
|
||||
@Description("Completely filled disc/sphere.")
|
||||
FILLED,
|
||||
@Description("Seeded probabilistic falloff toward the edge controlled by leafDensity.")
|
||||
DENSITY,
|
||||
@Description("Seeded value-noise mask controlled by leafDensity.")
|
||||
NOISE,
|
||||
@Description("Only the outer shell is placed, leaving the interior hollow.")
|
||||
HOLLOW,
|
||||
@Description("Quadratic radial gradient: dense at the center, thinning sharply toward the edge.")
|
||||
GRADIENT,
|
||||
@Description("Coarse low-frequency noise that forms clumps and gaps of foliage.")
|
||||
CLUMPED,
|
||||
@Description("Trimmed with heavy random erosion of the outer ring for a ragged, weathered look.")
|
||||
TATTERED,
|
||||
@Description("Very thin scattering of leaves across the volume.")
|
||||
SPARSE
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.generation.decoration.tree;
|
||||
|
||||
import art.arcane.volmlib.util.documentation.Description;
|
||||
|
||||
@Description("Named canopy presets that drive default layer radii and shape, scaled to the tree height.")
|
||||
public enum IrisTreeProfile {
|
||||
@Description("Rounded broadleaf crown.")
|
||||
OAK,
|
||||
@Description("Slim upright broadleaf crown.")
|
||||
BIRCH,
|
||||
@Description("Upright broadleaf crown with a rounded upper canopy and a tapered top.")
|
||||
POPLAR,
|
||||
@Description("Narrow conifer cone.")
|
||||
SPRUCE,
|
||||
@Description("Tall thin crown concentrated near the very top.")
|
||||
JUNGLE,
|
||||
@Description("Flat shallow umbrella crown.")
|
||||
ACACIA,
|
||||
@Description("Dense rounded broadleaf crown.")
|
||||
DARK_OAK,
|
||||
@Description("Flat wide umbrella crown compressed into the top quarter (vanilla dark oak look).")
|
||||
DARK_OAK_FLAT,
|
||||
@Description("Extra wide flat umbrella that overlaps into a continuous roofed canopy.")
|
||||
DARK_OAK_FLAT_WIDE,
|
||||
@Description("Broad rounded blossom crown.")
|
||||
CHERRY,
|
||||
@Description("Bare trunk with a small tuft of fronds only at the very top.")
|
||||
PALM,
|
||||
@Description("Broad crown with wide drooping radii, ideal with a low startAngle to make a weeping skirt.")
|
||||
WILLOW,
|
||||
@Description("Very narrow tall crown hugging the trunk (cypress / lombardy poplar).")
|
||||
COLUMNAR,
|
||||
@Description("Squat, wide, low crown for shrubs and saplings.")
|
||||
BUSH,
|
||||
@Description("Giant conifer cone for 2x2 mega spruce trunks.")
|
||||
MEGA_SPRUCE
|
||||
}
|
||||
Loaded 100 of 990 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user