WidgetArrow.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package me.shedaniel.gui.widget;
  2. import net.minecraft.client.Minecraft;
  3. import net.minecraft.client.renderer.GlStateManager;
  4. import net.minecraft.client.renderer.RenderHelper;
  5. import net.minecraft.util.ResourceLocation;
  6. public class WidgetArrow extends Control {
  7. private static final ResourceLocation RECIPE_GUI = new ResourceLocation("almostenoughitems", "textures/gui/recipecontainer.png");
  8. private int progress = 0;
  9. private int updateTick = 0;
  10. private boolean animated;
  11. public WidgetArrow(int x, int y, boolean animated) {
  12. super(x, y, 22, 18);
  13. this.animated = animated;
  14. }
  15. @Override
  16. public void draw() {
  17. GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
  18. RenderHelper.disableStandardItemLighting();
  19. Minecraft.getInstance().getTextureManager().bindTexture(RECIPE_GUI);
  20. this.drawTexturedModalRect(rect.x, rect.y, 18, 222, 22, 18);
  21. if (animated) {
  22. int width = (int) ((progress / 10f) * 22);
  23. this.drawTexturedModalRect(rect.x - 1, rect.y - 1, 40, 222, width, 18);
  24. }
  25. }
  26. @Override
  27. public void tick() {
  28. updateTick++;
  29. if (updateTick >= 20) {
  30. updateTick = 0;
  31. progress++;
  32. if (progress > 10)
  33. progress = 0;
  34. }
  35. }
  36. }