Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10.2] GUI don't refresh and repaint on resize
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
JimiIT92

[1.10.2] GUI don't refresh and repaint on resize

By JimiIT92, June 22, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

JimiIT92    19

JimiIT92

JimiIT92    19

  • Dragon Slayer
  • JimiIT92
  • Members
  • 19
  • 723 posts
Posted June 22, 2017

I have a GUI with some buttons in it, and when i click those buttons i want the gui to change appearance (basically some buttons will be replaced with others). How can i do so that the gui automatically refresh without closing it and reopening it to see the changes? Also i've noticed that the gui repaint itself when i resize the window, doing something like this
MgTIRet.png

How can i made so the gui doesn't do this every time i resize? This is my gui code, thanks in advance to everyone who will help me understand these problems :)

	package com.cf.gui;
	import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
	import org.lwjgl.opengl.GL11;
	import com.cf.CoreFaction;
import com.cf.network.GuiCoreAddExpansionServerMessage;
import com.cf.network.GuiCoreRemoveServerMessage;
import com.cf.network.GuiCoreSaveServerMessage;
import com.cf.utils.Settings;
import com.cf.utils.Utils;
	import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
	public class GuiCore extends GuiScreen {
    private static final ResourceLocation BG = new ResourceLocation(CoreFaction.MODID, "textures/gui/core.png");
	    private String territory;
    private String faction;
    private int coreLevel;
    private int expansions;
    private int primaryEffect;
    private int secondaryEffect;
    private int primaryLevel;
    private int secondaryLevel;
	    private GuiCore.UpgradeButton upgradeCoreButton;
    private GuiCore.ExpansionButton expansionButton;
    private GuiCore.RemoveButton removeButton;
	    private int guiLeft;
    private int guiTop;
    private int xSize = 256;
    private int ySize = 181;
    private ArrayList<AllyEffectButton> allyButtons = new ArrayList<AllyEffectButton>();
    private ArrayList<EnemyEffectButton> enemyButtons = new ArrayList<EnemyEffectButton>();
    private ArrayList<AllyActiveEffectButton> allyActiveButtons = new ArrayList<AllyActiveEffectButton>();
    private ArrayList<EnemyActiveEffectButton> enemyActiveButtons = new ArrayList<EnemyActiveEffectButton>();
    private ArrayList<Potion> allyEffects = new ArrayList<Potion>();
    private ArrayList<Potion> enemyEffects = new ArrayList<Potion>();
    private int maxCoreLevel = 10;
	    public GuiCore(String t, String f, int l, int e, int e1, int e2, int l1, int l2) {
        this.territory = t;
        this.faction = f;
        this.coreLevel = l;
        this.expansions = e;
        this.primaryEffect = e1;
        this.secondaryEffect = e2;
        this.primaryLevel = l1;
        this.secondaryLevel = l2;
    }
	    @Override
    public void initGui() {
        this.guiLeft = (this.width - xSize) / 2;
        this.guiTop = (this.height - ySize) / 2;
        this.upgradeCoreButton = new GuiCore.UpgradeButton(-1, this.guiLeft + 19, this.guiTop + 144);
        this.expansionButton = new GuiCore.ExpansionButton(-2, this.guiLeft + 116, this.guiTop + 144);
        this.removeButton = new GuiCore.RemoveButton(-3, this.guiLeft + 213, this.guiTop + 144);
	        this.buttonList.add(upgradeCoreButton);
        this.buttonList.add(expansionButton);
        this.buttonList.add(removeButton);
	        this.allyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.JUMP_BOOST)));
        this.allyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.SPEED)));
        this.allyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.RESISTANCE)));
        this.allyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.HASTE)));
        this.allyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.ABSORPTION)));
	        this.enemyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.HUNGER)));
        this.enemyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.WEAKNESS)));
        this.enemyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.SLOWNESS)));
        this.enemyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.BLINDNESS)));
        this.enemyEffects.add(Potion.getPotionById(Potion.getIdFromPotion(MobEffects.MINING_FATIGUE)));
	        for (int i = 0; i < 5; i++) {
            this.allyButtons.add(
                    new AllyEffectButton(i, this.guiLeft + 11 + 5, this.guiTop + 20 + (24 * i), allyEffects.get(i), 0));
            this.allyActiveButtons.add(new AllyActiveEffectButton(i, this.guiLeft + 11 + 5, this.guiTop + 20 + (24 * i),
                    allyEffects.get(i), 0));
            this.enemyButtons.add(new EnemyEffectButton(i + 5, this.guiLeft + (this.xSize - 106 - 11 - 5),
                    this.guiTop + 20 + (24 * i), enemyEffects.get(i), 0));
            this.enemyActiveButtons.add(new EnemyActiveEffectButton(i + 5, this.guiLeft + (this.xSize - 106 - 11 - 5),
                    this.guiTop + 20 + (24 * i), enemyEffects.get(i), 0));
        }
	        this.buttonList.addAll(allyButtons);
        this.buttonList.addAll(enemyButtons);
    }
	    @Override
    public void updateScreen() {
        if (this.primaryLevel != -999) {
            for (int i = 0; i < allyEffects.size(); i++) {
                if (Potion.getIdFromPotion(allyEffects.get(i)) == this.primaryEffect) {
                    this.buttonList.remove(allyButtons.get(i));
                    this.buttonList.add(allyActiveButtons.get(i));
                }
            }
            for (int i = 0; i < enemyEffects.size(); i++) {
                if (Potion.getIdFromPotion(enemyEffects.get(i)) == this.primaryEffect) {
                    this.buttonList.remove(enemyEffects.get(i));
                    this.buttonList.add(enemyActiveButtons.get(i));
                }
            }
        }
        if (this.secondaryLevel != -999) {
            for (int i = 0; i < enemyEffects.size(); i++) {
                if (Potion.getIdFromPotion(enemyEffects.get(i)) == this.secondaryEffect) {
                    this.buttonList.remove(enemyButtons.get(i));
                    this.buttonList.add(enemyActiveButtons.get(i));
                }
            }
            for (int i = 0; i < enemyEffects.size(); i++) {
                if (Potion.getIdFromPotion(enemyEffects.get(i)) == this.secondaryEffect) {
                    this.buttonList.remove(enemyEffects.get(i));
                    this.buttonList.add(enemyActiveButtons.get(i));
                }
            }
        }
        super.updateScreen();
    }
	    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        this.mc.getTextureManager().bindTexture(getBg());
        this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 256, 181);
        String terr = Utils.getTranslation("gui.core.territory", TextFormatting.GREEN);
        terr += ": " + territory;
        if (terr.length() >= 38) {
            if (coreLevel == maxCoreLevel) {
                this.fontRendererObj.drawString(terr.substring(0, 37) + "...", this.guiLeft + 19, this.guiTop + 10,
                        4210752);
                this.fontRendererObj.drawString(" | " + Utils.getTranslation("gui.core.level", TextFormatting.GOLD)
                        + ": " + String.valueOf(coreLevel), this.guiLeft + this.xSize - 64, this.guiTop + 10, 4210752);
            } else {
                this.fontRendererObj.drawString(terr.substring(0, 38) + "...", this.guiLeft + 19, this.guiTop + 10,
                        4210752);
                this.fontRendererObj.drawString(" | " + Utils.getTranslation("gui.core.level", TextFormatting.GOLD)
                        + ": " + String.valueOf(coreLevel), this.guiLeft + this.xSize - 58, this.guiTop + 10, 4210752);
            }
        } else {
            this.fontRendererObj.drawString(terr, this.guiLeft + 19, this.guiTop + 10, 4210752);
            this.fontRendererObj.drawString(
                    " | " + Utils.getTranslation("gui.core.level", TextFormatting.GOLD) + ": "
                            + String.valueOf(coreLevel),
                    coreLevel == maxCoreLevel ? this.guiLeft + this.xSize - 64 : this.guiLeft + this.xSize - 58,
                    this.guiTop + 10, 4210752);
        }
	        for (int i = 0; i < this.buttonList.size(); ++i) {
            ((GuiButton) this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY);
        }
	        for (int i = 0; i < this.buttonList.size(); ++i) {
            if (this.buttonList.get(i) instanceof AllyActiveEffectButton
                    || this.buttonList.get(i) instanceof AllyEffectButton)
                this.drawString(Minecraft.getMinecraft().fontRendererObj,
                        Utils.getTranslation(((HoverEffectButton) this.buttonList.get(i)).getEffect()) + " "
                                + (((HoverEffectButton) this.buttonList.get(i)).getTier() == 0 ? ""
                                        : (((HoverEffectButton) this.buttonList.get(i)).getTier() + 1)),
                        ((HoverEffectButton) this.buttonList.get(i)).xPosition + 25,
                        ((HoverEffectButton) this.buttonList.get(i)).yPosition + 7, 0xFFFFFF);
            else if (this.buttonList.get(i) instanceof EnemyActiveEffectButton
                    || this.buttonList.get(i) instanceof EnemyEffectButton)
                this.drawString(Minecraft.getMinecraft().fontRendererObj,
                        Utils.getTranslation(((HoverEffectButton) this.buttonList.get(i)).getEffect()) + " "
                                + (((HoverEffectButton) this.buttonList.get(i)).getTier() == 0 ? ""
                                        : (((HoverEffectButton) this.buttonList.get(i)).getTier() + 1)),
                        ((HoverEffectButton) this.buttonList.get(i)).xPosition + 5,
                        ((HoverEffectButton) this.buttonList.get(i)).yPosition + 7, 0xFFFFFF);
        }
	        this.mc.getTextureManager().bindTexture(getBg());
	        if (coreLevel < Settings.expansionLevel || expansions >= Settings.maxPurchasableExpansions)
            this.expansionButton.setEnabled(false);
	        if (coreLevel == maxCoreLevel)
            this.upgradeCoreButton.setEnabled(false);
	        if (this.coreLevel < 2) {
            this.drawTexturedModalRect(this.allyButtons.get(0).xPosition + 3, this.allyButtons.get(0).yPosition + 2, 0,
                    192, 18, 18);
            this.drawTexturedModalRect(this.enemyButtons.get(0).xPosition + 84, this.enemyButtons.get(0).yPosition + 2,
                    0, 192, 18, 18);
            this.allyButtons.get(0).setEnabled(false);
            this.enemyButtons.get(0).setEnabled(false);
        }
        if (this.coreLevel < 4) {
            this.drawTexturedModalRect(this.allyButtons.get(1).xPosition + 3, this.allyButtons.get(1).yPosition + 2, 0,
                    192, 16, 18);
            this.drawTexturedModalRect(this.enemyButtons.get(1).xPosition + 84, this.enemyButtons.get(1).yPosition + 2,
                    0, 192, 16, 18);
            this.allyButtons.get(1).setEnabled(false);
            this.enemyButtons.get(1).setEnabled(false);
        }
        if (this.coreLevel < 6) {
            this.drawTexturedModalRect(this.allyButtons.get(2).xPosition + 3, this.allyButtons.get(2).yPosition + 2, 0,
                    192, 16, 18);
            this.drawTexturedModalRect(this.enemyButtons.get(2).xPosition + 84, this.enemyButtons.get(2).yPosition + 2,
                    0, 192, 16, 18);
            this.allyButtons.get(2).setEnabled(false);
            this.enemyButtons.get(2).setEnabled(false);
        }
        if (this.coreLevel <  {
            this.drawTexturedModalRect(this.allyButtons.get(3).xPosition + 3, this.allyButtons.get(3).yPosition + 2, 0,
                    192, 16, 18);
            this.drawTexturedModalRect(this.enemyButtons.get(3).xPosition + 84, this.enemyButtons.get(3).yPosition + 2,
                    0, 192, 16, 18);
            this.allyButtons.get(3).setEnabled(false);
            this.enemyButtons.get(3).setEnabled(false);
        }
        if (this.coreLevel < 10) {
            this.drawTexturedModalRect(this.allyButtons.get(4).xPosition + 3, this.allyButtons.get(4).yPosition + 2, 0,
                    192, 16, 18);
            this.drawTexturedModalRect(this.enemyButtons.get(4).xPosition + 84, this.enemyButtons.get(4).yPosition + 2,
                    0, 192, 16, 18);
            this.allyButtons.get(4).setEnabled(false);
            this.enemyButtons.get(4).setEnabled(false);
        }
	        for (GuiButton button : this.buttonList) {
            if (button.isMouseOver()) {
                if (button instanceof HoverEffectButton) {
                    this.zLevel = 100;
                    if (button.enabled) {
                        this.drawCreativeTabHoveringText(((HoverEffectButton) button).getHoverText(), mouseX, mouseY);
                    } else {
                        if (button.id == 0 || button.id == 5)
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.unlock.2"), mouseX, mouseY);
                        else if (button.id == 1 || button.id == 6)
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.unlock.4"), mouseX, mouseY);
                        else if (button.id == 2 || button.id == 7)
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.unlock.6"), mouseX, mouseY);
                        else if (button.id == 3 || button.id == 
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.unlock.8"), mouseX, mouseY);
                        else if (button.id == 4 || button.id == 9)
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.unlock.10"), mouseX,
                                    mouseY);
                    }
                    this.zLevel = 0;
                } else {
                    if (button.id == -1) {
                        if (coreLevel < maxCoreLevel) {
                            int g = Settings.baseUpgradeCost * coreLevel;
                            String up = Utils.getTranslation("gui.core.upgrade", TextFormatting.GOLD) + " "
                                    + String.valueOf(coreLevel + 1);
                            String down = (g != 0
                                    ? String.valueOf(g) + Utils.getTranslation("gui.core.gemstones", TextFormatting.LIGHT_PURPLE)
                                    : "");
                            this.drawHoveringText(Arrays.<String>asList(up, down), mouseX, mouseY);
                        } else
                            this.drawCreativeTabHoveringText(
                                    Utils.getTranslation("gui.core.upgrade.max", TextFormatting.RED), mouseX, mouseY);
                    } else if (button.id == -2) {
                        if (coreLevel >= Settings.expansionLevel) {
                            if (this.expansions < Settings.maxPurchasableExpansions) {
                                int g = Settings.expansionBaseCost.getGold() * (expansions + 1);
                                int s = Settings.expansionBaseCost.getSilver() * (expansions + 1);
                                int c = Settings.expansionBaseCost.getCopper() * (expansions + 1);
                                String up = Utils.getTranslation("gui.core.expansion", TextFormatting.GREEN) + " ("
                                        + Utils.getTranslation("gui.core.purchased") + ": " + String.valueOf(expansions)
                                        + "/" + String.valueOf(Settings.maxPurchasableExpansions) + ")";
                                String down = (g != 0 ? String.valueOf(g)
                                        + Utils.getTranslation("gui.core.golds", TextFormatting.YELLOW) : "")
                                        + (s != 0
                                                ? String.valueOf(s)
                                                        + Utils.getTranslation("gui.core.silvers", TextFormatting.GRAY)
                                                : "")
                                        + (c != 0 ? String.valueOf(c)
                                                + Utils.getTranslation("gui.core.coppers", TextFormatting.DARK_RED)
                                                : "");
                                this.drawHoveringText(Arrays.<String>asList(up, down), mouseX, mouseY);
                            } else
                                this.drawCreativeTabHoveringText(
                                        Utils.getTranslation("gui.core.expansion.max", TextFormatting.RED), mouseX,
                                        mouseY);
                        } else
                            this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.expansion.locked") + " "
                                    + String.valueOf(Settings.expansionLevel), mouseX, mouseY);
                    } else if (button.id == -3) {
                        String up = Utils.getTranslation("gui.core.remove", TextFormatting.RED);
                        String down = Utils.getTranslation("gui.core.remove.back");
                        this.drawHoveringText(Arrays.<String>asList(up, down), mouseX, mouseY);
                    }
                }
            }
        }
    }
	    @Override
    protected void actionPerformed(GuiButton button) throws IOException {
        if (button.enabled) {
            int id = button.id;
            if (id == -1) {
                int g = Settings.baseUpgradeCost * coreLevel;
                if (Utils.canPayGemstones(this.mc.thePlayer, g) && coreLevel < 10) {
                    Utils.payGemstones(this.mc.thePlayer, g);
                    coreLevel++;
                    if (coreLevel >= maxCoreLevel / 2 && coreLevel < maxCoreLevel) {
                        primaryLevel = 2;
                        secondaryLevel = 2;
                    } else if (coreLevel == maxCoreLevel) {
                        primaryLevel = 3;
                        secondaryLevel = 3;
                    }
                    Utils.sendMessage(this.mc.thePlayer,
                            Utils.getTranslation("gui.core.upgrade.success", TextFormatting.GREEN));
                    CoreFaction.NETWORK.sendToServer(new GuiCoreSaveServerMessage(this.territory,
                            String.valueOf(this.coreLevel), String.valueOf(this.expansions), String.valueOf(this.primaryEffect),
                            String.valueOf(this.secondaryEffect), String.valueOf(this.primaryLevel),
                            String.valueOf(this.secondaryLevel)));
                } else
                    Utils.sendMessage(this.mc.thePlayer,
                            Utils.getTranslation("gui.core.upgrade.fail", TextFormatting.RED));
                this.mc.displayGuiScreen((GuiScreen)null);
            } else if (id == -2) {
                int g = Settings.expansionBaseCost.getGold() * expansions;
                int s = Settings.expansionBaseCost.getSilver() * expansions;
                int c = Settings.expansionBaseCost.getCopper() * expansions;
                if (Utils.canPay(this.mc.thePlayer, g, s, c) && coreLevel >= Settings.expansionLevel
                        && this.expansions < Settings.maxPurchasableExpansions) {
                    Utils.pay(this.mc.thePlayer, g, s, c);
                    CoreFaction.NETWORK.sendToServer(new GuiCoreAddExpansionServerMessage(territory));
                    expansions++;
                    Utils.sendMessage(this.mc.thePlayer,
                            Utils.getTranslation("gui.core.expansion.success", TextFormatting.GREEN));
                } else {
                    this.mc.displayGuiScreen((GuiScreen)null);
                    Utils.sendMessage(this.mc.thePlayer,
                            Utils.getTranslation("gui.core.expansion.fail", TextFormatting.RED));
                }
                
            } else if (id == -3) {
                CoreFaction.NETWORK.sendToServer(new GuiCoreRemoveServerMessage(territory, faction));
                Utils.sendMessage(this.mc.thePlayer,
                        Utils.getTranslation("gui.core.remove.success", TextFormatting.RED));
                this.mc.displayGuiScreen((GuiScreen) null);
                return;
            } else if (id == 0) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(allyEffects.get(0)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(allyEffects.get(0)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(0));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(allyEffects.get(0)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(0));
                }
            } else if (id == 1) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(allyEffects.get(1)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(allyEffects.get(1)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(1));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(allyEffects.get(1)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(1));
                }
            } else if (id == 2) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(allyEffects.get(2)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(allyEffects.get(2)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(2));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(allyEffects.get(2)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(2));
                }
            } else if (id == 3) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(allyEffects.get(3)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(allyEffects.get(3)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(3));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(allyEffects.get(3)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(3));
                }
            } else if (id == 4) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(allyEffects.get(4)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(allyEffects.get(4)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(4));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(allyEffects.get(4)) ? -999
                            : Potion.getIdFromPotion(allyEffects.get(4));
                }
            } else if (id == 5) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(enemyEffects.get(0)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(enemyEffects.get(0)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(0));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(enemyEffects.get(0)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(0));
                }
            } else if (id == 6) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(enemyEffects.get(1)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(enemyEffects.get(1)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(1));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(enemyEffects.get(1)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(1));
                }
            } else if (id == 7) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(enemyEffects.get(2)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(enemyEffects.get(2)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(2));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(enemyEffects.get(2)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(2));
                }
	            } else if (id ==  {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(enemyEffects.get(3)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(enemyEffects.get(3)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(3));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(enemyEffects.get(3)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(3));
                }
            } else if (id == 9) {
                if(this.primaryEffect != -999 && this.primaryEffect != Potion.getIdFromPotion(enemyEffects.get(4)) && coreLevel == maxCoreLevel) {
                    this.secondaryEffect = this.secondaryEffect == Potion.getIdFromPotion(enemyEffects.get(4)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(4));
                } else {
                    this.primaryEffect = this.primaryEffect == Potion.getIdFromPotion(enemyEffects.get(4)) ? -999
                            : Potion.getIdFromPotion(enemyEffects.get(4));
                }
                
            }
            CoreFaction.NETWORK.sendToServer(new GuiCoreSaveServerMessage(this.territory,
                    String.valueOf(this.coreLevel), String.valueOf(this.expansions), String.valueOf(this.primaryEffect),
                    String.valueOf(this.secondaryEffect), String.valueOf(this.primaryLevel),
                    String.valueOf(this.secondaryLevel)));
        }
        super.actionPerformed(button);
    }
	    @Override
    public boolean doesGuiPauseGame() {
        return false;
    }
	    public static ResourceLocation getBg() {
        return BG;
    }
	    @SideOnly(Side.CLIENT)
    class UpgradeButton extends ActionButton {
        public UpgradeButton(int buttonId, int x, int y) {
            super(buttonId, x, y, GuiCore.getBg(), 0, 237);
        }
	        public void drawButtonForegroundLayer(int mouseX, int mouseY) {
            GuiCore.this.drawCreativeTabHoveringText(
                    Utils.getTranslation("gui.core.upgrade", TextFormatting.GOLD) + "\n" + "Test", mouseX, mouseY);
        }
    }
	    @SideOnly(Side.CLIENT)
    class ExpansionButton extends ActionButton {
        public ExpansionButton(int buttonId, int x, int y) {
            super(buttonId, x, y, GuiCore.getBg(), 0, 237);
        }
	        public void drawButtonForegroundLayer(int mouseX, int mouseY) {
            GuiCore.this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.expansion", TextFormatting.GREEN),
                    mouseX, mouseY);
        }
    }
	    @SideOnly(Side.CLIENT)
    class RemoveButton extends ActionButton {
        public RemoveButton(int buttonId, int x, int y) {
            super(buttonId, x, y, GuiCore.getBg(), 23, 210);
        }
	        public void drawButtonForegroundLayer(int mouseX, int mouseY) {
            GuiCore.this.drawCreativeTabHoveringText(Utils.getTranslation("gui.core.remove", TextFormatting.RED),
                    mouseX, mouseY);
        }
    }
}

  • Quote

Share this post


Link to post
Share on other sites

JimiIT92    19

JimiIT92

JimiIT92    19

  • Dragon Slayer
  • JimiIT92
  • Members
  • 19
  • 723 posts
Posted July 8, 2017

Up

  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    386

V0idWa1k3r

V0idWa1k3r    386

  • World Shaper
  • V0idWa1k3r
  • Members
  • 386
  • 1773 posts
Posted July 8, 2017 (edited)

Clear the relevant lists in your initGui method. By default vanilla clears the button list on gui's resize. If you setup something else in that method you need to clear it beforehand too or you end up with stuff duplicating in your lists.

To clarify:

On 6/23/2017 at 0:49 AM, JimiIT92 said:

this.buttonList.addAll(allyButtons);         this.buttonList.addAll(enemyButtons);

This is your culprit. The butonList is cleared before initGui is called, but your allyButtons and enemyButtons are not.

Edited July 8, 2017 by V0idWa1k3r
  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • AdieCraft
      Japanese Style Temple Base

      By AdieCraft · Posted 1 hour ago

      Hello there!   Check out my latest tutorial in my Japanese Builds series, building a Japanese Temple base.   Make sure to Subscribe, so you don't miss any future videos.   Thanks   Adie   Japanese Style Temple Base    
    • DaemonUmbra
      Forge crashes on start

      By DaemonUmbra · Posted 1 hour ago

      Forge for 1.13+ requires Java 8-10 Forge for 1.12.2- requires Java 8
    • GttiqwT
      [1.12.2] Multiple Structure Generation

      By GttiqwT · Posted 2 hours ago

      Yeah I get where you're coming from. I also watched harry talk's tutorial and at first it worked but then I got the problem that it wont spawn more than one structure otherwise it'll overlap and only spawn the latest one added. I tried to follow this tutorial again and it just didnt seem to work at all now. When I get more time ill have to do it again and then afterwards try and fix the issues with spawning more than one structure. I'm currently trying to fix the issue where it causes cascading gen lag but I dont know how to fix that quite yet either.
    • Draco18s
      Distinguish singleplayer vs. multiplayer

      By Draco18s · Posted 2 hours ago

      No. Your client code is sending information to make the server do things. Your server code is telling the server to do those same things (again).
    • solitone
      Distinguish singleplayer vs. multiplayer

      By solitone · Posted 2 hours ago

      This isn’t an issue but normal behaviour, is it?
  • Topics

    • AdieCraft
      0
      Japanese Style Temple Base

      By AdieCraft
      Started 1 hour ago

    • bitman
      1
      Forge crashes on start

      By bitman
      Started 2 hours ago

    • Merthew
      7
      [1.12.2] Multiple Structure Generation

      By Merthew
      Started November 7, 2018

    • solitone
      24
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • TheGreenSquarez
      5
      Forge 28.1.10 won't show on launcher + 28.1.0 fails to work

      By TheGreenSquarez
      Started Wednesday at 11:21 AM

  • Who's Online (See full list)

    • jbredwards
    • DaemonUmbra
    • Choonster
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10.2] GUI don't refresh and repaint on resize
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community