Skip to content

Instantly share code, notes, and snippets.

@Densamisten
Created September 9, 2024 15:45
Show Gist options
  • Select an option

  • Save Densamisten/a45629e785a336a00038aab0e225b065 to your computer and use it in GitHub Desktop.

Select an option

Save Densamisten/a45629e785a336a00038aab0e225b065 to your computer and use it in GitHub Desktop.
package exonihility.client.gui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class EntityListScreen extends Screen {
private ScrollingEntityListWidget scrollingEntityList;
public EntityListScreen(Text title) {
super(title);
}
@Override
protected void init() {
super.init();
// Initialize the scrolling list widget directly with height values
scrollingEntityList = new ScrollingEntityListWidget(
this.client, this.width, this.height, 20, this.height - 40, 40 // Use this.height - 40 for the bottom
);
// Add the widget to the screen
this.addSelectableChild(scrollingEntityList);
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context, mouseX, mouseY, delta); // Render background
super.render(context, mouseX, mouseY, delta); // Render entities in the scrolling list
scrollingEntityList.render(context, mouseX, mouseY, delta); // Render the scrolling widget
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment