Package noppes.npcs.api.gui
Interface ICustomGui
-
public interface ICustomGui
Represents a custom graphical user interface (GUI) that can contain various components such as buttons, labels, text fields, item slots, etc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description IButton
addButton(int id, java.lang.String text, int x, int y)
Adds a button to the GUI.IButton
addButton(int id, java.lang.String text, int x, int y, int width, int height)
Adds a button to the GUI with a specified size.IItemSlot
addItemSlot(int x, int y)
Deprecated.Use addItemSlot(int, int, IItemStack) with an ID instead.IItemSlot
addItemSlot(int id, int x, int y)
Adds an item slot component to the GUI.IItemSlot
addItemSlot(int id, int x, int y, IItemStack itemStack)
Adds an item slot component with an initial item stack.IItemSlot
addItemSlot(int x, int y, IItemStack itemStack)
Deprecated.Use addItemSlot(int, int, IItemStack) with an ID instead.ILabel
addLabel(int id, java.lang.String text, int x, int y, int width, int height)
Adds a label component to the GUI.ILabel
addLabel(int id, java.lang.String text, int x, int y, int width, int height, int color)
Adds a label component with a specified text color.ILine
addLine(int id, int x1, int y1, int x2, int y2)
Adds a line component with default thickness.ILine
addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness)
Adds a line component to the GUI.IScroll
addScroll(int id, int x, int y, int width, int height, java.lang.String[] list)
Adds a scroll component to the GUI.ITextField
addTextField(int id, int x, int y, int width, int height)
Adds a text field component to the GUI.IButton
addTexturedButton(int id, java.lang.String text, int x, int y, int width, int height, java.lang.String texture)
Adds a textured button to the GUI.IButton
addTexturedButton(int id, java.lang.String text, int x, int y, int width, int height, java.lang.String texture, int textureX, int textureY)
Adds a textured button with texture offset.ITexturedRect
addTexturedRect(int id, java.lang.String texture, int x, int y, int width, int height)
Adds a textured rectangle component to the GUI.ITexturedRect
addTexturedRect(int id, java.lang.String texture, int x, int y, int width, int height, int textureX, int textureY)
Adds a textured rectangle component with texture offset.void
clear()
Clears all components from the GUI.boolean
doesPauseGame()
Checks if the GUI pauses the game.ICustomGui
fromNBT(net.minecraft.nbt.NBTTagCompound tag)
Recreates the GUI from NBT data.java.lang.String
getBackgroundTexture()
Returns the background texture resource location.ICustomGuiComponent
getComponent(int id)
Retrieves the GUI component with the given ID.java.util.List<ICustomGuiComponent>
getComponents()
Returns a list of all components contained in this GUI.int
getHeight()
Returns the height of the GUI.int
getID()
Returns the unique ID of the GUI.int
getPlayerInvX()
int
getPlayerInvY()
boolean
getShowPlayerInv()
java.util.List<IItemSlot>
getSlots()
Returns a list of item slot components in this GUI.int
getWidth()
Returns the width of the GUI.void
removeComponent(int id)
Removes the GUI component with the specified ID.void
setBackgroundTexture(java.lang.String resourceLocation)
Sets the background texture resource location for the GUI.void
setDoesPauseGame(boolean pauseGame)
Specifies whether the GUI pauses the game.void
setSize(int width, int height)
Sets the size of the GUI.void
showPlayerInventory(int x, int y)
Displays the player's inventory at the specified position.net.minecraft.nbt.NBTTagCompound
toNBT()
Serializes the GUI to an NBT tag.void
update(IPlayer player)
Sends an update of the GUI to the given player.void
updateComponent(ICustomGuiComponent component)
Updates the specified GUI component.
-
-
-
Method Detail
-
getID
int getID()
Returns the unique ID of the GUI.- Returns:
- the GUI ID.
-
getWidth
int getWidth()
Returns the width of the GUI.- Returns:
- the width in pixels.
-
getHeight
int getHeight()
Returns the height of the GUI.- Returns:
- the height in pixels.
-
getComponents
java.util.List<ICustomGuiComponent> getComponents()
Returns a list of all components contained in this GUI.- Returns:
- the list of components.
-
clear
void clear()
Clears all components from the GUI.
-
getSlots
java.util.List<IItemSlot> getSlots()
Returns a list of item slot components in this GUI.- Returns:
- the list of item slots.
-
setSize
void setSize(int width, int height)
Sets the size of the GUI.- Parameters:
width
- the new width.height
- the new height.
-
setDoesPauseGame
void setDoesPauseGame(boolean pauseGame)
Specifies whether the GUI pauses the game.- Parameters:
pauseGame
- true to pause the game.
-
doesPauseGame
boolean doesPauseGame()
Checks if the GUI pauses the game.- Returns:
- true if it pauses the game; false otherwise.
-
setBackgroundTexture
void setBackgroundTexture(java.lang.String resourceLocation)
Sets the background texture resource location for the GUI.- Parameters:
resourceLocation
- the texture resource location.
-
getBackgroundTexture
java.lang.String getBackgroundTexture()
Returns the background texture resource location.- Returns:
- the texture as a string.
-
addButton
IButton addButton(int id, java.lang.String text, int x, int y)
Adds a button to the GUI.- Parameters:
id
- the component ID.text
- the button label.x
- the x position.y
- the y position.- Returns:
- the created button.
-
addButton
IButton addButton(int id, java.lang.String text, int x, int y, int width, int height)
Adds a button to the GUI with a specified size.- Parameters:
id
- the component ID.text
- the button label.x
- the x position.y
- the y position.width
- the button width.height
- the button height.- Returns:
- the created button.
-
addTexturedButton
IButton addTexturedButton(int id, java.lang.String text, int x, int y, int width, int height, java.lang.String texture)
Adds a textured button to the GUI.- Parameters:
id
- the component ID.text
- the button label.x
- the x position.y
- the y position.width
- the button width.height
- the button height.texture
- the texture resource location.- Returns:
- the created button.
-
addTexturedButton
IButton addTexturedButton(int id, java.lang.String text, int x, int y, int width, int height, java.lang.String texture, int textureX, int textureY)
Adds a textured button with texture offset.- Parameters:
id
- the component ID.text
- the button label.x
- the x position.y
- the y position.width
- the button width.height
- the button height.texture
- the texture resource location.textureX
- the x offset in the texture.textureY
- the y offset in the texture.- Returns:
- the created button.
-
addLabel
ILabel addLabel(int id, java.lang.String text, int x, int y, int width, int height)
Adds a label component to the GUI.- Parameters:
id
- the component ID.text
- the label text.x
- the x position.y
- the y position.width
- the width.height
- the height.- Returns:
- the created label.
-
addLabel
ILabel addLabel(int id, java.lang.String text, int x, int y, int width, int height, int color)
Adds a label component with a specified text color.- Parameters:
id
- the component ID.text
- the label text.x
- the x position.y
- the y position.width
- the width.height
- the height.color
- the text color.- Returns:
- the created label.
-
addTextField
ITextField addTextField(int id, int x, int y, int width, int height)
Adds a text field component to the GUI.- Parameters:
id
- the component ID.x
- the x position.y
- the y position.width
- the width.height
- the height.- Returns:
- the created text field.
-
addTexturedRect
ITexturedRect addTexturedRect(int id, java.lang.String texture, int x, int y, int width, int height)
Adds a textured rectangle component to the GUI.- Parameters:
id
- the component ID.texture
- the texture resource location.x
- the x position.y
- the y position.width
- the width.height
- the height.- Returns:
- the created textured rectangle.
-
addTexturedRect
ITexturedRect addTexturedRect(int id, java.lang.String texture, int x, int y, int width, int height, int textureX, int textureY)
Adds a textured rectangle component with texture offset.- Parameters:
id
- the component ID.texture
- the texture resource location.x
- the x position.y
- the y position.width
- the width.height
- the height.textureX
- the x offset within the texture.textureY
- the y offset within the texture.- Returns:
- the created textured rectangle.
-
addItemSlot
IItemSlot addItemSlot(int id, int x, int y)
Adds an item slot component to the GUI.- Parameters:
id
- the component ID.x
- the x position.y
- the y position.- Returns:
- the created item slot.
-
addItemSlot
IItemSlot addItemSlot(int id, int x, int y, IItemStack itemStack)
Adds an item slot component with an initial item stack.- Parameters:
id
- the component ID.x
- the x position.y
- the y position.itemStack
- the initial item.- Returns:
- the created item slot.
-
addItemSlot
@Deprecated IItemSlot addItemSlot(int x, int y)
Deprecated.Use addItemSlot(int, int, IItemStack) with an ID instead.
-
addItemSlot
@Deprecated IItemSlot addItemSlot(int x, int y, IItemStack itemStack)
Deprecated.Use addItemSlot(int, int, IItemStack) with an ID instead.
-
addScroll
IScroll addScroll(int id, int x, int y, int width, int height, java.lang.String[] list)
Adds a scroll component to the GUI.- Parameters:
id
- the component ID.x
- the x position.y
- the y position.width
- the width.height
- the height.list
- the list of strings to display.- Returns:
- the created scroll component.
-
addLine
ILine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness)
Adds a line component to the GUI.- Parameters:
id
- the component ID.x1
- the start x position.y1
- the start y position.x2
- the end x position.y2
- the end y position.color
- the line color.thickness
- the line thickness.- Returns:
- the created line component.
-
addLine
ILine addLine(int id, int x1, int y1, int x2, int y2)
Adds a line component with default thickness.- Parameters:
id
- the component ID.x1
- the start x position.y1
- the start y position.x2
- the end x position.y2
- the end y position.- Returns:
- the created line component.
-
showPlayerInventory
void showPlayerInventory(int x, int y)
Displays the player's inventory at the specified position.- Parameters:
x
- the x position.y
- the y position.
-
getComponent
ICustomGuiComponent getComponent(int id)
Retrieves the GUI component with the given ID.- Parameters:
id
- the component ID.- Returns:
- the component.
-
removeComponent
void removeComponent(int id)
Removes the GUI component with the specified ID.- Parameters:
id
- the component ID.
-
updateComponent
void updateComponent(ICustomGuiComponent component)
Updates the specified GUI component.- Parameters:
component
- the component to update.
-
update
void update(IPlayer player)
Sends an update of the GUI to the given player.- Parameters:
player
- the player to update.
-
getShowPlayerInv
boolean getShowPlayerInv()
- Returns:
- true if the player inventory is shown.
-
getPlayerInvX
int getPlayerInvX()
- Returns:
- the x position where the player inventory is displayed.
-
getPlayerInvY
int getPlayerInvY()
- Returns:
- the y position where the player inventory is displayed.
-
fromNBT
ICustomGui fromNBT(net.minecraft.nbt.NBTTagCompound tag)
Recreates the GUI from NBT data.- Parameters:
tag
- the NBT tag.- Returns:
- this GUI.
-
toNBT
net.minecraft.nbt.NBTTagCompound toNBT()
Serializes the GUI to an NBT tag.- Returns:
- the NBT data.
-
-