Search in sources :

Example 1 with IDriveState

use of uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState 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 IDriveState

use of uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState 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 IDriveState

use of uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class DriveFormFinal method getXP.

@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityEnderman) {
        if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
            if (DRIVE.getActiveDriveName().equals(Strings.Form_Final)) {
                DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName()) + 1);
                int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts();
                int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName());
                int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName());
                if (costs.length == 7 && actualLevel < 7) {
                    if (actualExp >= costs[actualLevel]) {
                        System.out.println("LEVEL UP");
                        DRIVE.setDriveLevel(DRIVE.getActiveDriveName(), actualLevel + 1);
                        DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName());
                    }
                }
                PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player);
            }
        }
    }
}
Also used : SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with IDriveState

use of uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiOverlay method RenderGameOverlayEvent.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void RenderGameOverlayEvent(RenderGameOverlayEvent event) {
    if (event.getType() == ElementType.TEXT) {
        Minecraft mc = Minecraft.getMinecraft();
        int screenWidth = event.getResolution().getScaledWidth();
        int screenHeight = event.getResolution().getScaledHeight();
        IPlayerStats STATS = mc.player.getCapability(ModCapabilities.PLAYER_STATS, null);
        IDriveState DRIVE = mc.player.getCapability(ModCapabilities.DRIVE_STATE, null);
        if (showExp) {
            String reqExp = String.valueOf(STATS.getExpNeeded(STATS.getLevel(), STATS.getExperience()));
            mc.fontRenderer.drawString("Next LV", 5, 5, 0xFFFFFF);
            mc.fontRenderer.drawString(reqExp, 5, 5 + mc.fontRenderer.FONT_HEIGHT, 0xFFFFFF);
            if (timeExp + 4 <= (int) Minecraft.getSystemTime() / 1000)
                showExp = false;
        }
        if (showMunny) {
            if (!showExp) {
                GL11.glPushMatrix();
                GL11.glTranslatef(1, 1, 0);
                mc.fontRenderer.drawString("Munny Get!", 5, 5, 0xFFFFFF);
                mc.fontRenderer.drawString(munnyGet + "", 5, 5 + mc.fontRenderer.FONT_HEIGHT, 0xFFFFFF);
                GL11.glPopMatrix();
            } else {
                mc.fontRenderer.drawString("Munny Get!", 5, 5 + mc.fontRenderer.FONT_HEIGHT + 10, 0xFFFFFF);
                mc.fontRenderer.drawString(munnyGet + "", 5, 5 + (mc.fontRenderer.FONT_HEIGHT * 2) + 10, 0xFFFFFF);
            }
            if (timeMunny + 4 <= (int) Minecraft.getSystemTime() / 1000)
                showMunny = false;
        }
        if (showLevelUp) {
            ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/gui/levelup.png");
            GL11.glPushMatrix();
            {
                int height = (mc.fontRenderer.FONT_HEIGHT - 3) * STATS.getMessages().size();
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    GL11.glPushMatrix();
                    {
                        GL11.glTranslatef((width - 153.6f - 2), 0, 0);
                        GL11.glScalef(0.6f, 0.6f, 1);
                        drawTexturedModalRect(0, 0, 0, 0, 256, 36);
                    }
                    GL11.glPopMatrix();
                    GL11.glPushMatrix();
                    {
                        GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth("LEVEL UP!")) * 0.75f) - 115, 4, 0);
                        GL11.glScalef(0.75f, 0.75f, 1);
                        drawString(mc.fontRenderer, "LEVEL UP!" + TextFormatting.ITALIC, 0, 0, Color.decode(String.format("#%02x%02x%02x", (byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2])).hashCode());
                    }
                    GL11.glPopMatrix();
                    GL11.glPushMatrix();
                    {
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth("LV. ")) * 0.75f) - 90, 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, "LV.", 0, 0, 0xE3D000);
                        }
                        GL11.glPopMatrix();
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(width - 256.0f * 0.75f + ((mc.fontRenderer.getStringWidth("999")) * 0.75f) + 88, 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, "" + STATS.getLevel(), 0, 0, 0xFFFFFF);
                        }
                        GL11.glPopMatrix();
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(width - ((mc.fontRenderer.getStringWidth(mc.player.getDisplayNameString())) * 0.75f) - 7, 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, mc.player.getDisplayNameString(), 0, 0, 0xFFFFFF);
                        }
                        GL11.glPopMatrix();
                    }
                    GL11.glPopMatrix();
                }
                GL11.glPopMatrix();
                GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    GL11.glTranslatef((width - 256.0f * 0.6f - 2), 36.0f * 0.6f, 0);
                    GL11.glScalef(0.6f, height, 1);
                    drawTexturedModalRect(0, 0, 0, 36, 256, 1);
                }
                GL11.glPopMatrix();
                GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    GL11.glTranslatef((width - 256.0f * 0.6f - 2), height + (36.0f * 0.6f), 0);
                    GL11.glScalef(0.6f, 0.6f, 1);
                    drawTexturedModalRect(0, 0, 0, 37, 256, 14);
                }
                GL11.glPopMatrix();
                GL11.glColor4ub((byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2], (byte) 255);
                for (int i = 0; i < STATS.getMessages().size(); i++) {
                    GL11.glPushMatrix();
                    {
                        int width = event.getResolution().getScaledWidth();
                        String message = STATS.getMessages().get(i).toString();
                        GL11.glTranslatef((width - 256.0f * 0.8f + (mc.fontRenderer.getStringWidth("Maximum HP Increased!")) * 0.8f), mc.fontRenderer.FONT_HEIGHT * 0.8f * i + 23, 0);
                        GL11.glTranslatef(-35, 0, 0);
                        GL11.glScalef(0.8f, 0.8f, 1);
                        drawString(mc.fontRenderer, Utils.translateToLocal(message), 0, 0, 0xFFFFFF);
                    }
                    GL11.glPopMatrix();
                }
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
            }
            GL11.glPopMatrix();
            if (timeLevelUp + levelSeconds <= (int) Minecraft.getSystemTime() / 1000)
                showLevelUp = false;
        }
        if (showDriveLevelUp) {
            byte[] driveColor = new byte[] { (byte) 255, (byte) 255, (byte) 255 };
            switch(// mc.player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName()
            driveForm) {
                case Strings.Form_Valor:
                    driveColor[0] = (byte) 255;
                    driveColor[1] = (byte) 0;
                    driveColor[2] = (byte) 0;
                    break;
                case Strings.Form_Wisdom:
                    driveColor[0] = (byte) 0;
                    driveColor[1] = (byte) 0;
                    driveColor[2] = (byte) 255;
                    break;
                case Strings.Form_Limit:
                    driveColor[0] = (byte) 153;
                    driveColor[1] = (byte) 76;
                    driveColor[2] = (byte) 255;
                    break;
                case Strings.Form_Master:
                    driveColor[0] = (byte) 255;
                    driveColor[1] = (byte) 185;
                    driveColor[2] = (byte) 25;
                    break;
                case Strings.Form_Final:
                    driveColor[0] = (byte) 230;
                    driveColor[1] = (byte) 230;
                    driveColor[2] = (byte) 230;
                    break;
            }
            ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/gui/levelup.png");
            GL11.glPushMatrix();
            {
                int height = (mc.fontRenderer.FONT_HEIGHT - 3) * DRIVE.getMessages().size();
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    int sHeight = event.getResolution().getScaledHeight();
                    GL11.glPushMatrix();
                    {
                        GL11.glTranslatef(2, sHeight / 3, 0);
                        GL11.glScalef(0.6f, 0.6f, 1);
                        drawTexturedModalRect(0, 0, 0, 0, 256, 36);
                    }
                    GL11.glPopMatrix();
                    GL11.glPushMatrix();
                    {
                        GL11.glTranslatef(6, sHeight / 3 + 5, 0);
                        GL11.glScalef(0.75f, 0.75f, 1);
                        drawString(mc.fontRenderer, "LEVEL UP!" + TextFormatting.ITALIC, 0, 0, Color.decode(String.format("#%02x%02x%02x", (byte) MainConfig.client.hud.interfaceColour[0], (byte) MainConfig.client.hud.interfaceColour[1], (byte) MainConfig.client.hud.interfaceColour[2])).hashCode());
                    }
                    GL11.glPopMatrix();
                    GL11.glPushMatrix();
                    {
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(2 + (mc.fontRenderer.getStringWidth("LV. ") * 0.75f) + 38, sHeight / 3 + 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, "LV.", 0, 0, 0xE3D000);
                        }
                        GL11.glPopMatrix();
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(2 * 0.75f + (mc.fontRenderer.getStringWidth("999") * 0.75f) + 50, sHeight / 3 + 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, "" + DRIVE.getDriveLevel(driveForm), 0, 0, 0xFFFFFF);
                        }
                        GL11.glPopMatrix();
                        GL11.glPushMatrix();
                        {
                            GL11.glTranslatef(150 - (mc.fontRenderer.getStringWidth(Utils.translateToLocal(driveForm)) * 0.75f), sHeight / 3 + 4, 0);
                            GL11.glScalef(0.75f, 0.75f, 1);
                            drawString(mc.fontRenderer, Utils.translateToLocal(driveForm), 0, 0, 0xFFFFFF);
                        }
                        GL11.glPopMatrix();
                    }
                    GL11.glPopMatrix();
                }
                GL11.glPopMatrix();
                GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    int sHeight = event.getResolution().getScaledHeight();
                    GL11.glTranslatef(2.0f * 0.6f + 1, sHeight / 3 + 36.0f * 0.6f, 0);
                    GL11.glScalef(0.6f, height, 1);
                    drawTexturedModalRect(0, 0, 0, 36, 256, 1);
                }
                GL11.glPopMatrix();
                GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
                GL11.glPushMatrix();
                {
                    mc.renderEngine.bindTexture(texture);
                    int width = event.getResolution().getScaledWidth();
                    int sHeight = event.getResolution().getScaledHeight();
                    GL11.glTranslatef(2, sHeight / 3 + height + (36.0f * 0.6f), 0);
                    GL11.glScalef(0.6f, 0.6f, 1);
                    drawTexturedModalRect(0, 0, 0, 37, 256, 14);
                }
                GL11.glPopMatrix();
                GL11.glColor4ub(driveColor[0], driveColor[1], driveColor[2], (byte) 255);
                for (int i = 0; i < DRIVE.getMessages().size(); i++) {
                    GL11.glPushMatrix();
                    {
                        int width = event.getResolution().getScaledWidth();
                        int sHeight = event.getResolution().getScaledHeight();
                        String message = DRIVE.getMessages().get(i).toString();
                        GL11.glTranslatef(2 * 0.8f + 50, sHeight / 3 + mc.fontRenderer.FONT_HEIGHT * 0.8f * i + 21, 0);
                        GL11.glTranslatef(-35, 0, 0);
                        GL11.glScalef(0.8f, 0.8f, 1);
                        drawString(mc.fontRenderer, Utils.translateToLocalFormatted(message), 0, 0, 0xFFFFFF);
                    }
                    GL11.glPopMatrix();
                }
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
            }
            GL11.glPopMatrix();
            if (timeDriveLevelUp + levelSeconds <= (int) Minecraft.getSystemTime() / 1000)
                showDriveLevelUp = false;
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) Minecraft(net.minecraft.client.Minecraft) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with IDriveState

