### Interact with Entity Type Registry in Adyeshach Source: https://context7.com/taboolib/adyeshach/llms.txt This snippet demonstrates how to use the Adyeshach Entity Type Registry to get information about different entity types, convert between Bukkit and Adyeshach entity types, and create entity instances. It requires the Adyeshach core library. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import ink.ptms.adyeshach.core.entity.EntityTypes import org.bukkit.entity.EntityType val registry = Adyeshach.api().getEntityTypeRegistry() // Get Bukkit entity type from Adyeshach type val bukkitType = registry.getBukkitEntityType(EntityTypes.ZOMBIE) // Get Bukkit entity type (nullable) val type = registry.getBukkitEntityTypeOrNull(EntityTypes.PLAYER) // Get entity size information val size = registry.getEntitySize(EntityTypes.GIANT) // size.width, size.height // Get entity pathfinding type val pathType = registry.getEntityPathType(EntityTypes.ZOMBIE) // Create entity instance val instance = registry.getEntityInstance(EntityTypes.SKELETON) // Get Adyeshach type from Bukkit type val adyType = registry.getEntityTypeFromBukkit(EntityType.CREEPER) // Get entity flags (TESTING, INVALID, etc.) val flags = registry.getEntityFlags(EntityTypes.WARDEN) // Get client update interval for entity type val updateInterval = registry.getEntityClientUpdateInterval(EntityTypes.ARMOR_STAND) ``` -------------------------------- ### Implement Custom Entity Behavior with Controllers Source: https://context7.com/taboolib/adyeshach/llms.txt This snippet shows how to create and apply custom controllers to entities to implement AI-like behavior. It includes a 'FollowPlayerController' example and demonstrates adding and removing controllers from an entity's brain. Requires Adyeshach core library and entity management components. ```kotlin import ink.ptms.adyeshach.core.entity.EntityInstance import ink.ptms.adyeshach.core.entity.controller.Controller // Custom controller implementation class FollowPlayerController(val targetPlayer: Player) : Controller() { override fun id() = "follow_player" override fun group() = "movement" override fun priority() = 10 override fun shouldExecute(): Boolean { val entity = entity ?: return false val distance = entity.getLocation().distance(targetPlayer.location) return distance > 3.0 && distance < 20.0 } override fun tick() { val entity = entity ?: return val target = targetPlayer.location // Move towards player val direction = target.toVector() .subtract(entity.getLocation().toVector()) .normalize() .multiply(0.2) val newLocation = entity.getLocation().add(direction) entity.teleport(newLocation) entity.setHeadRotation(target) } override fun isAsync() = false } // Apply controller to entity val entity = publicManager.create(EntityTypes.VILLAGER, location) entity.brain.addController(FollowPlayerController(player)) // Remove controller entity.brain.removeController("follow_player") // Built-in controllers available: // - ControllerLookAtPlayer: Makes entity look at nearby players // - ControllerRandomLookaround: Random head movements // - BionicSight: Advanced line-of-sight calculations ``` -------------------------------- ### Query and Retrieve Entities with Entity Finder Source: https://context7.com/taboolib/adyeshach/llms.txt The Entity Finder utility allows searching for entities across all managers using various filters and identifiers. It can retrieve entities visible to a specific player, find entities by custom ID or unique UUID, get the nearest entity based on conditions, and fetch all entities matching a specific filter. It also supports finding entities by their client-side entity ID, useful for packet interactions. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import org.bukkit.entity.Player val finder = Adyeshach.api().getEntityFinder() // Get all entities visible to a player val visibleEntities = finder.getVisibleEntities(player) // Find entity by custom ID val entitiesById = finder.getEntitiesFromId("my_npc_id", player) // Find entity by unique UUID val entity = finder.getEntityFromUniqueId("550e8400-e29b-41d4-a716-446655440000", player) // Get nearest entity to player val nearest = finder.getNearestEntity(player) { entity -> entity.getEntityType() == EntityTypes.ZOMBIE } // Get nearest entity by ID val nearestNPC = finder.getNearestEntityFromId("shop_keeper", player) // Get all entities matching filter val allZombies = finder.getEntities(player) { entity -> entity.getEntityType() == EntityTypes.ZOMBIE && !entity.isDead() } // Get entity by client-side entity ID (from packet interaction) val clickedEntity = finder.getEntityFromClientEntityId(entityId, player) ``` -------------------------------- ### Access Adyeshach Core API Singleton Source: https://context7.com/taboolib/adyeshach/llms.txt Retrieve the main Adyeshach API singleton instance to interact with all plugin features. This includes accessing various subsystems like entity finders, hologram handlers, entity type registries, and Minecraft-specific APIs. The editor interface can also be accessed, though it may be null if the editor module is not loaded. ```kotlin import ink.ptms.adyeshach.core.Adyeshach // Get the API instance val api = Adyeshach.api() // Get the editor interface (may be null if editor module not loaded) val editor = Adyeshach.editor() // Example: Access various subsystems through the API val entityFinder = api.getEntityFinder() val hologramHandler = api.getHologramHandler() val entityTypeRegistry = api.getEntityTypeRegistry() val minecraftAPI = api.getMinecraftAPI() ``` -------------------------------- ### Create and Manage Holograms with Adyeshach API Source: https://context7.com/taboolib/adyeshach/llms.txt This snippet demonstrates how to create, update, move, and remove holograms using the Adyeshach API. It covers both public and private holograms, as well as temporary messages. Dependencies include Adyeshach core library. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import org.bukkit.Location import org.bukkit.Material import org.bukkit.inventory.ItemStack val hologramHandler = Adyeshach.api().getHologramHandler() // Create public hologram with mixed content val location = Location(world, 0.0, 100.0, 0.0) val hologram = hologramHandler.createHologram( location = location, content = listOf( "§6§lWelcome to the Server!", "§7Players online: 42", ItemStack(Material.DIAMOND_SWORD), "§aClick for rewards!" ) ) // Update hologram content dynamically hologram.update(listOf( "§6§lWelcome!", "§7Players: 45" )) // Safe update (only updates if same structure) hologram.updateSafely(listOf( "§6§lWelcome!", "§7Players: 50" )) // Move hologram hologram.teleport(newLocation) // Create private hologram for specific player val privateHologram = hologramHandler.createHologram( player = player, location = playerLocation.add(0.0, 2.0, 0.0), content = listOf("§eYour Private Message") ) // Send temporary hologram message hologramHandler.sendHologramMessage( location = location, message = listOf("§c§lWarning!", "§7Area is dangerous"), stay = 60L // ticks (3 seconds) ) // Remove hologram hologram.remove() ``` -------------------------------- ### Create and Manage Virtual Entities with Entity Managers Source: https://context7.com/taboolib/adyeshach/llms.txt Utilize public or private entity managers to create and manage virtual entities. Public managers make entities visible to all players, while private managers restrict visibility to specific players. Entities can be created at a given location with customizable properties like names and visibility. Operations include teleporting, removing, finding by ID, and filtering entities based on custom criteria. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import ink.ptms.adyeshach.core.entity.EntityTypes import ink.ptms.adyeshach.core.entity.manager.ManagerType import org.bukkit.entity.Player import org.bukkit.Location // Get public entity manager (visible to all players) val publicManager = Adyeshach.api().getPublicEntityManager(ManagerType.TEMPORARY) // Create a zombie entity at specific location val location = Location(world, 100.0, 64.0, 100.0) val zombie = publicManager.create(EntityTypes.ZOMBIE, location) { entity -> // Configure entity before spawning entity.setCustomName("Friendly Zombie") entity.setCustomNameVisible(true) } // Get private entity manager (visible only to specific player) val privateManager = Adyeshach.api().getPrivateEntityManager(player, ManagerType.TEMPORARY) // Create player-specific NPC val npc = privateManager.create(EntityTypes.PLAYER, playerLocation) { entity -> entity.setCustomName("Private Guide") } // Teleport entity zombie.teleport(newLocation) // Remove entity zombie.remove() // Find entities by ID val entities = publicManager.getEntityById("my_custom_id") // Get all entities with filter val nearbyEntities = publicManager.getEntities { entity -> entity.getLocation().distance(playerLocation) < 10.0 } ``` -------------------------------- ### Serialize and Deserialize Entities in Kotlin Source: https://context7.com/taboolib/adyeshach/llms.txt Save and load entity data to and from configuration files using Kotlin. This involves obtaining an entity serializer, saving entities to files or configuration sections, and loading them back. This functionality is crucial for persisting entity states. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import java.io.File val serializer = Adyeshach.api().getEntitySerializer() // Save entity to file val file = File(dataFolder, "entities/my_npc.yml") serializer.saveEntity(entity, file) // Load entity from file val manager = Adyeshach.api().getPublicEntityManager() val loadedEntity = manager.loadEntityFromFile(file) // Serialize to configuration section val config = YamlConfiguration() serializer.saveEntityToConfig(entity, config.createSection("entity")) // Deserialize from configuration val entityData = config.getConfigurationSection("entity") val restoredEntity = serializer.loadEntityFromConfig(entityData, manager) ``` -------------------------------- ### Manage Entity Managers for Players in Kotlin Source: https://context7.com/taboolib/adyeshach/llms.txt Handle the lifecycle of entity managers for players using Kotlin event listeners. This includes setting up an entity manager when a player joins, refreshing entities to make them visible, and releasing the entity manager when a player quits. This ensures proper entity synchronization per player. ```kotlin import ink.ptms.adyeshach.core.Adyeshach import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.event.player.PlayerQuitEvent import org.bukkit.event.Listener class EntityManagerListener : Listener { @EventHandler fun onPlayerJoin(event: PlayerJoinEvent) { val player = event.player // Setup entity manager for player Adyeshach.api().setupEntityManager(player) // Refresh to show all entities Adyeshach.api().refreshEntityManager(player) } @EventHandler fun onPlayerQuit(event: PlayerQuitEvent) { val player = event.player // Release entity manager (async by default) Adyeshach.api().releaseEntityManager(player, async = true) } } // Refresh all public entities Adyeshach.api().refreshPublicEntityManager() ``` -------------------------------- ### Control Individual Entities in Kotlin Source: https://context7.com/taboolib/adyeshach/llms.txt Manipulate entity properties, position, metadata, and visibility using Kotlin. This includes spawning, respawning, teleporting, setting velocity, controlling head rotation, playing animations, managing attached entities, cloning, despawning, removing, and checking entity states. It also covers setting custom names, fire ticks, glowing, and invisibility. ```kotlin import ink.ptms.adyeshach.core.entity.EntityInstance import ink.ptms.adyeshach.core.bukkit.BukkitAnimation import org.bukkit.util.Vector // Spawn entity at location entity.spawn(location) // Respawn entity (if already spawned) entity.respawn() // Teleport entity entity.teleport(x = 100.0, y = 64.0, z = 100.0) entity.teleport(location) // Set entity velocity entity.setVelocity(Vector(0.5, 1.0, 0.0)) entity.setVelocity(x = 0.5, y = 1.0, z = 0.0) // Set head rotation to look at location entity.setHeadRotation(targetLocation, forceUpdate = true) entity.setHeadRotation(yaw = 90f, pitch = 0f) // Play animation entity.sendAnimation(BukkitAnimation.SWING_MAIN_ARM) entity.sendAnimation(BukkitAnimation.TAKE_DAMAGE) // Add attached entity (moves with parent) entity.addAttachEntity(id = childEntityIndex, relativePos = Vector(0.0, 1.0, 0.0)) entity.removeAttachEntity(id = childEntityIndex) // Clone entity val clone = entity.clone( newId = "cloned_entity", location = cloneLocation, manager = publicManager ) // Despawn without removing from manager entity.despawn(destroyPacket = true, removeFromManager = false) // Remove entity completely entity.remove() // Check entity state val isPublic = entity.isPublic() val isTemporary = entity.isTemporary() // Set custom name entity.setCustomName("§6Quest Giver") entity.setCustomNameVisible(true) // Set entity on fire (visual effect) entity.setFireTicks(100) // Set entity glowing entity.setGlowing(true) // Set entity invisible entity.setInvisible(true) // Entity visibility control (from EntityInstance interface: Viewable) // Add viewer (make visible to specific player) entity.addViewer(player) // Remove viewer (hide from specific player) entity.removeViewer(player) // Check if player can see entity val canSee = entity.hasViewer(player) // Get all viewers val viewers = entity.getViewers() // Clear all viewers entity.clearViewer() // Visibility update (refresh for all viewers) entity.visible(true) // show to all viewers entity.visible(false) // hide from all viewers ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.