Search in sources :

Example 1 with PortalCoords

use of uk.co.wehavecookies56.kk.common.util.PortalCoords in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class InputHandler method commandEnter.

public void commandEnter() {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    World world = mc.world;
    PlayerStatsCapability.IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
    IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
    loadLists();
    switch(GuiCommandMenu.selected) {
        case GuiCommandMenu.ATTACK:
            player.swingArm(EnumHand.MAIN_HAND);
            if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
                // Submenu of the portals
                if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
                    if (!this.portalCommands.isEmpty() && !STATS.getRecharge()) {
                        GuiCommandMenu.submenu = GuiCommandMenu.SUB_PORTALS;
                        GuiCommandMenu.portalSelected = 0;
                        world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
                    } else {
                        GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                        world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                    }
                    return;
                }
            }
            if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Wisdom)) {
                PacketDispatcher.sendToServer(new MagicWisdomShot());
            }
            break;
        case GuiCommandMenu.MAGIC:
            if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
                if (!STATS.getRecharge() && (!this.magicCommands.isEmpty() && !DRIVE.getActiveDriveName().equals(Strings.Form_Valor))) {
                    GuiCommandMenu.magicselected = 0;
                    GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAGIC;
                    world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
                    return;
                } else {
                    GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                    world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                }
            }
            break;
        case GuiCommandMenu.ITEMS:
            if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
                if (!this.itemsCommands.isEmpty()) {
                    GuiCommandMenu.submenu = GuiCommandMenu.SUB_ITEMS;
                    GuiCommandMenu.potionselected = 0;
                    world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
                } else {
                    GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                    world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                }
                return;
            }
            break;
        case GuiCommandMenu.DRIVE:
            if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
                if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
                    // TODO Use Limit
                    player.sendMessage(new TextComponentString("Limits are not available yet"));
                    GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
                    GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                    world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                } else {
                    if (DRIVE.getInDrive()) {
                        // Revert
                        if (DRIVE.getActiveDriveName().equals(Strings.Form_Anti) && !player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
                            GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                            world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                            player.sendMessage(new TextComponentTranslation("Cannot revert while in Anti form"));
                        } else {
                            PacketDispatcher.sendToServer(new DriveFormPacket(DRIVE.getActiveDriveName(), true));
                            if (DriveFormRegistry.isDriveFormRegistered(DRIVE.getActiveDriveName()))
                                DriveFormRegistry.get(DRIVE.getActiveDriveName()).endDrive(player);
                            GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
                            GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                            world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
                        }
                    } else if (this.driveCommands.isEmpty() || DRIVE.getDP() <= 0) {
                        world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
                        GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                    } else {
                        GuiCommandMenu.driveselected = 0;
                        GuiCommandMenu.submenu = GuiCommandMenu.SUB_DRIVE;
                        world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
                        return;
                    }
                }
            }
            break;
    }
    // Portal Submenu
    if (GuiCommandMenu.selected == GuiCommandMenu.ATTACK && GuiCommandMenu.submenu == GuiCommandMenu.SUB_PORTALS) {
        if (this.portalCommands.isEmpty()) {
        } else {
            // ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
            if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).getRecharge()) {
                PortalCoords coords = this.portalCommands.get((byte) GuiCommandMenu.portalSelected);
                if (coords.getX() != 0 && coords.getY() != 0 && coords.getZ() != 0) {
                    // ValidPortal
                    summonPortal(player, coords);
                } else {
                    player.sendMessage(new TextComponentString(TextFormatting.RED + "You don't have any portal destination"));
                }
                GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
                GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
                world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
            }
        }
    }
    // Magic Submenu
    if (GuiCommandMenu.selected == GuiCommandMenu.MAGIC && GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAGIC) {
        if (this.magicCommands.isEmpty()) {
        } else if (!STATS.getRecharge() || Constants.getCost((String) this.magicCommands.get(GuiCommandMenu.magicselected)) == -1 && STATS.getMP() > 0) {
            Magic.getMagic(player, world, (String) this.magicCommands.get(GuiCommandMenu.magicselected));
            GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
            GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
            world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
        }
    }
    if (GuiCommandMenu.selected == GuiCommandMenu.ITEMS && GuiCommandMenu.submenu == GuiCommandMenu.SUB_ITEMS) {
        if (this.itemsCommands.isEmpty()) {
        } else if (!this.itemsCommands.isEmpty()) {
            ItemKKPotion.getItem(player, world, (String) this.itemsCommands.get(GuiCommandMenu.potionselected), GuiCommandMenu.potionselected);
            GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
            GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
            world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
        }
    }
    if (GuiCommandMenu.selected == GuiCommandMenu.DRIVE && GuiCommandMenu.submenu == GuiCommandMenu.SUB_DRIVE) {
        if (this.driveCommands.isEmpty()) {
        } else if ((DRIVE.getDP() >= Constants.getCost((String) this.driveCommands.get(GuiCommandMenu.driveselected)))) {
            if (this.driveCommands.get(GuiCommandMenu.driveselected).equals(Strings.Form_Final)) {
                ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
            } else {
                if (!antiFormCheck()) {
                    ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
                }
            }
            GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
            GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
            world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
        }
    }
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) MagicWisdomShot(uk.co.wehavecookies56.kk.common.network.packet.server.magics.MagicWisdomShot) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with PortalCoords