use of uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class CommandDriveLevel method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
        if (args.length == 0 || args.length > 3)
            TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
        else if (args.length >= 2 && args.length <= 3) {
            if (args.length == 3) {
                if (getPlayerFromUsername(args[2]) != null) {
                    player = getPlayerFromUsername(args[2]);
                }
            }
            int level = 1;
            try {
                // Parse the given level
                if (Integer.parseInt(args[1]) < 1 || Integer.parseInt(args[1]) > 7) {
                    TextHelper.sendFormattedChatMessage("Invalid level, it must be a number between 1 - 7", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
                    return;
                } else
                    level = Integer.parseInt(args[1]);
            } catch (Exception e) {
                TextHelper.sendFormattedChatMessage("Invalid level, it must be a number between 1 - 7", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
                return;
            }
            IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
            String form = null;
            int oldLevel = DRIVE.getDriveLevel("form." + args[0].toLowerCase());
            int newLevel = Integer.parseInt(args[1].toString());
            switch(args[0].toLowerCase()) {
                case "valor":
                    DRIVE.setDriveLevel(Strings.Form_Valor, newLevel);
                    form = Utils.translateToLocal(Strings.Form_Valor);
                    break;
                case "wisdom":
                    DRIVE.setDriveLevel(Strings.Form_Wisdom, Integer.parseInt(args[1].toString()));
                    form = Utils.translateToLocal(Strings.Form_Wisdom);
                    break;
                case "limit":
                    DRIVE.setDriveLevel(Strings.Form_Limit, Integer.parseInt(args[1].toString()));
                    form = Utils.translateToLocal(Strings.Form_Limit);
                    break;
                case "master":
                    DRIVE.setDriveLevel(Strings.Form_Master, Integer.parseInt(args[1].toString()));
                    form = Utils.translateToLocal(Strings.Form_Master);
                    break;
                case "final":
                    DRIVE.setDriveLevel(Strings.Form_Final, Integer.parseInt(args[1].toString()));
                    form = Utils.translateToLocal(Strings.Form_Final);
                    break;
            }
            DRIVE.displayLevelUpMessage(player, "form." + args[0].toLowerCase());
            if (oldLevel != 7 && newLevel == 7) {
                // Increase
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
                PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
            } else if (oldLevel == 7 && newLevel != 7) {
                // Decrease
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() - 1);
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
                PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
            }
            if (form != null) {
                if (args.length == 3)
                    TextHelper.sendFormattedChatMessage("Succesfully leveled up " + form + " to level " + args[1] + " for player " + args[2], TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
                else
                    TextHelper.sendFormattedChatMessage("Succesfully leveled up " + form + " to level " + args[1], TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
            } else {
                TextHelper.sendFormattedChatMessage("Unknown form " + args[0], TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
            }
        } else {
            TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
        }
    }
}
Also used : SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException) CommandException(net.minecraft.command.CommandException) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)

Aggregations

IDriveState (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 PlayerStatsCapability (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability)5 SyncDriveData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData)4 Minecraft (net.minecraft.client.Minecraft)3 PortalCoords (uk.co.wehavecookies56.kk.common.util.PortalCoords)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 MunnyCapability (uk.co.wehavecookies56.kk.common.capability.MunnyCapability)2 IPlayerStats (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats)2 ItemKKPotion (uk.co.wehavecookies56.kk.common.item.base.ItemKKPotion)2 CommandException (net.minecraft.command.CommandException)1 PlayerNotFoundException (net.minecraft.command.PlayerNotFoundException)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 NBTPrimitive (net.minecraft.nbt.NBTPrimitive)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumFacing (net.minecraft.util.EnumFacing)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1