Guiy
Guiy is a general purpose library for creating chest GUIs. It is an easy
way to create navigatable guis with powerful functionality, such as
on click events and user input.
Guiy was written against minecraft version 1.13.2, but should work for higher
versions (and probably lower versions as well). If it doesn't work for something in
1.14 let me know and I'll take a look.
Guiy was made with creative mode in mind, so treats all clicks the same (clients in
creative mode do not distinguish between different types of inventory
click events).
Some Features
- Layout - Holds multiple other elements
- ClickableElement - Invokes a callback on click
- NumberInput - Input a (positive at the moment) floating point value
- BooleanInput - Input a boolean value
- FixedStringInput - Choose a single string from a list of possible strings
- VerticalScrollingElement - Allow vertical scrolling of an element
- ScrollingPallet - Horizontally scrolling element fixed at one slot high
- FillableElement - Allows adding other elements to it at next available position
Examples
Guiy abstracts the chest GUI into a number of elements. Most elements
wrap other elements to provide additional functionality. A root element
is added to a [code single]GuiHolder[/code], and item holder that passes all click events
through the element tree.
You must register an [code single]InventoryClickEvent[/code] listener in your plugin which
wraps and passes click events to the holder. A simple listener is provided
in [code single]com.derongan.minecraft.guiy.GuiListener[/code]. You can register this if
you want.
Create simple view and swap to a new view
Code (Java):
Layout secondView
= ...
Layout firstView = new Layout ( ) ;
Element cell = Cell. forMaterial (Material. DIAMOND_BLOCK, "Button" ) ;
ClickableElement button = new ClickableElement (cell ) ;
firstView. addElement ( 0, 0, button ) ;
SwappableElement swappable = new SwappableElement (firstView ) ;
button. setClickAction (clickEvent -> {
swappable. swap (secondView ) ;
} ) ;
GuiHolder guiHolder = new GuiHolder ( 6, "Gui with second view", firstView, yourPlugin ) ;
guiHolder. show (player ) ;
Layout firstView = new Layout ( ) ;
Element cell = Cell. forMaterial (Material. DIAMOND_BLOCK, "Button" ) ;
ClickableElement button = new ClickableElement (cell ) ;
firstView. addElement ( 0, 0, button ) ;
SwappableElement swappable = new SwappableElement (firstView ) ;
button. setClickAction (clickEvent -> {
swappable. swap (secondView ) ;
} ) ;
GuiHolder guiHolder = new GuiHolder ( 6, "Gui with second view", firstView, yourPlugin ) ;
guiHolder. show (player ) ;
Code (Java):
Layout layout
=
new Layout
(
)
;
Element cell = Cell. forMaterial (Material. DIAMOND_BLOCK, "Submit Number" ) ;
ClickableElement button = new ClickableElement (cell ) ;
NumberInput numberInput = new NumberInput ( ) ;
layout. addElement ( 4, 5, button ) ;
layout. addElement ( 0, 0, numberInput ) ;
button. setClickAction (clickEvent -> {
numberInput. onSubmit ( ) ;
} ) ;
numberInput. setSubmitAction (number -> {
player. sendMessage ( String. format ( "You entered %f", number ) ) ;
} ) ;
GuiHolder guiHolder = new GuiHolder ( 6, "Gui with number input", layout, yourPlugin ) ;
guiHolder. show (player ) ;
Element cell = Cell. forMaterial (Material. DIAMOND_BLOCK, "Submit Number" ) ;
ClickableElement button = new ClickableElement (cell ) ;
NumberInput numberInput = new NumberInput ( ) ;
layout. addElement ( 4, 5, button ) ;
layout. addElement ( 0, 0, numberInput ) ;
button. setClickAction (clickEvent -> {
numberInput. onSubmit ( ) ;
} ) ;
numberInput. setSubmitAction (number -> {
player. sendMessage ( String. format ( "You entered %f", number ) ) ;
} ) ;
GuiHolder guiHolder = new GuiHolder ( 6, "Gui with number input", layout, yourPlugin ) ;
guiHolder. show (player ) ;
Code (Text):
repositories {
maven {
name = 'jitpack'
url = "https://jitpack.io"
}
}
dependencies {
compile group: 'com.github.MineInAbyss', name: 'guiy', version: "master-SNAPSHOT"
}
maven {
name = 'jitpack'
url = "https://jitpack.io"
}
}
dependencies {
compile group: 'com.github.MineInAbyss', name: 'guiy', version: "master-SNAPSHOT"
}
Code (Text):
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.MineInAbyss</groupId>
<artifactId>guiy</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.MineInAbyss</groupId>
<artifactId>guiy</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
This is probably very specific to the problem I was solving when I made Guiy, but guiy supports Protocol buffer inputs out of the box.
Say we have the following protocol buffer definition:
Code (Text):
package com.something.test.proto;
message Thing {
enum Color{
RED = 0;
BLUE = 1;
YELLOW = 2;
}
Color color = 1;
double value = 2;
}
message Thing {
enum Color{
RED = 0;
BLUE = 1;
YELLOW = 2;
}
Color color = 1;
double value = 2;
}
Code (Java):
// Construct the initial message state. Values will be preserved if unchanged.
Thing thing = Thing. newBuilder ( ). setValue ( 2 ). build ;
ProtobufInput <Thing > protobufInput = new ProtobufInput <> (thing ) ;
thing. setSubmitAction (newThing -> {
// newThing is a message of type Thing.
} ) ;
Thing thing = Thing. newBuilder ( ). setValue ( 2 ). build ;
ProtobufInput <Thing > protobufInput = new ProtobufInput <> (thing ) ;
thing. setSubmitAction (newThing -> {
// newThing is a message of type Thing.
} ) ;
Many thanks to Daniel Saukel for Headlib, which
makes life so much easier.
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft version listed: 1.13
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
Guiy is a free Minecraft Java mod. Compatible with Minecraft 1.13. Downloaded 120 times (via Spigot). Download it and open it directly in the game.