CopyRecipeIdentifierToast.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Roughly Enough Items by Danielshe.
  3. * Licensed under the MIT License.
  4. */
  5. package me.shedaniel.rei.gui.toast;
  6. import com.mojang.blaze3d.systems.RenderSystem;
  7. import net.minecraft.client.MinecraftClient;
  8. import net.minecraft.client.toast.Toast;
  9. import net.minecraft.client.toast.ToastManager;
  10. import net.minecraft.util.Identifier;
  11. import javax.annotation.Nullable;
  12. public class CopyRecipeIdentifierToast implements Toast {
  13. protected static final Identifier TOASTS_TEX = new Identifier("roughlyenoughitems", "textures/gui/toasts.png");
  14. private String title;
  15. private String subtitle;
  16. private long startTime;
  17. public CopyRecipeIdentifierToast(String title, @Nullable String subtitleNullable) {
  18. this.title = title;
  19. this.subtitle = subtitleNullable;
  20. }
  21. public static void addToast(String title, @Nullable String subtitleNullable) {
  22. MinecraftClient.getInstance().getToastManager().add(new CopyRecipeIdentifierToast(title, subtitleNullable));
  23. }
  24. @Override
  25. public Visibility draw(ToastManager toastManager, long var2) {
  26. toastManager.getGame().getTextureManager().bindTexture(TOASTS_TEX);
  27. RenderSystem.color3f(1.0F, 1.0F, 1.0F);
  28. toastManager.blit(0, 0, 0, 0, 160, 32);
  29. if (this.subtitle == null) {
  30. toastManager.getGame().textRenderer.draw(this.title, 18.0F, 12.0F, 11141120);
  31. } else {
  32. toastManager.getGame().textRenderer.draw(this.title, 18.0F, 7.0F, 11141120);
  33. toastManager.getGame().textRenderer.draw(this.subtitle, 18.0F, 18.0F, -16777216);
  34. }
  35. return var2 - this.startTime < 5000L ? Visibility.SHOW : Visibility.HIDE;
  36. }
  37. @Override
  38. public Object getType() {
  39. return Type.THIS_IS_SURE_A_TYPE;
  40. }
  41. public enum Type {
  42. THIS_IS_SURE_A_TYPE
  43. }
  44. }