Advertisement
Webadict

Untitled

Jul 1st, 2022
1,012
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.21 KB | None
  1. package buffingTheBasics.patches;
  2.  
  3. import basemod.BaseMod;
  4. import buffingTheBasics.BuffingTheBasicsMod;
  5. import buffingTheBasics.actions.ModifiedApplyPowerAction;
  6. import buffingTheBasics.cards.AbstractDualCard;
  7. import com.badlogic.gdx.Gdx;
  8. import com.badlogic.gdx.graphics.Texture;
  9. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  10. import com.evacipated.cardcrawl.modthespire.lib.*;
  11. import com.evacipated.cardcrawl.modthespire.patcher.PatchingException;
  12. import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
  13. import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
  14. import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
  15. import com.megacrit.cardcrawl.actions.utility.TextAboveCreatureAction;
  16. import com.megacrit.cardcrawl.cards.AbstractCard;
  17. import com.megacrit.cardcrawl.core.CardCrawlGame;
  18. import com.megacrit.cardcrawl.core.Settings;
  19. import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
  20. import com.megacrit.cardcrawl.helpers.ImageMaster;
  21. import com.megacrit.cardcrawl.powers.AbstractPower;
  22. import com.megacrit.cardcrawl.screens.SingleCardViewPopup;
  23. import javassist.CannotCompileException;
  24. import javassist.CtBehavior;
  25. import org.apache.logging.log4j.LogManager;
  26. import org.apache.logging.log4j.Logger;
  27.  
  28. import java.lang.reflect.Field;
  29. import java.util.ArrayList;
  30. import java.util.Arrays;
  31. import java.util.Map;
  32.  
  33. public class HalfBgPatch {
  34.     @SpirePatch(
  35.             clz = SingleCardViewPopup.class,
  36.             method = "renderCardBack"
  37.     )
  38.     public static class HalfBgTexture {
  39.         public HalfBgTexture() {
  40.         }
  41.  
  42.         public static void Postfix(Object __obj_instance, Object sbObject) {
  43.             try {
  44.                 SingleCardViewPopup popup = (SingleCardViewPopup) __obj_instance;
  45.                 SpriteBatch sb = (SpriteBatch) sbObject;
  46.                 Gdx.gl.glColorMask(false, false, false, true);
  47.                 Field cardField = popup.getClass().getDeclaredField("card");
  48.                 cardField.setAccessible(true);
  49.                 AbstractCard card = (AbstractCard) cardField.get(popup);
  50.                 if (card instanceof AbstractDualCard) {
  51.                     AbstractDualCard dualCard = (AbstractDualCard) card;
  52.                     AbstractCard.CardColor color = dualCard.secondaryColor;
  53.                     Texture bgTexture;
  54.                     switch (dualCard.type) {
  55.                         case ATTACK:
  56.                             bgTexture = dualCard.getHalfBackgroundLargeTexture();
  57.  
  58.                             if (bgTexture == null) {
  59.                                 bgTexture = BuffingTheBasicsMod.getAttackHalfBgPortraitTexture(color);
  60.                                 if (bgTexture == null) {
  61.                                     bgTexture = ImageMaster.loadImage(BuffingTheBasicsMod.getAttackHalfBgPortrait(color));
  62.                                     BuffingTheBasicsMod.saveAttackHalfBgPortraitTexture(color, bgTexture);
  63.                                 }
  64.                             }
  65.  
  66.                             sb.draw(bgTexture, (float) Settings.WIDTH / 2.0F - 512.0F, (float) Settings.HEIGHT / 2.0F - 512.0F, 512.0F, 512.0F, 1024.0F, 1024.0F, Settings.scale, Settings.scale, 0.0F, 0, 0, 1024, 1024, false, false);
  67.                             break;
  68.                         case POWER:
  69.                             bgTexture = dualCard.getHalfBackgroundLargeTexture();
  70.  
  71.                             if (bgTexture == null) {
  72.                                 bgTexture = BuffingTheBasicsMod.getPowerHalfBgPortraitTexture(color);
  73.                                 if (bgTexture == null) {
  74.                                     bgTexture = ImageMaster.loadImage(BuffingTheBasicsMod.getPowerHalfBgPortrait(color));
  75.                                     BuffingTheBasicsMod.savePowerHalfBgPortraitTexture(color, bgTexture);
  76.                                 }
  77.                             }
  78.  
  79.                             sb.draw(bgTexture, (float) Settings.WIDTH / 2.0F - 512.0F, (float) Settings.HEIGHT / 2.0F - 512.0F, 512.0F, 512.0F, 1024.0F, 1024.0F, Settings.scale, Settings.scale, 0.0F, 0, 0, 1024, 1024, false, false);
  80.                             break;
  81.                         default:
  82.                             bgTexture = dualCard.getHalfBackgroundLargeTexture();
  83.  
  84.                             if (bgTexture == null) {
  85.                                 bgTexture = BuffingTheBasicsMod.getSkillHalfBgPortraitTexture(color);
  86.                                 if (bgTexture == null) {
  87.                                     bgTexture = ImageMaster.loadImage(BuffingTheBasicsMod.getSkillHalfBgPortrait(color));
  88.                                     BuffingTheBasicsMod.saveSkillHalfBgPortraitTexture(color, bgTexture);
  89.                                 }
  90.                             }
  91.  
  92.                             sb.draw(bgTexture, (float) Settings.WIDTH / 2.0F - 512.0F, (float) Settings.HEIGHT / 2.0F - 512.0F, 512.0F, 512.0F, 1024.0F, 1024.0F, Settings.scale, Settings.scale, 0.0F, 0, 0, 1024, 1024, false, false);
  93.                     }
  94.                 }
  95.             } catch (SecurityException | IllegalAccessException | NoSuchFieldException var8) {
  96.                 var8.printStackTrace();
  97.             }
  98.         }
  99.     }
  100. }
Advertisement
RAW Paste Data Copied
Advertisement