### InfoProvider Interface Definition and Usage (Java) Source: https://context7.com/hytale-mods/eyespy/llms.txt The InfoProvider interface is the primary extension point for adding custom information to the EyeSpy HUD. Implementations receive context about the player's target and populate an InfoBuilder with display values. The example demonstrates how to create a custom block info provider. ```java package com.jarhax.eyespy.api.info; import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder; import com.jarhax.eyespy.api.context.Context; public interface InfoProvider { // Called to populate the info builder with values to display void updateDescription(CTX context, InfoBuilder info); // Optional: Modify the UI directly for advanced customization default void modifyUI(CTX context, UICommandBuilder ui) { } } // Example: Custom block info provider public class MyBlockInfoProvider implements InfoProvider { @Override public void updateDescription(BlockContext context, InfoBuilder info) { BlockType block = context.getBlock(); // Add header with block name info.set("Header", id -> new LabelValue(id, Message.translation("mymod.block." + block.getId()), 24)); // Add icon from the block's item Item item = block.getItem(); if (item != null) { info.setIcon(new IconValue(item.getId())); } // Add custom metadata from block state BlockState state = context.getState(); if (state instanceof MyCustomState custom) { info.set("CustomInfo", id -> new LabelValue(id, Message.raw("Power: " + custom.getPowerLevel()))); } } } ``` -------------------------------- ### BlockContext: Get Block Information and Update Description (Java) Source: https://context7.com/hytale-mods/eyespy/llms.txt The BlockContext class provides methods to retrieve details about a targeted block, such as its type, state, and position. The example demonstrates how to use this context within an InfoProvider to display block coordinates and handle specific block states like processing benches and item containers. ```java package com.jarhax.eyespy.api.context; public class BlockContext extends Context { // Get the block type being targeted public BlockType getBlock(); // Get the block's state data (nullable) @Nullable public BlockState getState(); // Get the exact position being targeted public Vector3i getTargetPos(); // Get the offset position (base block for multi-block structures) public Vector3i getOffsetPos(); // Factory method to create context from player targeting @Nullable public static BlockContext create(Player player, float dt, int index, ArchetypeChunk archetypeChunk, Store store, CommandBuffer commandBuffer); } // Example: Using BlockContext in an InfoProvider @Override public void updateDescription(BlockContext context, InfoBuilder info) { BlockType block = context.getBlock(); // Skip empty blocks if (block.getId().equals("Empty")) { return; } // Display block coordinates Vector3i pos = context.getTargetPos(); info.set("Position", id -> new LabelValue(id, Message.raw(String.format("X: %d Y: %d Z: %d", pos.x, pos.y, pos.z)))); // Handle specific block states BlockState state = context.getState(); if (state instanceof ProcessingBenchState processor) { if (processor.isActive()) { float progress = processor.getInputProgress() / processor.getRecipe().getTimeSeconds(); info.set("Crafting", id -> new ProgressBarValue(id, progress)); } } else if (state instanceof ItemContainerState container) { // Display container contents List items = collectItems(container); info.set("Contents", id -> new ItemGridValue(id, items)); } } ``` -------------------------------- ### EntityContext: Get Entity Reference and Display Info (Java) Source: https://context7.com/hytale-mods/eyespy/llms.txt The EntityContext class provides a reference to a targeted entity, allowing access to its components via the entity store. The example illustrates how to use this context to retrieve and display an entity's display name and health statistics. ```java package com.jarhax.eyespy.api.context; public class EntityContext extends Context { // Get a reference to the targeted entity public Ref entity(); // Factory method to create context from player targeting @Nullable public static EntityContext create(Player player, float dt, int index, ArchetypeChunk archetypeChunk, Store store, CommandBuffer commandBuffer); } // Example: Using EntityContext to display entity info @Override public void updateDescription(EntityContext context, InfoBuilder info) { Store store = context.getStore(); Ref entity = context.entity(); // Get display name component DisplayNameComponent displayName = store.getComponent(entity, DisplayNameComponent.getComponentType()); if (displayName != null) { info.set("Header", id -> new LabelValue(id, displayName.getDisplayName(), 24)); } // Get health statistics EntityStatMap stats = store.getComponent(entity, EntityStatMap.getComponentType()); if (stats != null) { int healthIndex = EntityStatType.getAssetMap().getIndex("Health"); EntityStatValue health = stats.get(healthIndex); if (health != null) { info.set("Health", id -> new LabelValue(id, Message.raw(String.format("Health: %.0f/%.0f", health.get(), health.getMax())))); } } } ``` -------------------------------- ### InfoBuilder Class Definition and Usage (Java) Source: https://context7.com/hytale-mods/eyespy/llms.txt The InfoBuilder class collects and organizes UI elements for the EyeSpy HUD. It maintains an ordered map of info values and an optional icon. The example shows how to build a complete info display with a header, icon, progress bar, and footer. ```java package com.jarhax.eyespy.api.info; public class InfoBuilder { // Set an info value with a unique ID public void set(String id, Function factory); // Retrieve a previously set info value public T get(String id); // Set the icon displayed alongside the info public void setIcon(InfoValue icon); // Check if any displayable content exists public boolean canDisplay(); } // Example: Building a complete info display public void updateDescription(BlockContext context, InfoBuilder info) { // Header - displayed first with larger font info.set("Header", id -> new LabelValue(id, Message.raw("Mining Station"), 24)); // Icon - shown to the left of text content info.setIcon(new IconValue("hytale:mining_station")); // Body content - can contain groups, progress bars, etc. info.set("Progress", id -> new ProgressBarValue(id, 0.75f)); // Footer - typically used for mod attribution info.set("Footer", id -> new LabelValue(id, Message.raw("MyMod:MiningStation").color(new Color(85, 85, 255)))); } ``` -------------------------------- ### AnchorBuilder Class for UI Anchors (Java) Source: https://context7.com/hytale-mods/eyespy/llms.txt The AnchorBuilder class is used to construct UI anchor configurations for positioning and sizing HUD elements dynamically. It allows setting positioning values like left, right, top, bottom, width, and height, and also supports adding or ensuring minimum height to accommodate content. The build() method finalizes the Anchor object. ```Java package com.jarhax.eyespy.api.info; public class AnchorBuilder { // Add height to accommodate new content public void addHeight(int height); // Ensure minimum height public void ensureHeight(int height); // Set positioning values public AnchorBuilder setLeft(Integer left); public AnchorBuilder setRight(Integer right); public AnchorBuilder setTop(Integer top); public AnchorBuilder setBottom(Integer bottom); public AnchorBuilder setWidth(Integer width); public AnchorBuilder setHeight(Integer height); // Build the final Anchor object public Anchor build(); } ``` ```Java // Example: AnchorBuilder is used internally when building the HUD // Each InfoValue's build() method receives an AnchorBuilder to update dimensions @Override public void build(@Nonnull UICommandBuilder ui, @Nonnull AnchorBuilder anchorBuilder, String selector) { // Append UI element ui.appendInline(selector, """ Label #%s { Style: LabelStyle(FontSize: %s); }""" .formatted(this.id, this.fontSize)); // Update anchor to accommodate this element's height anchorBuilder.addHeight(this.height); } ``` -------------------------------- ### EntityContext API Source: https://context7.com/hytale-mods/eyespy/llms.txt Provides information about a targeted entity, including a reference to access its components from the entity store. ```APIDOC ## EntityContext Class ### Description The `EntityContext` provides information about a targeted entity, including a reference to access its components from the entity store. ### Method Factory method: `EntityContext.create(Player player, float dt, int index, ArchetypeChunk archetypeChunk, Store store, CommandBuffer commandBuffer)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Example: Using EntityContext to display entity info @Override public void updateDescription(EntityContext context, InfoBuilder info) { Store store = context.getStore(); Ref entity = context.entity(); // Get display name component DisplayNameComponent displayName = store.getComponent(entity, DisplayNameComponent.getComponentType()); if (displayName != null) { info.set("Header", id -> new LabelValue(id, displayName.getDisplayName(), 24)); } // Get health statistics EntityStatMap stats = store.getComponent(entity, EntityStatMap.getComponentType()); if (stats != null) { int healthIndex = EntityStatType.getAssetMap().getIndex("Health"); EntityStatValue health = stats.get(healthIndex); if (health != null) { info.set("Health", id -> new LabelValue(id, Message.raw(String.format("Health: %.0f/%.0f", health.get(), health.getMax())))); } } } ``` ### Response #### Success Response (200) `EntityContext` object containing entity information. #### Response Example ```json { "entityRef": "some_entity_reference", "components": { "DisplayNameComponent": {"displayName": "Example Entity"}, "EntityStatMap": {"Health": {"current": 100, "max": 100}} } } ``` ``` -------------------------------- ### EyeSpy HudProvider Interface for Custom HUDs Source: https://context7.com/hytale-mods/eyespy/llms.txt Defines the interface for custom HUD rendering. It includes a `showHud` method that receives delta time, index, and data stores. EyeSpy provides `VanillaHudProvider` and integrates with `MultiHudProvider` if the MultipleHUD mod is present. ```java package com.jarhax.eyespy.api.hud; import com.jarhax.eyespy.core.entity.ArchetypeChunk; import com.jarhax.eyespy.core.entity.EntityStore; import com.jarhax.eyespy.core.plugin.PluginBase; import com.jarhax.eyespy.core.plugin.PluginIdentifier; import com.jarhax.eyespy.core.plugin.PluginManager; import com.jarhax.eyespy.core.plugin.JavaPlugin; import com.jarhax.eyespy.core.store.CommandBuffer; import com.jarhax.eyespy.core.store.Store; import javax.annotation.Nonnull; public interface HudProvider { void showHud(float dt, int index, @Nonnull ArchetypeChunk archetypeChunk, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer); } // Example: The current provider is accessible via EyeSpy.provider // It automatically switches to MultiHudProvider when MultipleHUD is installed // public class EyeSpy extends JavaPlugin { // public static HudProvider provider = new VanillaHudProvider(); // @Override // protected void start() { // // Auto-detect MultipleHUD mod // PluginBase plugin = PluginManager.get() // .getPlugin(PluginIdentifier.fromString("Buuz135:MultipleHUD")); // if (plugin != null) { // EyeSpy.provider = new MultiHudProvider(); // } // } // } ``` -------------------------------- ### BlockContext API Source: https://context7.com/hytale-mods/eyespy/llms.txt Provides information about a targeted block, including its type, state, and position. It is created automatically when a player looks at a block within range. ```APIDOC ## BlockContext Class ### Description The `BlockContext` provides information about a targeted block, including its type, state, and position. It is created automatically when a player looks at a block within range. ### Method Factory method: `BlockContext.create(Player player, float dt, int index, ArchetypeChunk archetypeChunk, Store store, CommandBuffer commandBuffer)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java // Example: Using BlockContext in an InfoProvider @Override public void updateDescription(BlockContext context, InfoBuilder info) { BlockType block = context.getBlock(); // Skip empty blocks if (block.getId().equals("Empty")) { return; } // Display block coordinates Vector3i pos = context.getTargetPos(); info.set("Position", id -> new LabelValue(id, Message.raw(String.format("X: %d Y: %d Z: %d", pos.x, pos.y, pos.z)))); // Handle specific block states BlockState state = context.getState(); if (state instanceof ProcessingBenchState processor) { if (processor.isActive()) { float progress = processor.getInputProgress() / processor.getRecipe().getTimeSeconds(); info.set("Crafting", id -> new ProgressBarValue(id, progress)); } } else if (state instanceof ItemContainerState container) { // Display container contents List items = collectItems(container); info.set("Contents", id -> new ItemGridValue(id, items)); } } ``` ### Response #### Success Response (200) `BlockContext` object containing block information. #### Response Example ```json { "blockType": "example_block_type", "blockState": { ... }, "targetPos": {"x": 10, "y": 64, "z": -20}, "offsetPos": {"x": 10, "y": 64, "z": -20} } ``` ``` -------------------------------- ### EyeSpy InfoValue Types for UI Elements Source: https://context7.com/hytale-mods/eyespy/llms.txt Provides implementations for common UI elements like text labels, icons, progress bars, and containers. These are used to build informative displays within the game. Dependencies include basic Java types and custom EyeSpy classes like Message and ItemStack. ```java package com.jarhax.eyespy.api.info; import com.jarhax.eyespy.api.Message; import com.jarhax.eyespy.api.MessageHelpers; import com.jarhax.eyespy.core.block.BlockContext; import com.jarhax.eyespy.core.block.BlockState; import com.jarhax.eyespy.core.block.InfoBuilder; import com.jarhax.eyespy.core.block.InfoValue; import com.jarhax.eyespy.core.item.ItemStack; import com.jarhax.eyespy.core.processing.ProcessingBenchState; import java.awt.Color; import java.util.ArrayList; import java.util.List; // LabelValue - Display text with customizable font size public class LabelValue implements InfoValue { public LabelValue(String id, Message value); public LabelValue(String id, Message value, int fontSize); public LabelValue fontSize(int fontSize); public LabelValue setHeight(int height); } // IconValue - Display an item icon public class IconValue implements InfoValue { public IconValue(String iconId); } // ProgressBarValue - Display a progress bar (0.0 to 1.0) public class ProgressBarValue implements InfoValue { public ProgressBarValue(String id, float value); } // GroupValue - Container for multiple values public class GroupValue implements InfoValue { public GroupValue(String id, List values); } // ItemGridValue - Display a grid of item stacks public class ItemGridValue implements InfoValue { public ItemGridValue(String id, List stacks); } // Example: Complex info display with multiple value types // @Override // public void updateDescription(BlockContext context, InfoBuilder info) { // // Header with large text // info.set("Header", id -> new LabelValue(id, // Message.raw("Furnace"), 24)); // // Icon // info.setIcon(new IconValue("hytale:furnace")); // // Grouped body content // info.set("Body", id -> { // List values = new ArrayList<>(); // // Tier label // values.add(new LabelValue(id + "_tier", // MessageHelpers.tier(3).color(new Color(170, 170, 170)))); // // Progress bar for smelting // values.add(new ProgressBarValue(id + "_progress", 0.65f)); // return new GroupValue(id, values); // }); // // Mod attribution footer // info.set("Footer", id -> new LabelValue(id, // Message.raw("Hytale:Furnace") // .color(new Color(85, 85, 255)) // .bold(true))); // } ``` -------------------------------- ### EyeSpy MessageHelpers for Localized Messages Source: https://context7.com/hytale-mods/eyespy/llms.txt A utility class offering convenience methods for generating common localized messages used in game UIs. It supports creating messages for tiers, levels, capacities, sizes, progress, and stages. These methods simplify the creation of user-friendly text displays. ```java package com.jarhax.eyespy.api; import com.jarhax.eyespy.api.info.LabelValue; import com.jarhax.eyespy.core.block.BlockContext; import com.jarhax.eyespy.core.block.BlockState; import com.jarhax.eyespy.core.block.InfoBuilder; import com.jarhax.eyespy.core.processing.ProcessingBenchState; import java.awt.Color; public class MessageHelpers { // "Tier X" message public static Message tier(int tier); // "Level X" message public static Message level(int level); // "Capacity: X" message public static Message capacity(int capacity); // "Size: X" message public static Message size(int size); // Progress percentage message public static Message progress(int current, int max); public static Message progress(float amount); // "Stage X/Y" message public static Message stage(int current, int max); } // Example: Using MessageHelpers in an InfoProvider // @Override // public void updateDescription(BlockContext context, InfoBuilder info) { // BlockState state = context.getState(); // if (state instanceof ProcessingBenchState processor) { // // Use tier helper for crafting station tier // info.set("Tier", id -> new LabelValue(id, // MessageHelpers.tier(processor.getTierLevel()) // .color(new Color(170, 170, 170)))); // if (processor.isActive()) { // // Use progress helper for crafting progress // float progress = processor.getInputProgress() / // processor.getRecipe().getTimeSeconds(); // info.set("Progress", id -> new LabelValue(id, // MessageHelpers.progress(progress))); // } // } // } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.