Last active
March 28, 2019 17:46
-
-
Save robere2/fd314599161eff24fdb6eae24a252f83 to your computer and use it in GitHub Desktop.
Example of how to set up a very simple scrollable GUI in Minecraft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScrollableGui extends GuiScreen { | |
int scrollDistance = 0; | |
final int x = 10; | |
final int y = 10; | |
@Override | |
public void handleMouseInput() throws IOException { | |
super.handleMouseInput(); | |
// Get the distance scrolled since last checking | |
int d = Mouse.getDWheel(); | |
if(d == 0) | |
return; | |
// Add the distance scrolled to our scrollDistance field | |
scrollDistance += d; | |
} | |
@Override | |
public void drawScreen(int mouseX, int mouseY, float partialTicks) { | |
int adjustedY = y + scrollDistance; | |
// Draw the string at the specified y adjusted for scrolling and x | |
drawString(Minecraft.getMinecraft().fontRendererObj, "Hello, world!", x, adjustedY, 0xFFFFFFFF); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment