ClothConfigTabButton.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package me.shedaniel.clothconfig2.gui;
  2. import net.minecraft.client.gui.widget.AbstractPressableButtonWidget;
  3. public class ClothConfigTabButton extends AbstractPressableButtonWidget {
  4. private int index = -1;
  5. private ClothConfigScreen screen;
  6. public ClothConfigTabButton(ClothConfigScreen screen, int index, int int_1, int int_2, int int_3, int int_4, String string_1) {
  7. super(int_1, int_2, int_3, int_4, string_1);
  8. this.index = index;
  9. this.screen = screen;
  10. }
  11. @Override
  12. public void onPress() {
  13. if (index != -1)
  14. screen.nextTabIndex = index;
  15. screen.tabsScrollVelocity = 0d;
  16. screen.init();
  17. }
  18. @Override
  19. public void render(int int_1, int int_2, float float_1) {
  20. active = index != screen.selectedTabIndex;
  21. super.render(int_1, int_2, float_1);
  22. }
  23. @Override
  24. protected boolean clicked(double double_1, double double_2) {
  25. return visible && active && isMouseOver(double_1, double_2);
  26. }
  27. @Override
  28. public boolean isMouseOver(double double_1, double double_2) {
  29. return this.active && this.visible && double_1 >= this.x && double_2 >= this.y && double_1 < this.x + this.width && double_2 < this.y + this.height && double_1 >= 20 && double_1 < screen.width - 20;
  30. }
  31. }