use of uk.co.wehavecookies56.kk.common.util.PortalCoords in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class InputHandler method loadLists.

public void loadLists() {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    PlayerStatsCapability.IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
    IDriveState DS = player.getCapability(ModCapabilities.DRIVE_STATE, null);
    this.magicCommands = new ArrayList<String>();
    this.itemsCommands = new ArrayList<String>();
    this.driveCommands = new ArrayList<String>();
    this.portalCommands = new ArrayList<PortalCoords>();
    this.magicCommands.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i), ItemStack.EMPTY))
        this.magicCommands.add(((ItemSpellOrb) Minecraft.getMinecraft().player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i).getItem()).getMagicName());
    this.itemsCommands.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getStackInSlot(i), ItemStack.EMPTY))
        this.itemsCommands.add(((ItemKKPotion) Minecraft.getMinecraft().player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getStackInSlot(i).getItem()).getUnlocalizedName().substring(5));
    this.driveCommands.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i), ItemStack.EMPTY))
        this.driveCommands.add(((ItemDriveForm) Minecraft.getMinecraft().player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i).getItem()).getDriveFormName());
    this.portalCommands.clear();
    for (byte i = 0; i < 3; i++) {
        PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
        if (!(coords.getX() == 0 && coords.getY() == 0 && coords.getZ() == 0)) {
            this.portalCommands.add(coords);
            System.out.println(i + " Added portal: " + coords.getPID());
        }
    }
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) ItemKKPotion(uk.co.wehavecookies56.kk.common.item.base.ItemKKPotion) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) Minecraft(net.minecraft.client.Minecraft) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)

Example 3 with PortalCoords

use of uk.co.wehavecookies56.kk.common.util.PortalCoords in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class BlockOrgPortal method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        byte index = -1;
        if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
            if (world.getTileEntity(pos) instanceof TileEntityOrgPortal) {
                TileEntityOrgPortal te = (TileEntityOrgPortal) world.getTileEntity(pos);
                if (te.getOwner() == null) {
                    te.setOwner(player);
                    te.markDirty();
                    for (byte i = 0; i < 3; i++) {
                        PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
                        // System.out.println(i+" "+coords.getX());
                        if (coords.getX() == 0.0D && coords.getY() == 0.0D && coords.getZ() == 0.0D) {
                            index = i;
                            break;
                        }
                    }
                    // System.out.println("A: "+index);
                    if (index != -1) {
                        player.sendMessage(new TextComponentString(TextFormatting.GREEN + "This is now " + player.getDisplayNameString() + "'s portal " + (index + 1)));
                        player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setPortalCoords((byte) index, new PortalCoords((byte) index, pos.getX(), pos.getY(), pos.getZ(), player.dimension));
                        System.out.println(index + " " + player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(index).getDimID());
                        PacketDispatcher.sendTo(new SyncOrgXIIIData(player.getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) player);
                    } else {
                        player.sendMessage(new TextComponentString(TextFormatting.RED + "You have no empty slots for portals"));
                    }
                    return true;
                } else if (te.getOwner().equals(player.getDisplayNameString())) {
                    player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "This is your portal " + index));
                } else {
                    player.sendMessage(new TextComponentString(TextFormatting.RED + "This portal belongs to " + te.getOwner()));
                    return false;
                }
            }
        }
    }
    return false;
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) TileEntityOrgPortal(uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 4 with PortalCoords

use of uk.co.wehavecookies56.kk.common.util.PortalCoords in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class BlockOrgPortal method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    if (!world.isRemote) {
        if (world.getTileEntity(pos) instanceof TileEntityOrgPortal) {
            TileEntityOrgPortal te = (TileEntityOrgPortal) world.getTileEntity(pos);
            if (te.getOwner() != null) {
                EntityPlayer player = world.getPlayerEntityByName(te.getOwner());
                byte index = -1;
                for (byte i = 0; i < 3; i++) {
                    PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
                    if (coords.getX() == pos.getX() && coords.getY() == pos.getY() && coords.getZ() == pos.getZ()) {
                        index = i;
                        break;
                    }
                }
                System.out.println("R: " + index);
                if (index != -1) {
                    player.sendMessage(new TextComponentString(TextFormatting.RED + "Portal destination disappeared"));
                    player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setPortalCoords((byte) index, new PortalCoords((byte) index, 0, 0, 0, 0));
                } else {
                    player.sendMessage(new TextComponentString(TextFormatting.RED + "You have no empty slots for portals"));
                }
                PacketDispatcher.sendTo(new SyncOrgXIIIData(player.getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) player);
            }
        }
    }
    super.breakBlock(world, pos, state);
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityOrgPortal(uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with PortalCoords

use of uk.co.wehavecookies56.kk.common.util.PortalCoords in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiCommandMenu method drawCommandMenu.

public void drawCommandMenu(int width, int height) {
    int extraY = 0;
    if (Minecraft.getMinecraft().player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
        extraY = 45;
    }
    int alpha = MainConfig.client.hud.guiAlpha;
    EntityPlayer player = Minecraft.getMinecraft().player;
    IDriveState DS = mc.player.getCapability(ModCapabilities.DRIVE_STATE, null);
    PlayerStatsCapability.IPlayerStats STATS = mc.player.getCapability(ModCapabilities.PLAYER_STATS, null);
    this.spells = new ArrayList<String>();
    this.items = new ArrayList<String>();
    this.driveCommands = new ArrayList<String>();
    this.portalCommands = new ArrayList<PortalCoords>();
    this.spells.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i), ItemStack.EMPTY))
        this.spells.add(((ItemSpellOrb) Minecraft.getMinecraft().player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i).getItem()).getMagicName());
    this.items.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getStackInSlot(i), ItemStack.EMPTY))
        this.items.add(((ItemKKPotion) Minecraft.getMinecraft().player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getStackInSlot(i).getItem()).getUnlocalizedName().substring(5));
    this.driveCommands.clear();
    for (int i = 0; i < player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getSlots(); i++) if (!ItemStack.areItemStacksEqual(Minecraft.getMinecraft().player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i), ItemStack.EMPTY))
        this.driveCommands.add(((ItemDriveForm) Minecraft.getMinecraft().player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i).getItem()).getDriveFormName());
    this.portalCommands.clear();
    for (byte i = 0; i < 3; i++) {
        PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
        // System.out.println(i+" "+coords);
        if (coords != null) {
            if (!(coords.getX() == 0 && coords.getY() == 0 && coords.getZ() == 0)) {
                this.portalCommands.add(coords);
            }
        }
    }
    float scale = 1.05f;
    int colour;
    // DRIVE
    GL11.glPushMatrix();
    {
        GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
        int u;
        int v = 0;
        int x = 0;
        mc.renderEngine.bindTexture(texture);
        GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * DRIVE), 0);
        GL11.glScalef(scale, scale, scale);
        if (submenu != 0)
            GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
        if (selected == DRIVE) {
            // Selected
            textX = 5;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(5, 0, TOP_WIDTH, 30 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(5, 0, TOP_WIDTH, MENU_HEIGHT + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        } else {
            // Not selected
            textX = 0;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(0, 0, 0, 30, TOP_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        }
        if (this.submenu == 0) {
            if (DS.getInDrive()) {
                if (DS.getActiveDriveName().equals(Strings.Form_Anti))
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Drive_Revert), 6 + textX, 4, 0x888888);
                else
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Drive_Revert), 6 + textX, 4, 0xFFFFFF);
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            } else if (this.driveCommands.isEmpty() || DS.getDP() <= 0) {
                if (extraY == 45)
                    // 0xFFFFFF
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Limit), 6 + textX, 4, 0x888888);
                else
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Drive), 6 + textX, 4, 0x888888);
            } else {
                if (extraY == 45)
                    // 0xFFFFFF
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Limit), 6 + textX, 4, 0x888888);
                else
                    drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Drive), 6 + textX, 4, 0xFFFFFF);
            }
        }
    }
    GL11.glPopMatrix();
    // ITEMS
    GL11.glPushMatrix();
    {
        GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
        int u;
        int v = 0;
        int x = 0;
        mc.renderEngine.bindTexture(texture);
        GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * ITEMS), 0);
        GL11.glScalef(scale, scale, scale);
        if (submenu != 0)
            GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
        if (selected == ITEMS) {
            // Selected
            textX = 5;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(5, 0, TOP_WIDTH, 30 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(5, 0, TOP_WIDTH, MENU_HEIGHT + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        } else {
            // Not selected
            textX = 0;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(0, 0, 0, 30, TOP_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        }
        if (this.submenu == 0) {
            if (this.items.isEmpty())
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Items), 6 + textX, 4, 0x888888);
            else
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Items), 6 + textX, 4, 0xFFFFFF);
        }
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
    GL11.glPopMatrix();
    // MAGIC
    GL11.glPushMatrix();
    {
        GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
        int u;
        int v = 0;
        int x = 0;
        mc.renderEngine.bindTexture(texture);
        GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * MAGIC), 0);
        GL11.glScalef(scale, scale, scale);
        if (submenu != 0)
            GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
        if (selected == MAGIC) {
            // Selected
            textX = 5;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(5, 0, TOP_WIDTH, 30 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(5, 0, TOP_WIDTH, MENU_HEIGHT + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        } else {
            // Not selected
            textX = 0;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(0, 0, 0, 30, TOP_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        }
        if (this.submenu == 0) {
            int color;
            if (spells == null) {
                color = 0x888888;
            } else {
                if (!STATS.getRecharge() && (!this.spells.isEmpty() && !DS.getActiveDriveName().equals(Strings.Form_Valor)))
                    color = 0xFFFFFF;
                else
                    color = 0x888888;
            }
            drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Magic), 6 + textX, 4, color);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }
    }
    GL11.glPopMatrix();
    // ATTACK
    GL11.glPushMatrix();
    {
        GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
        int u;
        int v = 0;
        int x = 0;
        mc.renderEngine.bindTexture(texture);
        GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * ATTACK), 0);
        GL11.glScalef(scale, scale, scale);
        if (submenu != 0)
            GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
        if (selected == ATTACK) {
            // Selected
            textX = 5;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(5, 0, TOP_WIDTH, 30 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(5, 0, TOP_WIDTH, MENU_HEIGHT + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        } else {
            // Not selected
            textX = 0;
            if (EntityEvents.isHostiles)
                drawTexturedModalRect(0, 0, 0, 30, TOP_WIDTH, v + MENU_HEIGHT);
            else
                drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
        }
        if (this.submenu == 0) {
            int color = this.portalCommands.isEmpty() || STATS.getRecharge() ? 0x888888 : 0xFFFFFF;
            if (extraY == 45)
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Portal), 6 + textX, 4, color);
            else
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Attack), 6 + textX, 4, color);
        }
    }
    GL11.glPopMatrix();
    // TOP
    GL11.glPushMatrix();
    {
        GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
        mc.renderEngine.bindTexture(texture);
        GL11.glTranslatef(0, (height - MENU_HEIGHT * scale * TOP), 0);
        GL11.glScalef(scale, scale, scale);
        if (submenu != 0)
            GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
        if (EntityEvents.isHostiles)
            drawTexturedModalRect(0, 0, 0, 15, TOP_WIDTH, TOP_HEIGHT);
        else
            drawTexturedModalRect(0, 0, 0, 0 + extraY, TOP_WIDTH, TOP_HEIGHT);
        if (this.submenu == 0) {
            drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Command), 6, 4, 0xFFFFFF);
        }
    }
    GL11.glPopMatrix();
    // Portal submenu //
    if (portalCommands == null) {
    } else if (!portalCommands.isEmpty()) {
        // PORTAL TOP
        GL11.glPushMatrix();
        {
            GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
            mc.renderEngine.bindTexture(texture);
            GL11.glTranslatef(5, (height - MENU_HEIGHT * scale * (portalCommands.size() + 1)), 0);
            GL11.glScalef(scale, scale, scale);
            if (submenu == SUB_PORTALS) {
                drawTexturedModalRect(0, 0, 0, 0 + extraY, TOP_WIDTH, TOP_HEIGHT);
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Portals_Title), 6, 4, 0xFFFFFF);
            }
        }
        GL11.glPopMatrix();
        for (int i = 0; i < portalCommands.size(); i++) {
            GL11.glPushMatrix();
            {
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
                int u;
                int v;
                int x;
                x = (portalSelected == i) ? 10 : 5;
                mc.renderEngine.bindTexture(texture);
                GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * (portalCommands.size() - i)), 0);
                GL11.glScalef(scale, scale, scale);
                if (submenu == SUB_PORTALS) {
                    v = 0;
                    if (portalSelected == i)
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 15 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    else
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    // colour = Constants.getCost(spells.get(i)) < STATS.getMP() ? 0xFFFFFF : 0xFF9900;
                    PortalCoords portal = portalCommands.get(i);
                    // String magicName = Constants.getMagicName(magic, level);
                    drawString(mc.fontRenderer, Utils.translateToLocal(portal.getShortCoords() + ""), 6, 4, 0xFFFFFF);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                }
            }
            GL11.glPopMatrix();
        }
    }
    // Magic submenu //
    if (spells == null) {
    } else if (!spells.isEmpty()) {
        // MAGIC TOP
        GL11.glPushMatrix();
        {
            GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
            mc.renderEngine.bindTexture(texture);
            GL11.glTranslatef(5, (height - MENU_HEIGHT * scale * (spells.size() + 1)), 0);
            GL11.glScalef(scale, scale, scale);
            if (submenu == SUB_MAGIC) {
                drawTexturedModalRect(0, 0, 0, 0 + extraY, TOP_WIDTH, TOP_HEIGHT);
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Magic_Title), 6, 4, 0xFFFFFF);
            }
        }
        GL11.glPopMatrix();
        for (int i = 0; i < spells.size(); i++) {
            GL11.glPushMatrix();
            {
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
                int u;
                int v;
                int x;
                x = (magicselected == i) ? 10 : 5;
                mc.renderEngine.bindTexture(texture);
                GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * (spells.size() - i)), 0);
                GL11.glScalef(scale, scale, scale);
                if (submenu == SUB_MAGIC) {
                    v = 0;
                    if (magicselected == i)
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 15 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    else
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    colour = Constants.getCost(spells.get(i)) < STATS.getMP() ? 0xFFFFFF : 0xFF9900;
                    if (spells.get(i).equals(Strings.Spell_Cure))
                        colour = 0xFF9900;
                    colour = STATS.getMP() < 1 ? 0x888888 : colour;
                    String magic = spells.get(i);
                    int level = mc.player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic);
                    String magicName = Constants.getMagicName(magic, level);
                    drawString(mc.fontRenderer, Utils.translateToLocal(magicName), 6, 4, colour);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                }
            }
            GL11.glPopMatrix();
        }
    }
    // Items submenu //
    if (items == null) {
    } else if (!items.isEmpty()) {
        // Items TOP
        GL11.glPushMatrix();
        {
            GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
            mc.renderEngine.bindTexture(texture);
            GL11.glTranslatef(5, (height - MENU_HEIGHT * scale * (items.size() + 1)), 0);
            GL11.glScalef(scale, scale, scale);
            if (submenu == SUB_ITEMS) {
                drawTexturedModalRect(0, 0, 0, 0 + extraY, TOP_WIDTH, TOP_HEIGHT);
                drawString(mc.fontRenderer, Utils.translateToLocal("ITEMS"), 6, 4, 0xFFFFFF);
            }
        }
        GL11.glPopMatrix();
        for (int i = 0; i < items.size(); i++) {
            GL11.glPushMatrix();
            {
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
                int u;
                int v;
                int x;
                x = (potionselected == i) ? 10 : 5;
                mc.renderEngine.bindTexture(texture);
                GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * (items.size() - i)), 0);
                GL11.glScalef(scale, scale, scale);
                if (submenu == SUB_ITEMS) {
                    v = 0;
                    if (potionselected == i)
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 15 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    else
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    drawString(mc.fontRenderer, Utils.translateToLocal("item." + items.get(i) + ".name"), 6, 4, 0xFFFFFF);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                }
            }
            GL11.glPopMatrix();
        }
    }
    // Drive form submenu //
    if (driveCommands == null) {
    } else if (!driveCommands.isEmpty()) {
        // DRIVE TOP
        GL11.glPushMatrix();
        {
            GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
            mc.renderEngine.bindTexture(texture);
            GL11.glTranslatef(5, (height - MENU_HEIGHT * scale * (driveCommands.size() + 1)), 0);
            GL11.glScalef(1.25f, scale, scale);
            if (submenu == SUB_DRIVE)
                drawTexturedModalRect(0, 0, 0, 0 + extraY, TOP_WIDTH, TOP_HEIGHT);
        }
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        {
            GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
            GL11.glTranslatef(5, (height - MENU_HEIGHT * scale * (driveCommands.size() + 1)), 0);
            GL11.glScalef(scale, scale, scale);
            if (submenu == SUB_DRIVE)
                drawString(mc.fontRenderer, Utils.translateToLocal(Strings.Gui_CommandMenu_Drive_Title), 6, 4, 0xFFFFFF);
        }
        GL11.glPopMatrix();
        for (int i = 0; i < driveCommands.size(); i++) {
            GL11.glPushMatrix();
            {
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) alpha);
                int u;
                int v;
                int x;
                x = (driveselected == i) ? 10 : 5;
                v = (driveselected == i) ? MENU_HEIGHT : 0;
                mc.renderEngine.bindTexture(texture);
                GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * (driveCommands.size() - i)), 0);
                GL11.glScalef(1.25f, scale, scale);
                if (submenu == SUB_DRIVE) {
                    v = 0;
                    if (driveselected == i)
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 15 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                    else
                        drawTexturedModalRect(0, 0, TOP_WIDTH, 0 + extraY, TOP_WIDTH + MENU_WIDTH, v + MENU_HEIGHT);
                }
            }
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            {
                GL11.glColor4ub((byte) 80, (byte) 80, (byte) 80, (byte) alpha);
                int x;
                x = (driveselected == i) ? 10 : 5;
                GL11.glTranslatef(x, (height - MENU_HEIGHT * scale * (driveCommands.size() - i)), 0);
                GL11.glScalef(scale, scale, scale);
                if (submenu == SUB_DRIVE) {
                    if (DS.getDP() >= Constants.getCost(driveCommands.get(i)) || mc.player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
                        drawString(mc.fontRenderer, Utils.translateToLocal(driveCommands.get(i)), 6, 4, 0xFFFFFF);
                    else
                        drawString(mc.fontRenderer, Utils.translateToLocal(driveCommands.get(i)), 6, 4, 0x888888);
                }
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            }
            GL11.glPopMatrix();
        }
    }
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) ItemKKPotion(uk.co.wehavecookies56.kk.common.item.base.ItemKKPotion) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)

Aggregations

PortalCoords (uk.co.wehavecookies56.kk.common.util.PortalCoords)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 TextComponentString (net.minecraft.util.text.TextComponentString)4 IDriveState (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)3 PlayerStatsCapability (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability)3 Minecraft (net.minecraft.client.Minecraft)2 TileEntityOrgPortal (uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal)2 ItemKKPotion (uk.co.wehavecookies56.kk.common.item.base.ItemKKPotion)2 SyncOrgXIIIData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData)2 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 World (net.minecraft.world.World)1 IOrganizationXIII (uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability.IOrganizationXIII)1 EntityOrgPortal (uk.co.wehavecookies56.kk.common.entity.magic.EntityOrgPortal)1 DriveFormPacket (uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket)1 OrgPortal (uk.co.wehavecookies56.kk.common.network.packet.server.OrgPortal)1 MagicWisdomShot (uk.co.wehavecookies56.kk.common.network.packet.server.magics.MagicWisdomShot)1