diff --git a/DuneRealms-minecraft-only/README.md b/DuneRealms-minecraft-only/README.md index c9f59f6d..f0be010c 100644 --- a/DuneRealms-minecraft-only/README.md +++ b/DuneRealms-minecraft-only/README.md @@ -1,6 +1,6 @@ # DuneCore for Paper 1.21.4 -Requires Java 21 and Gradle 8+. Run `gradle build` and copy `build/libs/DuneCore-1.0.0.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.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`. Commands: `/dune choose fremen|harkonnen|corrino|atreides`, `/dune kit`, `/dune balance`, `/dune sell`, `/dune travel`, `/dune guildnpc` (OP), `/dune givespice` (OP). @@ -14,7 +14,7 @@ Admins with `dune.admin` can force a local teleport to the loaded Arrakis world ## Sandworms (Shai-Hulud) -Hostile, oversized husks representing sandworms spawn on sandy surfaces near players **only on Arrakis**, roughly every 10 seconds with a configurable chance. They target players, have 500 health and 30 base melee attack damage (Warden-level values), and play a Warden roar when emerging. They cannot teleport to other worlds. Settings are under `sandworms` in `config.yml`. The worm is represented by a scaled vanilla husk; a true animated worm model would require a resource pack or model plugin. +Hostile, oversized husks representing sandworms spawn on sandy surfaces near players **only on Arrakis**, at most once per hour serverwide by default. The successful spawn time is saved in the plugin config, so a restart does not reset the cooldown. They target players, have 500 health and 30 base melee attack damage (Warden-level values), and play a Warden roar when emerging. They cannot teleport to other worlds. Settings are under `sandworms` in `config.yml`. The worm is represented by a scaled vanilla husk; a true animated worm model would require a resource pack or model plugin. ## Spice contracts and sandworm blooms - On Arrakis, defeating a sandworm generates a broad patch of suspicious-sand spice deposits with a target base harvest value of 100,000 Solaris (actual value depends on available sandy terrain and faction bonuses). @@ -79,6 +79,8 @@ Each newly issued leather stillsuit piece receives a distinctive vanilla smithin Ordos starts and respawns on its own generated planet `sigma_draconis_iv` (Sigma Draconis IV). Its dark, snowy terrain profile is configured by DuneTerrain. The Spacing Guild remains a non-playable faction and does not receive its own kit through normal gameplay. Existing armor is not automatically upgraded; issue a fresh kit. +Wearing a complete Ordos stillsuit and using an ender pearl activates Shadow Step: the player and armor are invisible for five seconds. The armor is returned after the effect, on logout, or when the plugin shuts down. + The trims are Minecraft's built-in vanilla patterns, not custom resource-pack models. This source has not been compiled or tested on Paper. ## Proxy mode diff --git a/DuneRealms-minecraft-only/build.gradle.kts b/DuneRealms-minecraft-only/build.gradle.kts index 9d6f7f1d..45384fa3 100644 --- a/DuneRealms-minecraft-only/build.gradle.kts +++ b/DuneRealms-minecraft-only/build.gradle.kts @@ -1,6 +1,6 @@ plugins { java } group = "com.example" -version = "1.0.0" +version = "1.0.1" repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") } dependencies { compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") diff --git a/DuneRealms-minecraft-only/src/main/java/com/example/dunerealms/DuneCore.java b/DuneRealms-minecraft-only/src/main/java/com/example/dunerealms/DuneCore.java index ba9cd7c8..82b31742 100644 --- a/DuneRealms-minecraft-only/src/main/java/com/example/dunerealms/DuneCore.java +++ b/DuneRealms-minecraft-only/src/main/java/com/example/dunerealms/DuneCore.java @@ -31,6 +31,7 @@ import org.bukkit.inventory.*; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; import org.bukkit.potion.*; import java.io.File; import java.io.IOException; @@ -47,6 +48,8 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu private File dataFile; private final Map jobs = new HashMap<>(); private final Map activeWorkers = new HashMap<>(); + private final Map ordosCloakedArmor = new HashMap<>(); + private final Map ordosRevealTasks = new HashMap<>(); private record Job(UUID owner, int quota, int harvested) {} private YamlConfiguration data; private ServerJobs serverJobs; @@ -95,7 +98,10 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu Bukkit.getScheduler().runTaskTimer(this, this::spawnSandworms, 200L, 200L); getLogger().info("DuneCore enabled. Gameplay, faction travel, and Arrakis sandworms ready."); } - @Override public void onDisable() { if(serverJobs!=null)serverJobs.save(); savePlayers(); } + @Override public void onDisable() { + for (UUID playerId : new ArrayList<>(ordosCloakedArmor.keySet())) restoreOrdosArmor(playerId); + if(serverJobs!=null)serverJobs.save(); savePlayers(); + } private void savePlayers() { if(sharedDatabase!=null){ for(Player player:Bukkit.getOnlinePlayers())try{sharedDatabase.savePlayer(player,selected,money);} @@ -321,10 +327,38 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu if(e.getAction()!=Action.RIGHT_CLICK_AIR && e.getAction()!=Action.RIGHT_CLICK_BLOCK)return; ItemStack held=e.getItem(); if(held==null||held.getType()!=Material.ENDER_PEARL)return; - // Trigger on activation; vanilla pearl throw remains intact. + UUID id=p.getUniqueId(); + if (!ordosCloakedArmor.containsKey(id)) { + ItemStack[] armor=p.getInventory().getArmorContents(); + ItemStack[] saved=new ItemStack[armor.length]; + for (int i=0;irestoreOrdosArmor(id),100L)); p.sendMessage(ChatColor.DARK_GREEN+"Shadow Step: invisible for five seconds."); } + private void restoreOrdosArmor(UUID id) { + BukkitTask task=ordosRevealTasks.remove(id); + if(task!=null)task.cancel(); + ItemStack[] saved=ordosCloakedArmor.remove(id); + Player player=Bukkit.getPlayer(id); + if(saved==null||player==null)return; + ItemStack[] current=player.getInventory().getArmorContents(); + for(int i=0;i leftovers=player.getInventory().addItem(piece); + for(ItemStack leftover:leftovers.values())player.getWorld().dropItemNaturally(player.getLocation(),leftover); + } + } + player.getInventory().setArmorContents(current); + } private boolean wearingStillsuit(Player p) { for (ItemStack armor : p.getInventory().getArmorContents()) if (!is(armor, "stillsuit")) return false; return true; @@ -539,6 +573,7 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu catch(Exception ex){getLogger().severe("Shared player load failed: "+ex.getMessage());e.getPlayer().kickPlayer("Your network profile could not be loaded.");} } @EventHandler public void onNetworkQuit(org.bukkit.event.player.PlayerQuitEvent e) { + restoreOrdosArmor(e.getPlayer().getUniqueId()); if(sharedDatabase!=null)try{sharedDatabase.savePlayer(e.getPlayer(),selected,money);} catch(Exception ex){getLogger().severe("Shared player save failed: "+ex.getMessage());} } @@ -556,7 +591,7 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu Bukkit.getScheduler().runTask(this, () -> giveMenuItem(p)); if (!selected.containsKey(p.getUniqueId()) || selected.get(p.getUniqueId()).isEmpty()) { p.sendMessage(ChatColor.GOLD + "Choose your faction with /dune choose ."); - } + }); Bukkit.getScheduler().runTask(this, () -> { World localWorld = Bukkit.getWorld(localPlanet()); if (p.isOnline() && localWorld != null && p.getWorld().getName().equalsIgnoreCase("world")) { @@ -669,6 +704,8 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu } private void spawnSandworms() { if (!getConfig().getBoolean("sandworms.enabled", true)) return; + long now = System.currentTimeMillis(); + if (now < getConfig().getLong("sandworms.next-spawn-at", 0L)) return; World world = Bukkit.getWorld("arrakis"); if (world == null) return; int max = Math.max(0, getConfig().getInt("sandworms.max-per-world", 12)); @@ -703,7 +740,10 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu }); world.spawnParticle(Particle.CLOUD, location, 45, 2, 1, 2, 0.1); world.playSound(location, Sound.ENTITY_WARDEN_ROAR, 2f, 0.6f); - count++; + long interval = Math.max(60L, getConfig().getLong("sandworms.spawn-interval-seconds", 3600L)); + getConfig().set("sandworms.next-spawn-at", now + interval * 1000L); + saveConfig(); + return; } } @EventHandler public void onWormTarget(EntityTargetLivingEntityEvent e) { diff --git a/DuneRealms-minecraft-only/src/main/resources/config.yml b/DuneRealms-minecraft-only/src/main/resources/config.yml index b3296190..fbc10a90 100644 --- a/DuneRealms-minecraft-only/src/main/resources/config.yml +++ b/DuneRealms-minecraft-only/src/main/resources/config.yml @@ -2,7 +2,7 @@ spice-sell-price: 15 travel-price: 100 spice-respawn-seconds: 120 -# Sandworms spawn near players on Arrakis only. +# Sandworms spawn near players on Arrakis only, at most once per interval serverwide. # Damage 30 and health 500 approximate Warden-level threat. sandworms: enabled: true @@ -10,6 +10,7 @@ sandworms: attack-damage: 30.0 max-per-world: 12 spawn-chance: 0.35 + spawn-interval-seconds: 3600 # Arrakis solar exposure: 5 minutes of uninterrupted direct sunlight without a full stillsuit. arrakis-sun: diff --git a/DuneRealms-minecraft-only/src/main/resources/plugin.yml b/DuneRealms-minecraft-only/src/main/resources/plugin.yml index 16851893..88a68da2 100644 --- a/DuneRealms-minecraft-only/src/main/resources/plugin.yml +++ b/DuneRealms-minecraft-only/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: DuneCore -version: 1.0.0 +version: 1.0.1 main: com.example.dunerealms.DuneCore api-version: '1.21' softdepend: [DuneTerrain] diff --git a/DuneTerrain/README.md b/DuneTerrain/README.md index 996e10d3..61a267cd 100644 --- a/DuneTerrain/README.md +++ b/DuneTerrain/README.md @@ -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. Adjust `planets.arrakis.oasis-trees.spacing` to change the tree interval. +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. 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. diff --git a/DuneTerrain/src/main/java/com/example/duneterrain/DuneTerrain.java b/DuneTerrain/src/main/java/com/example/duneterrain/DuneTerrain.java index 4c1179e2..71979747 100644 --- a/DuneTerrain/src/main/java/com/example/duneterrain/DuneTerrain.java +++ b/DuneTerrain/src/main/java/com/example/duneterrain/DuneTerrain.java @@ -181,7 +181,10 @@ public final class DuneTerrain extends JavaPlugin implements Listener { } } if (planet.equals("arrakis")) placeOasisTree(data, chunkX, chunkZ, heights, minY, maxY); - if (planet.equals("arrakis")) placeSpiceDeposits(data, heights, random, minY, maxY); + if (planet.equals("arrakis")) { + placeSpiceDeposits(data, heights, random, minY, maxY); + placeRandomSpicePatch(data, chunkX, chunkZ, heights); + } placeOres(data, random, path, minY, maxY); } @Override public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) { @@ -232,6 +235,39 @@ public final class DuneTerrain extends JavaPlugin implements Listener { if (y + 1 < maxY && y > minY) data.setBlock(x, y, z, Material.SUSPICIOUS_SAND); } } + private void placeRandomSpicePatch(ChunkData data, int chunkX, int chunkZ, int[][] heights) { + String path = "spice-deposits.patches."; + if (!plugin.getConfig().getBoolean(path + "enabled", true)) return; + int spacing = Math.max(128, plugin.getConfig().getInt(path + "region-spacing", 600)); + int radius = Math.max(2, plugin.getConfig().getInt(path + "radius", 12)); + int targetValue = Math.max(1, plugin.getConfig().getInt(path + "target-value", 5000)); + int unitPrice = Math.max(1, plugin.getConfig().getInt(path + "unit-price", 15)); + double density = Math.min(1.0, Math.ceil(targetValue / (double) unitPrice) / (Math.PI * radius * radius)); + double chance = Math.max(0, Math.min(1, plugin.getConfig().getDouble(path + "chance-per-region", 0.35))); + int worldMinX = chunkX * 16, worldMinZ = chunkZ * 16; + int firstCellX = Math.floorDiv(worldMinX - radius, spacing), lastCellX = Math.floorDiv(worldMinX + 15 + radius, spacing); + int firstCellZ = Math.floorDiv(worldMinZ - radius, spacing), lastCellZ = Math.floorDiv(worldMinZ + 15 + radius, spacing); + long salt = 0x5350494345504154L; + for (int cellX = firstCellX; cellX <= lastCellX; cellX++) for (int cellZ = firstCellZ; cellZ <= lastCellZ; cellZ++) { + long cellSeed = mix64((long) cellX * 0x9E3779B97F4A7C15L ^ (long) cellZ * 0xC2B2AE3D27D4EB4FL ^ salt); + if (hashUnit(cellSeed) >= chance) continue; + long offsetX = Math.floorMod(mix64(cellSeed ^ 0x165667B19E3779F9L), spacing - radius * 2L); + long offsetZ = Math.floorMod(mix64(cellSeed ^ 0x85EBCA77C2B2AE63L), spacing - radius * 2L); + long centerX = (long) cellX * spacing + radius + offsetX; + long centerZ = (long) cellZ * spacing + radius + offsetZ; + for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) { + long gx = (long) worldMinX + x, gz = (long) worldMinZ + z; + long dx = gx - centerX, dz = gz - centerZ; + if (dx * dx + dz * dz > (long) radius * radius) continue; + long blockSeed = mix64(gx * 0x9E3779B97F4A7C15L ^ gz * 0xC2B2AE3D27D4EB4FL ^ salt); + if (hashUnit(blockSeed) >= density) continue; + int y = heights[x][z]; + if (data.getType(x, y, z) == Material.SAND || data.getType(x, y, z) == Material.RED_SAND) + data.setBlock(x, y, z, Material.SUSPICIOUS_SAND); + } + } + } + private static double hashUnit(long hash) { return (hash >>> 11) * 0x1.0p-53; } private void placeOres(ChunkData data, Random random, String path, int minWorldY, int maxWorldY) { org.bukkit.configuration.ConfigurationSection ores = plugin.getConfig().getConfigurationSection(path + "ores"); if (ores == null) return; @@ -296,10 +332,10 @@ public final class DuneTerrain extends JavaPlugin implements Listener { long cellX = Math.floorDiv(centerX, spacing), cellZ = Math.floorDiv(centerZ, spacing); long h1 = mix64(cellX * 0x9E3779B97F4A7C15L ^ cellZ * 0xC2B2AE3D27D4EB4FL ^ 0x534945544348L); long h2 = mix64(cellZ * 0x165667B19E3779F9L ^ cellX * 0x85EBCA77C2B2AE63L ^ ~0x534945544348L); - long ax = cellX * spacing + 8 + Math.floorMod(h1, spacing - 16); - long az = cellZ * spacing + 8 + Math.floorMod(h2, spacing - 16); - if (Math.floorDiv(ax, 16) != cx || Math.floorDiv(az, 16) != cz) return; - int x = (int) ax, z = (int) az; + long anchorX = cellX * spacing + 8 + Math.floorMod(h1, spacing - 16); + long anchorZ = cellZ * spacing + 8 + Math.floorMod(h2, spacing - 16); + 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++) { diff --git a/DuneTerrain/src/main/resources/config.yml b/DuneTerrain/src/main/resources/config.yml index 0ba22dd7..f8ed8562 100644 --- a/DuneTerrain/src/main/resources/config.yml +++ b/DuneTerrain/src/main/resources/config.yml @@ -9,6 +9,13 @@ guild-npc: spice-deposits: per-chunk: 2 + patches: + enabled: true + region-spacing: 600 + chance-per-region: 0.35 + radius: 12 + target-value: 5000 + unit-price: 15 planets: arrakis: