LabelWidget.java 837 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package me.shedaniel.rei.gui.widget;
  2. import net.minecraft.client.gui.Element;
  3. import java.awt.*;
  4. import java.util.Collections;
  5. import java.util.List;
  6. public class LabelWidget extends HighlightableWidget {
  7. public int x;
  8. public int y;
  9. public String text;
  10. public LabelWidget(int x, int y, String text) {
  11. this.x = x;
  12. this.y = y;
  13. this.text = text;
  14. }
  15. @Override
  16. public Rectangle getBounds() {
  17. int width = font.getStringWidth(text);
  18. return new Rectangle(x - width / 2 - 1, y - 5, width + 2, 14);
  19. }
  20. @Override
  21. public List<? extends Element> children() {
  22. return Collections.emptyList();
  23. }
  24. @Override
  25. public void render(int mouseX, int mouseY, float delta) {
  26. drawCenteredString(font, text, x, y, -1);
  27. }
  28. }