Search in sources :

Example 6 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

the class GuiKeybindCheckBox method onMouseClicked.

@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
    if (button == 0) {
        super.onMouseClicked(mouseX, mouseY, button);
        GuiKeybindCheckBox trackedBox = trackedCheckboxes.get(keyBindingName);
        if (trackedBox != this) {
            trackedBox.onMouseClicked(mouseX, mouseY, button);
        } else {
            HelmetWidgetDefaults.INSTANCE.setKey(keyBindingName, checked);
            try {
                HelmetWidgetDefaults.INSTANCE.writeToFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
                if (("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).equals(keyBindingName)) {
                    NetworkHandler.sendToServer(new PacketToggleHelmetFeature((byte) i, GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && checked));
                }
            }
            if (keyBindingName.equals("pneumaticHelmet.upgrade.coreComponents")) {
                for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                    NetworkHandler.sendToServer(new PacketToggleHelmetFeature((byte) i, checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()).checked));
                }
            }
        }
    } else {
        isAwaitingKey = !isAwaitingKey;
        if (isAwaitingKey) {
            oldCheckboxText = text;
            text = "gui.setKeybind";
        } else {
            text = oldCheckboxText;
        }
    }
}
Also used : IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) PacketToggleHelmetFeature(me.desht.pneumaticcraft.common.network.PacketToggleHelmetFeature) IOException(java.io.IOException)

Aggregations

IUpgradeRenderHandler (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler)6 ArrayList (java.util.ArrayList)3 IGuiAnimatedStat (me.desht.pneumaticcraft.api.client.IGuiAnimatedStat)2 CommonHUDHandler (me.desht.pneumaticcraft.common.CommonHUDHandler)2 PacketToggleHelmetFeature (me.desht.pneumaticcraft.common.network.PacketToggleHelmetFeature)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 IOException (java.io.IOException)1 IOptionPage (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IOptionPage)1 INeedTickUpdate (me.desht.pneumaticcraft.client.gui.INeedTickUpdate)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1