Miles

Make an alien dimension with a bunch of advanced technology and a bunch of aliens

Kodari AI
KodariOct 24 at 4:20 pm 1
AlienTechDimension
Creates a new explorable alien dimension filled with advanced technology and alien inhabitants. The plugin generates a unique dimension accessible via a custom portal, featuring futuristic terrain, alien mobs with unique behaviors, high-tech structures like glowing towers and energy nodes, and collectible tech items. Includes custom crafting recipes, dimension-specific loot tables, and a quest system to guide players through discovering the dimension's secrets. Features configurable spawn rates, biome generation, and compatibility with popular world-gen libraries.

Plan:

  • Add the Kotlin/Paper build and plugin metadata.

  • Generate an End-themed alien world with terrain and scattered reactor outposts.

  • Add /alienworld travel and custom alien mobs with tech drops.

Created the Paper plugin with a custom alien dimension, procedurally generated terrain and reactor outposts, six types of named alien mobs, and alien tech drops. Use /alienworld or /alienworld tp to travel there; /alienworld create creates it and teleports you.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
Code
7 316
src/main/kotlin/com/kodari/aliendimension/AlienMobManager.kt
package com.kodari.aliendimension

import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.entity.EntityType
import org.bukkit.entity.LivingEntity
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDeathEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType
import java.util.Random

class AlienMobManager(private val plugin: AlienDimensionPlugin) : Listener {
    private val alienKey = NamespacedKey(plugin, "alien_mob")
    private val random = Random()
    private val species = listOf(
        Species(EntityType.ENDERMAN, "Void Stalker", Material.CHAINMAIL_HELMET, Material.IRON_CHESTPLATE, Material.IRON_SWORD),
        Species(EntityType.WITCH, "Xeno Biochemist", Material.GOLDEN_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.BLAZE_ROD),
        Species(EntityType.HUSK, "Dust Raider", Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_AXE),
        Species(EntityType.STRAY, "Starforged Hunter", Material.CHAINMAIL_HELMET, Material.IRON_CHESTPLATE, Material.BOW),
        Species(EntityType.ZOMBIE, "Cybernetic Guard", Material.NETHERITE_HELMET, Material.IRON_CHESTPLATE, Material.IRON_SWORD),
        Species(EntityType.SKELETON, "Plasma Marksman", Material.IRON_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CROSSBOW)
    )

    fun start() {
        plugin.server.scheduler.runTaskTimer(plugin, Runnable { spawnAliens() }, 100L, 200L)
    }

    private fun spawnAliens() {
        for (player in Bukkit.getOnlinePlayers()) {
            if (player.world.name != AlienDimensionPlugin.WORLD_NAME) continue

            val nearbyAliens = player.world.getNearbyEntities(player.location, 32.0, 24.0, 32.0)
                .count { it.persistentDataContainer.has(alienKey, PersistentDataType.BYTE) }
            repeat(minOf(2, MAX_ALIENS_PER_PLAYER - nearbyAliens)) {
                spawnAlienNear(player)
            }
        }
    }

    private fun spawnAlienNear(player: org.bukkit.entity.Player) {
        val world = player.world
        val x = player.location.blockX + random.nextInt(-12, 13)
        val z = player.location.blockZ + random.nextInt(-12, 13)
        val y = world.getHighestBlockYAt(x, z) + 1
        val location = org.bukkit.Location(world, x + 0.5, y.toDouble(), z + 0.5)
        val chosen = species[random.nextInt(species.size)]
        val alien = world.spawnEntity(location, chosen.type) as? LivingEntity ?: return

        alien.persistentDataContainer.set(alienKey, PersistentDataType.BYTE, 1)
        alien.customName = "${ChatColor.LIGHT_PURPLE}${chosen.designation} ${ChatColor.DARK_PURPLE}#${random.nextInt(100, 1000)}"
        alien.isCustomNameVisible = true
        alien.setRemoveWhenFarAway(false)
        alien.canPickupItems = false

        alien.equipment?.apply {
            setHelmet(ItemStack(chosen.helmet))
            setChestplate(ItemStack(chosen.chestplate))
            setItemInMainHand(ItemStack(chosen.weapon))
        }
    }

    @EventHandler
    fun onAlienDeath(event: EntityDeathEvent) {
        if (!event.entity.persistentDataContainer.has(alienKey, PersistentDataType.BYTE)) return

        if (random.nextDouble() < 0.65) {
            event.drops.add(techDrop(Material.AMETHYST_SHARD, "Xeno Core", "${ChatColor.GRAY}A humming power source from an alien machine."))
        }
        if (random.nextDouble() < 0.35) {
            event.drops.add(techDrop(Material.PRISMARINE_CRYSTALS, "Quantum Circuit", "${ChatColor.GRAY}A fragment of advanced alien circuitry."))
        }
        event.droppedExp += 4
    }

    private fun techDrop(material: Material, name: String, description: String): ItemStack {
        val item = ItemStack(material)
        val meta = item.itemMeta
        meta.setDisplayName("${ChatColor.AQUA}$name")
        meta.lore = listOf(description)
        item.itemMeta = meta
        return item
    }

    private data class Species(
        val type: EntityType,
        val designation: String,
        val helmet: Material,
        val chestplate: Material,
        val weapon: Material
    )

    companion object {
        private const val MAX_ALIENS_PER_PLAYER = 12
    }
}