Expand Arrakis sietches and add admin commands

This commit is contained in:
unimatrixgit 2026-10-13 03:39:06 +02:00
commit c53d8bf9fd
10 changed files with 332 additions and 29 deletions

View file

@ -1,6 +1,6 @@
# Arrakis Water & Sietch prototype
New Arrakis chunks can generate sandstone **sietches** with a cave and small water reservoir beneath. Existing chunks will not be retroactively populated. Generation is approximately 1 in 90 chunks (hard-coded in the populator; config field is informational for now).
New Arrakis chunks generate underground cave **sietches** at roughly 2,000-block spacing. Each has connected chambers for sleeping and cooking, a concealed surface entry, a descending waterfall, and a bottom water reservoir. A chest opens a personal cache for each player with at least 250 tagged spice, enchanted gold armor, planks, and bread. Existing chunks will not be retroactively populated. See `plugins/DuneTerrain/config.yml` (`sietches.spacing`) to change the interval.
- `/dune water guild` - become an official Spacing Guild water seller.
- `/dune water smuggler` - become a smuggler.

View file

@ -1,10 +1,10 @@
# DuneCore for Paper 1.21.4
Requires Java 21 and Gradle 8+. Run `gradle build` and copy `build/libs/DuneCore-1.0.1.jar` into your Paper server's `plugins/` directory. DuneCore provides factions, spice gameplay, politics, jobs, and Guild travel. Install the separate `DuneTerrain` plugin to generate the server's planet world. Remove the old `DuneRealms.jar` from the Paper `plugins/` folder when upgrading to `DuneCore.jar`.
Requires Java 21 and Gradle 8+. Run `gradle build` and copy `build/libs/DuneCore-1.0.2.jar` into your Paper server's `plugins/` directory. DuneCore provides factions, spice gameplay, politics, jobs, and Guild travel. Install the separate `DuneTerrain` plugin to generate the server's planet world. Remove the old `DuneRealms.jar` from the Paper `plugins/` folder when upgrading to `DuneCore.jar`.
Commands: `/dune choose fremen|harkonnen|corrino|atreides`, `/dune kit`, `/dune balance`, `/dune sell`, `/dune travel`, `/dune guildnpc` (OP), `/dune givespice` (OP).
For proxy travel, configure `network.local-planet` for this backend and the `network.servers` proxy names. The selected world is generated by DuneTerrain, with `server.planet` in `plugins/DuneTerrain/config.yml` set to the same planet. DuneTerrain applies terrain generation only when the world is first created; existing worlds and generated chunks are not replaced.
For proxy travel, configure `network.local-planet` for this backend and the `network.servers` proxy names. The selected world is generated by DuneTerrain, with `server.planet` in `plugins/DuneTerrain/config.yml` set to the same planet. DuneTerrain applies terrain generation only when the world is first created; existing worlds and generated chunks are not replaced. On Arrakis, defaults place cave sietches about every 2,000 blocks and sand-covered darkstone islands about every 750 blocks. Sietches include sleeping and kitchen chambers, a water descent to a reservoir, and a personal cache with at least 250 tagged spice, enchanted gold armor, planks, and bread. Oasis trees remain sparse at roughly 300-block spacing. Admins can use `/dune admin sietch [player]` to teleport to the nearest generated sietch, `/dune admin arrakis [player]` to reach the Arrakis spawn, and `/dune admin solari <player> <amount>` to grant Solaris to an online player.
Suspicious sand on Arrakis is harvestable spice. Use the tagged netherite spice shovel from `/dune kit`. Spice can be sold with `/dune sell` and Solaris spent through Guild travel. Each faction has a passive perk; Fremen harvest double spice. Player faction and balances persist in `plugins/DuneCore/players.yml`; the plugin migrates existing flat files from `plugins/DuneRealms/` on first startup after the rename.

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.example"
version = "1.0.1"
version = "1.0.2"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")

View file

@ -476,17 +476,37 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 0 && args[0].equalsIgnoreCase("admin")) {
if (!sender.hasPermission("dune.admin")) { sender.sendMessage(ChatColor.RED + "Admin only."); return true; }
if (args.length < 2 || !args[1].equalsIgnoreCase("arrakis")) {
sender.sendMessage(ChatColor.YELLOW + "Usage: /dune admin arrakis [player]"); return true;
if (args.length < 2 || (!args[1].equalsIgnoreCase("arrakis") && !args[1].equalsIgnoreCase("sietch") && !args[1].equalsIgnoreCase("solari"))) {
sender.sendMessage(ChatColor.YELLOW + "Usage: /dune admin <arrakis|sietch> [player] | solari <player> <amount>"); return true;
}
if (args[1].equalsIgnoreCase("solari")) {
if (args.length != 4) { sender.sendMessage(ChatColor.YELLOW + "Usage: /dune admin solari <player> <amount>"); return true; }
Player recipient = Bukkit.getPlayerExact(args[2]);
if (recipient == null) { sender.sendMessage(ChatColor.RED + "That player must be online."); return true; }
int amount;
try { amount = Integer.parseInt(args[3]); }
catch (NumberFormatException ex) { sender.sendMessage(ChatColor.RED + "Amount must be a positive whole number."); return true; }
if (amount <= 0 || (long)money.getOrDefault(recipient.getUniqueId(), 0) + amount > Integer.MAX_VALUE) {
sender.sendMessage(ChatColor.RED + "Amount must be positive and the resulting balance cannot exceed the Solaris limit."); return true;
}
money.merge(recipient.getUniqueId(), amount, Integer::sum);
savePlayers();
recipient.sendMessage(ChatColor.GOLD + "An admin added " + amount + " Solaris to your balance. New balance: " + money.get(recipient.getUniqueId()) + ".");
sender.sendMessage(ChatColor.GREEN + "Added " + amount + " Solaris to " + recipient.getName() + ". Balance: " + money.get(recipient.getUniqueId()) + ".");
return true;
}
Player target;
if (args.length >= 3) {
target = Bukkit.getPlayerExact(args[2]);
if (target == null) { sender.sendMessage(ChatColor.RED + "That player is not online."); return true; }
} else if (sender instanceof Player player) target = player;
else { sender.sendMessage(ChatColor.YELLOW + "From console, specify an online player: /dune admin arrakis <player>"); return true; }
else { sender.sendMessage(ChatColor.YELLOW + "From console, specify an online player: /dune admin <arrakis|sietch> <player>"); return true; }
World arrakis = Bukkit.getWorld("arrakis");
if (arrakis == null) { sender.sendMessage(ChatColor.RED + "Arrakis is not loaded on this server. Set DuneTerrain's server.planet to arrakis and restart this backend."); return true; }
if (args[1].equalsIgnoreCase("sietch")) {
teleportToNearestSietch(sender, target, arrakis);
return true;
}
if (target.teleport(arrakis.getSpawnLocation())) {
target.sendMessage(ChatColor.AQUA + "An admin sent you to Arrakis.");
sender.sendMessage(ChatColor.GREEN + "Teleported " + target.getName() + " to Arrakis.");
@ -496,7 +516,7 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
if (!(sender instanceof Player p)) { sender.sendMessage("Run this command in-game."); return true; }
if (args.length == 0) { gui.open(p, "main"); return true; }
if (args[0].equalsIgnoreCase("help")) {
p.sendMessage(ChatColor.GOLD + "/dune choose <fremen|harkonnen|corrino|atreides>, kit, balance, sell, water, travel, politics, exchange, serverjobs, serverjobs accept <id>, job post <spice>, job accept <player>, job finish, guildnpc (admin), admin arrakis [player]"); return true;
p.sendMessage(ChatColor.GOLD + "/dune choose <fremen|harkonnen|corrino|atreides>, kit, balance, sell, water, travel, politics, exchange, serverjobs, serverjobs accept <id>, job post <spice>, job accept <player>, job finish, admin arrakis|sietch [player], admin solari <player> <amount>"); return true;
}
switch (args[0].toLowerCase(Locale.ROOT)) {
case "choose" -> {
@ -539,6 +559,48 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
}
return true;
}
private void teleportToNearestSietch(CommandSender sender, Player target, World arrakis) {
Location origin = target.getWorld().equals(arrakis) ? target.getLocation() : arrakis.getSpawnLocation();
int spacing = 2000;
long cellX = Math.floorDiv(origin.getBlockX(), spacing), cellZ = Math.floorDiv(origin.getBlockZ(), spacing);
List<long[]> candidates = new ArrayList<>();
for (long gx = cellX - 2; gx <= cellX + 2; gx++) for (long gz = cellZ - 2; gz <= cellZ + 2; gz++) {
long h1 = sietchMix64(gx * 0x9E3779B97F4A7C15L ^ gz * 0xC2B2AE3D27D4EB4FL ^ 0x534945544348L);
long h2 = sietchMix64(gz * 0x165667B19E3779F9L ^ gx * 0x85EBCA77C2B2AE63L ^ ~0x534945544348L);
long x = gx * spacing + 8 + Math.floorMod(h1, spacing - 16);
long z = gz * spacing + 8 + Math.floorMod(h2, spacing - 16);
long dx = x - origin.getBlockX(), dz = z - origin.getBlockZ();
candidates.add(new long[]{x, z, dx * dx + dz * dz});
}
candidates.sort(Comparator.comparingLong(candidate -> candidate[2]));
for (long[] candidate : candidates) {
int x = (int)candidate[0], z = (int)candidate[1], chestX = x, chestZ = z - 10;
arrakis.getChunkAt(x >> 4, z >> 4).load(true);
arrakis.getChunkAt(chestX >> 4, chestZ >> 4).load(true);
int estimate = arrakis.getHighestBlockYAt(x + 12, z + 12);
int low = Math.max(arrakis.getMinHeight() + 1, estimate - 80);
int high = Math.min(arrakis.getMaxHeight() - 1, estimate + 5);
for (int y = low; y <= high; y++) {
Block block = arrakis.getBlockAt(chestX, y, chestZ);
if (block.getType() != Material.CHEST || !(block.getState() instanceof org.bukkit.block.Chest chest)
|| !"Personal Sietch Cache".equals(chest.getCustomName())) continue;
Location destination = new Location(arrakis, x + 0.5, y + 14, z + 0.5);
if (target.teleport(destination)) {
target.sendMessage(ChatColor.AQUA + "An admin sent you to a sietch on Arrakis.");
sender.sendMessage(ChatColor.GREEN + "Teleported " + target.getName() + " to a sietch cache at " + x + ", " + z + ".");
} else sender.sendMessage(ChatColor.RED + "Teleport to the sietch failed.");
return;
}
}
sender.sendMessage(ChatColor.RED + "No generated sietch was found nearby. Explore new Arrakis terrain with DuneTerrain enabled, then try again.");
}
private static long sietchMix64(long value) {
value = (value ^ (value >>> 30)) * 0xBF58476D1CE4E5B9L;
value = (value ^ (value >>> 27)) * 0x94D049BB133111EBL;
return value ^ (value >>> 31);
}
void runGuiCommand(Player p, String command) {
String[] args = command.trim().split("\\s+");
if (args.length == 0 || args[0].isEmpty()) return;

View file

@ -1,5 +1,5 @@
name: DuneCore
version: 1.0.1
version: 1.0.2
main: com.example.dunerealms.DuneCore
api-version: '1.21'
softdepend: [DuneTerrain]

View file

@ -10,7 +10,7 @@ Build the plugin from this directory with Java 21 and Gradle 8.14 or newer:
gradle clean build
```
Copy `build/libs/DuneTerrain-1.0.2.jar` into the Paper server's `plugins/` directory. Set `server.planet` in `plugins/DuneTerrain/config.yml` separately on each backend, then restart.
Copy `build/libs/DuneTerrain-1.0.3.jar` into the Paper server's `plugins/` directory. Set `server.planet` in `plugins/DuneTerrain/config.yml` separately on each backend, then restart.
Valid values are `arrakis`, `giedi_prime`, `kaitain`, `caladan`, and `sigma_draconis_iv`. All five planet profiles are present in each server's config; change `server.planet` to select the world that backend creates. The generated world is named after the selected planet. Adjust its `planets.<planet>` settings for terrain, biome, surface, water, vegetation, ores, and spawn coordinates.
@ -29,6 +29,6 @@ For another primary planet, replace both `arrakis` values with that planet name.
The generator applies to newly generated chunks. Existing chunks are never replaced by a config change. If the selected planet world already exists with non-Arrakis terrain or rivers, stop the server, back up and move that world's folder out of the server directory, then restart to create it with DuneTerrain. DuneTerrain registers the generator at startup and creates a separate planet world only after Paper has finished loading, if needed.
Arrakis uses the Desert biome throughout, has no vanilla vegetation, and places one persistent-leaf oasis tree and one underground sietch about every 300 blocks in each direction. Random spice patches generate about 35% of 600-by-600-block regions; each patch has roughly 5,000 Solaris in deposits at the default 15 Solaris per spice. Adjust `spice-deposits.patches` for patch frequency, size, or value, and `planets.arrakis.oasis-trees.spacing` to change the tree interval.
Arrakis uses the Desert biome throughout and has no vanilla vegetation. Sparse persistent-leaf oasis trees remain about 300 blocks apart. A larger underground cave sietch generates about every 2,000 blocks; it has connected sleeping and kitchen chambers, a concealed entry, a waterfall descent into a bottom reservoir, and a personal cache per player containing at least 250 tagged spice, enchanted gold armor, planks, and bread. Sand-covered darkstone islands generate about every 750 blocks. Set `sietches.spacing` and `planets.arrakis.darkstone-islands.spacing` to adjust those intervals. Random spice patches generate about 35% of 600-by-600-block regions; each patch has roughly 5,000 Solaris in deposits at the default 15 Solaris per spice. Adjust `spice-deposits.patches` for patch frequency, size, or value.
DuneCore sends new players who have not chosen a faction from Paper's default `world` to the local planet spawn, so they arrive in the world generated by DuneTerrain.

View file

@ -1,7 +1,7 @@
plugins { java }
group = "com.example"
version = "1.0.2"
version = "1.0.3"
repositories {
mavenCentral()

View file

@ -2,9 +2,22 @@ package com.example.duneterrain;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.type.Bed;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Villager;
import org.bukkit.event.block.Action;
import org.bukkit.generator.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.event.EventHandler;
@ -16,6 +29,95 @@ import java.util.*;
public final class DuneTerrain extends JavaPlugin implements Listener {
private static final String[] PLANETS = {"arrakis", "giedi_prime", "kaitain", "caladan", "sigma_draconis_iv"};
private NamespacedKey guildKey;
private NamespacedKey sietchLootIdKey;
private final Map<UUID, PersonalLoot> openSietchLoot = new HashMap<>();
private record PersonalLoot(Inventory inventory, String id) {}
@EventHandler public void onSietchChestOpen(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null) return;
if (event.getHand() != org.bukkit.inventory.EquipmentSlot.HAND) return;
BlockState state = event.getClickedBlock().getState();
if (!(state instanceof Chest chest)) return;
String id = chest.getPersistentDataContainer().get(sietchLootIdKey, PersistentDataType.STRING);
if (id == null) return;
event.setCancelled(true);
org.bukkit.entity.Player player = event.getPlayer();
NamespacedKey claimedKey = new NamespacedKey(this, "sietch_claim_" + id);
if (player.getPersistentDataContainer().has(claimedKey, PersistentDataType.BYTE)) {
player.sendMessage(ChatColor.YELLOW + "You have already claimed this sietch cache.");
return;
}
Inventory inventory = Bukkit.createInventory(null, 27, ChatColor.DARK_GRAY + "Sietch Cache");
addLoot(inventory, spiceItem(64)); addLoot(inventory, spiceItem(64)); addLoot(inventory, spiceItem(64)); addLoot(inventory, spiceItem(58));
addLoot(inventory, enchantedGold(Material.GOLDEN_HELMET));
addLoot(inventory, enchantedGold(Material.GOLDEN_CHESTPLATE));
addLoot(inventory, enchantedGold(Material.GOLDEN_LEGGINGS));
addLoot(inventory, enchantedGold(Material.GOLDEN_BOOTS));
addLoot(inventory, new ItemStack(Material.OAK_PLANKS, 32));
addLoot(inventory, new ItemStack(Material.BREAD, 16));
openSietchLoot.put(player.getUniqueId(), new PersonalLoot(inventory, id));
player.openInventory(inventory);
player.sendMessage(ChatColor.GOLD + "This personal cache contains supplies for you.");
}
@EventHandler public void onSietchLootClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof org.bukkit.entity.Player player)) return;
PersonalLoot loot = openSietchLoot.get(player.getUniqueId());
if (loot == null || event.getView().getTopInventory() != loot.inventory()) return;
if (event.getClickedInventory() != loot.inventory()) return;
event.setCancelled(true);
ItemStack item = event.getCurrentItem();
if (item == null || item.getType().isAir()) return;
Map<Integer, ItemStack> leftovers = player.getInventory().addItem(item.clone());
if (leftovers.isEmpty()) loot.inventory().setItem(event.getSlot(), null);
else {
loot.inventory().setItem(event.getSlot(), leftovers.values().iterator().next());
player.sendMessage(ChatColor.RED + "Your inventory only had room for part of that stack.");
}
}
@EventHandler public void onSietchLootDrag(InventoryDragEvent event) {
if (!(event.getWhoClicked() instanceof org.bukkit.entity.Player player)) return;
PersonalLoot loot = openSietchLoot.get(player.getUniqueId());
if (loot != null && event.getView().getTopInventory() == loot.inventory()) event.setCancelled(true);
}
@EventHandler public void onSietchLootClose(InventoryCloseEvent event) {
if (!(event.getPlayer() instanceof org.bukkit.entity.Player player)) return;
PersonalLoot loot = openSietchLoot.get(player.getUniqueId());
if (loot == null || event.getView().getTopInventory() != loot.inventory()) return;
openSietchLoot.remove(player.getUniqueId());
for (ItemStack item : loot.inventory().getContents()) if (item != null && !item.getType().isAir()) {
Map<Integer, ItemStack> leftovers = player.getInventory().addItem(item);
leftovers.values().forEach(left -> player.getWorld().dropItemNaturally(player.getLocation(), left));
}
player.getPersistentDataContainer().set(new NamespacedKey(this, "sietch_claim_" + loot.id()), PersistentDataType.BYTE, (byte) 1);
}
private static void addLoot(Inventory inventory, ItemStack item) {
for (int slot = 0; slot < inventory.getSize(); slot++) if (inventory.getItem(slot) == null) {
inventory.setItem(slot, item);
return;
}
}
private static ItemStack spiceItem(int amount) {
ItemStack item = new ItemStack(Material.ORANGE_DYE, amount);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.GOLD + "Melange Spice");
meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms", "item"), PersistentDataType.STRING, "spice");
item.setItemMeta(meta);
return item;
}
private static ItemStack enchantedGold(Material material) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
meta.addEnchant(Enchantment.PROTECTION, 2, true);
meta.addEnchant(Enchantment.UNBREAKING, 2, true);
item.setItemMeta(meta);
return item;
}
@Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
String planet = id == null || id.isBlank()
@ -49,6 +151,7 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
saveDefaultConfig();
getServer().getPluginManager().registerEvents(this, this);
guildKey = new NamespacedKey("dunerealms", "guild");
sietchLootIdKey = new NamespacedKey(this, "sietch-loot-id");
String planet = getConfig().getString("server.planet", "arrakis").toLowerCase(Locale.ROOT);
if (!Arrays.asList(PLANETS).contains(planet)) {
getLogger().severe("Invalid server.planet '" + planet + "'. Choose one of: " + String.join(", ", PLANETS));
@ -137,7 +240,7 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
private final String planet;
PlanetChunkGenerator(DuneTerrain plugin, String planet) { this.plugin = plugin; this.planet = planet; }
@Override public List<BlockPopulator> getDefaultPopulators(World world) {
return planet.equals("arrakis") ? List.of(new SietchPopulator()) : List.of();
return planet.equals("arrakis") ? List.of(new SietchPopulator(plugin)) : List.of();
}
@Override public void generateNoise(WorldInfo world, Random random, int chunkX, int chunkZ, ChunkData data) {
String path = "planets." + planet + ".";
@ -182,6 +285,7 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
}
if (planet.equals("arrakis")) placeOasisTree(data, chunkX, chunkZ, heights, minY, maxY);
if (planet.equals("arrakis")) {
placeDarkstoneIsland(data, chunkX, chunkZ, heights, minY, maxY);
placeSpiceDeposits(data, heights, random, minY, maxY);
placeRandomSpicePatch(data, chunkX, chunkZ, heights);
}
@ -223,6 +327,43 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
if (Math.floorDiv(x, spacing) != cellX || Math.floorDiv(z, spacing) != cellZ) return new long[]{Long.MIN_VALUE, Long.MIN_VALUE};
return new long[]{x, z};
}
private void placeDarkstoneIsland(ChunkData data, int chunkX, int chunkZ, int[][] heights, int minY, int maxY) {
String path = "planets.arrakis.darkstone-islands.";
if (!plugin.getConfig().getBoolean(path + "enabled", true)) return;
int spacing = Math.max(128, plugin.getConfig().getInt(path + "spacing", 750));
int minRadius = Math.max(3, plugin.getConfig().getInt(path + "min-radius", 5));
int maxRadius = Math.max(minRadius, plugin.getConfig().getInt(path + "max-radius", 9));
int maxRise = Math.max(1, plugin.getConfig().getInt(path + "max-height", 4));
int worldMinX = chunkX * 16, worldMinZ = chunkZ * 16;
int firstCellX = Math.floorDiv(worldMinX - maxRadius, spacing), lastCellX = Math.floorDiv(worldMinX + 15 + maxRadius, spacing);
int firstCellZ = Math.floorDiv(worldMinZ - maxRadius, spacing), lastCellZ = Math.floorDiv(worldMinZ + 15 + maxRadius, spacing);
long salt = 0x4441524B49534C41L;
for (int cellX = firstCellX; cellX <= lastCellX; cellX++) for (int cellZ = firstCellZ; cellZ <= lastCellZ; cellZ++) {
long seed = mix64((long) cellX * 0x9E3779B97F4A7C15L ^ (long) cellZ * 0xC2B2AE3D27D4EB4FL ^ salt);
long centerX = (long) cellX * spacing + Math.floorMod(mix64(seed ^ 0x165667B19E3779F9L), spacing);
long centerZ = (long) cellZ * spacing + Math.floorMod(mix64(seed ^ 0x85EBCA77C2B2AE63L), spacing);
int radius = minRadius + (int) Math.floorMod(seed >>> 1, maxRadius - minRadius + 1L);
for (int lx = 0; lx < 16; lx++) for (int lz = 0; lz < 16; lz++) {
long gx = (long) worldMinX + lx, gz = (long) worldMinZ + lz;
long dx = gx - centerX, dz = gz - centerZ;
long rough = mix64(gx * 0x9E3779B97F4A7C15L ^ gz * 0xC2B2AE3D27D4EB4FL ^ seed);
double edge = radius + (((rough >>> 11) * 0x1.0p-53) - 0.5) * 2.8;
double distance = Math.sqrt(dx * dx + dz * dz);
if (distance > edge) continue;
int baseY = heights[lx][lz];
if (baseY + maxRise + 2 >= maxY || baseY <= minY + 1) continue;
double fullness = Math.max(0.0, 1.0 - distance / (radius + 1.0));
int rise = Math.max(1, Math.min(maxRise, 1 + (int) Math.round(fullness * (maxRise - 1))));
int rockHeight = Math.max(1, rise - 1);
Material[] darkRock = {Material.BLACKSTONE, Material.BASALT, Material.TUFF, Material.COBBLED_DEEPSLATE};
for (int dy = 1; dy <= rockHeight; dy++) {
int hashIndex = (int) Math.floorMod(mix64(rough + dy * 0x9E3779B97F4A7C15L), darkRock.length);
data.setBlock(lx, baseY + dy, lz, darkRock[hashIndex]);
}
data.setBlock(lx, baseY + rise, lz, Material.SAND);
}
}
}
private Material configuredMaterial(String path, Material fallback) {
String name = plugin.getConfig().getString(path, fallback.name());
Material material = Material.matchMaterial(name == null ? "" : name);
@ -325,9 +466,12 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
}
private static final class SietchPopulator extends BlockPopulator {
private final DuneTerrain plugin;
private SietchPopulator(DuneTerrain plugin) { this.plugin = plugin; }
@Override public void populate(WorldInfo world, Random random, int cx, int cz, LimitedRegion region) {
if (!world.getName().equalsIgnoreCase("arrakis")) return;
int spacing = 300;
if (!plugin.getConfig().getBoolean("sietches.enabled", true)) return;
int spacing = Math.max(256, plugin.getConfig().getInt("sietches.spacing", 2000));
int centerX = cx * 16 + 8, centerZ = cz * 16 + 8;
long cellX = Math.floorDiv(centerX, spacing), cellZ = Math.floorDiv(centerZ, spacing);
long h1 = mix64(cellX * 0x9E3779B97F4A7C15L ^ cellZ * 0xC2B2AE3D27D4EB4FL ^ 0x534945544348L);
@ -337,22 +481,114 @@ public final class DuneTerrain extends JavaPlugin implements Listener {
if (Math.floorDiv(anchorX, 16) != cx || Math.floorDiv(anchorZ, 16) != cz) return;
int x = (int) anchorX, z = (int) anchorZ;
int y = region.getHighestBlockYAt(x, z);
if (y < 65 || y > world.getMaxHeight() - 12 || y - 12 < world.getMinHeight()) return;
for (int dx = -4; dx <= 4; dx++) for (int dz = -4; dz <= 4; dz++) for (int dy = -10; dy <= 3; dy++) {
int ax = x + dx, az = z + dz, ay = y + dy;
if (!region.isInRegion(ax, ay, az)) continue;
boolean cave = dy >= -9 && dy <= -5 && Math.abs(dx) <= 3 && Math.abs(dz) <= 3;
if (cave) region.setType(ax, ay, az, dy <= -8 ? Material.WATER : Material.AIR);
else if (dy >= 0 && dy <= 3 && Math.abs(dx) <= 3 && Math.abs(dz) <= 3) {
boolean wall = Math.abs(dx) == 3 || Math.abs(dz) == 3 || dy == 3;
region.setType(ax, ay, az, wall ? Material.SANDSTONE : Material.AIR);
}
if (y < world.getMinHeight() + 40 || y > world.getMaxHeight() - 4 || y - 36 < world.getMinHeight()) return;
// Hub with three side chambers and a lower reservoir, all within the populator's chunk buffer.
int hy = y - 11;
carveRoom(region, x, hy, z, 5, 3, 5);
carveTunnel(region, x, hy - 2, z - 3, x - 7, hy - 6, z - 2);
carveRoom(region, x - 9, hy - 6, z - 2, 4, 2, 4);
carveTunnel(region, x, hy - 2, z + 3, x + 7, hy - 6, z + 2);
carveRoom(region, x + 9, hy - 6, z + 2, 4, 2, 4);
carveTunnel(region, x, hy - 2, z - 3, x, hy - 10, z - 9);
carveRoom(region, x, hy - 12, z - 10, 4, 2, 4);
carveTunnel(region, x, hy - 3, z + 3, x, hy - 18, z + 7);
carveRoom(region, x, hy - 21, z + 8, 5, 3, 5);
// A discreet surface entry descends into the central cavern; no ladder is used.
for (int step = 0; step <= 10; step++) {
int sx = x, sz = z - step / 3, sy = y - 1 - step;
carveRoom(region, sx, sy, sz, 1, 1, 1);
}
for (int dy = -7; dy <= 2; dy++) {
if (region.isInRegion(x, y + dy, z)) region.setType(x, y + dy, z, Material.AIR);
if (region.isInRegion(x + 1, y + dy, z)) region.setType(x + 1, y + dy, z, Material.LADDER);
for (int dx = -2; dx <= 2; dx++) for (int dz = -2; dz <= 2; dz++) {
if (Math.abs(dx) + Math.abs(dz) > 3) continue;
set(region, x + dx, y, z + dz, (Math.abs(dx) == 2 || Math.abs(dz) == 2) ? Material.CUT_SANDSTONE : Material.AIR);
}
if (region.isInRegion(x, y + 4, z)) region.setType(x, y + 4, z, Material.ORANGE_BANNER);
// A narrow waterfall drops from the hub into the deep reservoir.
for (int dy = -4; dy >= -20; dy--) {
set(region, x + 2, hy + dy, z + 2, Material.WATER);
set(region, x + 1, hy + dy, z + 2, Material.STONE);
set(region, x + 3, hy + dy, z + 2, Material.STONE);
set(region, x + 2, hy + dy, z + 1, Material.STONE);
set(region, x + 2, hy + dy, z + 3, Material.STONE);
}
for (int dx = -2; dx <= 2; dx++) for (int dz = -2; dz <= 2; dz++)
set(region, x + dx, hy - 23, z + dz, Material.WATER);
furnishSleepingHall(region, x - 9, hy - 6, z - 2);
furnishKitchen(region, x + 9, hy - 6, z + 2);
placePersonalChest(region, x, hy - 14, z - 10, cellX, cellZ);
for (int[] lamp : new int[][]{{0,-1,0},{-11,-5,-2},{11,-5,2},{0,-11,-11}})
set(region, x + lamp[0], hy + lamp[1], z + lamp[2], Material.TORCH);
}
private static void carveRoom(LimitedRegion region, int cx, int cy, int cz, int rx, int ry, int rz) {
for (int dx = -rx; dx <= rx; dx++) for (int dy = -ry; dy <= ry; dy++) for (int dz = -rz; dz <= rz; dz++) {
double outer = dx * dx / (double)(rx * rx) + dy * dy / (double)(ry * ry) + dz * dz / (double)(rz * rz);
if (outer > 1.15) continue;
int x = cx + dx, y = cy + dy, z = cz + dz;
if (outer >= 0.58) {
long variation = mix64((long)x * 341873128712L ^ (long)y * 132897987541L ^ z);
Material wall = switch ((int)Math.floorMod(variation, 10)) {
case 0, 1 -> Material.TUFF;
case 2 -> Material.ANDESITE;
case 3 -> Material.COBBLED_DEEPSLATE;
case 4 -> Material.COBBLESTONE;
case 5 -> Material.MOSSY_COBBLESTONE;
default -> Material.STONE;
};
set(region, x, y, z, wall);
} else set(region, x, y, z, Material.AIR);
}
}
private static void carveTunnel(LimitedRegion region, double ax, double ay, double az, double bx, double by, double bz) {
int steps = (int)Math.ceil(Math.sqrt((bx-ax)*(bx-ax) + (by-ay)*(by-ay) + (bz-az)*(bz-az)) * 1.5);
for (int i = 0; i <= steps; i++) {
double t = i / (double)Math.max(1, steps);
int cx = (int)Math.round(ax + (bx-ax)*t), cy = (int)Math.round(ay + (by-ay)*t), cz = (int)Math.round(az + (bz-az)*t);
for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <= 1; dy++) for (int dz = -1; dz <= 1; dz++)
if (dx*dx + dy*dy + dz*dz <= 2) set(region, cx+dx, cy+dy, cz+dz, Material.AIR);
}
}
private static void furnishSleepingHall(LimitedRegion r, int x, int y, int z) {
for (int i = -1; i <= 1; i++) {
set(r, x+i, y-1, z, Material.POLISHED_ANDESITE);
set(r, x+i, y, z, Material.RED_CARPET);
set(r, x+i, y+1, z, Material.AIR);
}
set(r, x-1, y, z, Material.WHITE_CARPET);
set(r, x+1, y, z, Material.WHITE_CARPET);
set(r, x-2, y-1, z+2, Material.BARREL);
}
private static void furnishKitchen(LimitedRegion r, int x, int y, int z) {
set(r, x-2, y-1, z, Material.STONE_BRICKS);
set(r, x-2, y, z, Material.FURNACE);
set(r, x-1, y-1, z, Material.STONE_BRICKS);
set(r, x-1, y, z, Material.SMOKER);
set(r, x, y-1, z, Material.STONE_BRICKS);
set(r, x, y, z, Material.CRAFTING_TABLE);
set(r, x+2, y-1, z+1, Material.BARREL);
set(r, x+2, y, z+1, Material.CAULDRON);
}
private void placePersonalChest(LimitedRegion r, int x, int y, int z, long cellX, long cellZ) {
set(r, x, y-1, z, Material.CHISELED_STONE_BRICKS);
set(r, x, y, z, Material.CHEST);
BlockState state = r.getBlockState(x, y, z);
if (state instanceof Chest chest) {
String id = Long.toUnsignedString(mix64(cellX * 0x9E3779B97F4A7C15L ^ cellZ * 0xC2B2AE3D27D4EB4FL ^ 0x534945544348L), 16);
chest.setCustomName("Personal Sietch Cache");
chest.getPersistentDataContainer().set(plugin.sietchLootIdKey, PersistentDataType.STRING, id);
chest.update(true, false);
}
}
private static void set(LimitedRegion region, int x, int y, int z, Material material) {
if (region.isInRegion(x, y, z)) region.setType(x, y, z, material);
}
}
}

View file

@ -7,6 +7,10 @@ server:
guild-npc:
enabled: true
sietches:
enabled: true
spacing: 2000
spice-deposits:
per-chunk: 2
patches:
@ -28,6 +32,7 @@ planets:
water: {level: 63, swamp-pools: false, coverage: 0.18}
vegetation: {trees: false, tree-chance: 0.0, flowers-per-chunk: 0}
oasis-trees: {enabled: true, spacing: 300, trunk-height: 7}
darkstone-islands: {enabled: true, spacing: 750, min-radius: 5, max-radius: 9, max-height: 4}
ores: {min-y: -48, max-y: 48, vein-size: 5, COAL_ORE: 2, IRON_ORE: 2, COPPER_ORE: 1}
giedi_prime:
enabled: true

View file

@ -1,5 +1,5 @@
name: DuneTerrain
version: 1.0.2
version: 1.0.3
main: com.example.duneterrain.DuneTerrain
api-version: '1.21'
load: STARTUP