Vaerys_Dawn

EffectComponent class

Feb 13th, 2021 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. public class EffectComponent implements ICustomComponent {
  2.  
  3.     IVariable effectID;
  4.     private transient TextureAtlasSprite effectSprite;
  5.     private transient Effect effect;
  6.     private transient static final ResourceLocation EFFECT_BACKGROUND = new ResourceLocation("patchouli", "textures/gui/crafting.png");
  7.  
  8.     @Override
  9.     public void build(int i, int i1, int i2) {
  10.         this.effect = ForgeRegistries.POTIONS.getValue(new ResourceLocation(effectID.asString()));
  11.         this.effectSprite = Minecraft.getInstance().getPotionSpriteUploader().getSprite(effect);
  12.     }
  13.  
  14.     private ITextComponent renderTooltip(Effect effect) {
  15.         IFormattableTextComponent iformattabletextcomponent = new TranslationTextComponent(effect.getName());
  16.         return iformattabletextcomponent;
  17.     }
  18.  
  19.     @Override
  20.     public void render(MatrixStack matrixStack, IComponentRenderContext context, float pticks, int mouseX, int mouseY) {
  21.         Minecraft.getInstance().getTextureManager().bindTexture(EFFECT_BACKGROUND);
  22.         AbstractGui.drawTexture(matrixStack, 0, 0, 1,99,64, 32, 128, 256);
  23.         Minecraft.getInstance().getTextureManager().bindTexture(this.effectSprite.getAtlas().getId());
  24.         AbstractGui.drawSprite(matrixStack, 0, 0, 1, 18, 18, this.effectSprite);
  25.     }
  26.  
  27.     @Override
  28.     public void onVariablesAvailable(UnaryOperator<IVariable> lookup) {
  29.         lookup.apply(effectID);
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment