Search in sources :

Example 1 with DriveFormPacket

use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class InputHandler method antiFormCheck.

public boolean antiFormCheck() {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    World world = mc.world;
    double random = Math.random();
    int ap = player.getCapability(ModCapabilities.DRIVE_STATE, null).getAntiPoints();
    int prob = 0;
    if (ap > 0 && ap <= 4)
        prob = 0;
    else if (ap > 4 && ap <= 9)
        prob = 10;
    else if (ap >= 10)
        prob = 25;
    if (random * 100 < prob) {
        PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Anti));
        GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
        GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
        PacketDispatcher.sendToServer(new AntiPoints(-4));
        world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
        return true;
    } else
        return false;
}
Also used : AntiPoints(uk.co.wehavecookies56.kk.common.network.packet.server.AntiPoints) EntityPlayer(net.minecraft.entity.player.EntityPlayer) DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft)

Example 2 with DriveFormPacket

use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket 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 3 with DriveFormPacket

use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class DriveFormAnti method update.

@Override
public void update(EntityPlayer player) {
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
        if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() > 0) {
            player.getCapability(ModCapabilities.DRIVE_STATE, null).remFP(0.1);
            if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() < 0) {
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setFP(0);
                endDrive(player);
                if (player.world.isRemote) {
                    PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
                }
            }
        } else {
            System.out.println(FMLCommonHandler.instance().getEffectiveSide());
            endDrive(player);
        }
    }
}
Also used : DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket)

Example 4 with DriveFormPacket

use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class ModDriveForms method getDriveForm.

public static void getDriveForm(EntityPlayer player, World world, String drive) {
    switch(drive) {
        case Strings.Form_Valor:
            PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Valor));
            PacketDispatcher.sendToServer(new AntiPoints(1));
            break;
        case Strings.Form_Wisdom:
            PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Wisdom));
            PacketDispatcher.sendToServer(new AntiPoints(1));
            break;
        case Strings.Form_Limit:
            PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Limit));
            PacketDispatcher.sendToServer(new AntiPoints(1));
            break;
        case Strings.Form_Master:
            PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Master));
            PacketDispatcher.sendToServer(new AntiPoints(1));
            break;
        case Strings.Form_Final:
            PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Final));
            PacketDispatcher.sendToServer(new AntiPoints(-10));
            break;
        default:
            break;
    }
}
Also used : AntiPoints(uk.co.wehavecookies56.kk.common.network.packet.server.AntiPoints) DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket)

Example 5 with DriveFormPacket

use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class DriveForm method update.

public void update(EntityPlayer player) {
    if (player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot() == -1) {
        player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setActiveSlot(player.inventory.currentItem);
    }
    if (player.world.isRemote) {
        GuiScreen currScreen = Minecraft.getMinecraft().currentScreen;
        if (currScreen instanceof GuiContainer) {
            Minecraft.getMinecraft().displayGuiScreen(null);
            player.sendMessage(new TextComponentTranslation("Cannot open containers while drive form is active"));
        }
    }
    if (player.inventory.currentItem != player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot())
        player.inventory.currentItem = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot();
    if (ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()))) {
        player.inventory.setItemStack(ItemStack.EMPTY);
        player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
    }
    if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(getKeychainSlot()).getItem()).getKeyblade()))) {
        player.inventory.setItemStack(ItemStack.EMPTY);
        player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
    }
    if (ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot()), ItemStack.EMPTY)) {
        player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
    }
    if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.offHandInventory.get(0), ItemStack.EMPTY)) {
        player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
    }
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
        if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() > 0) {
            player.getCapability(ModCapabilities.DRIVE_STATE, null).remFP(0.1);
            if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() < 0) {
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setFP(0);
                endDrive(player);
                if (player.world.isRemote) {
                    PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
                }
            }
        } else {
            endDrive(player);
            if (player.world.isRemote) {
                PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
            }
        /*Utils.summonWeapon(player, EnumHand.MAIN_HAND, 0);
                if(hasOffHand())
                    Utils.summonWeapon(player, EnumHand.OFF_HAND, getKeychainSlot());
                player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
                player.inventory.offHandInventory.set(0, ItemStack.EMPTY);*/
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket) ItemStack(net.minecraft.item.ItemStack)

Aggregations

DriveFormPacket (uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket)5 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 World (net.minecraft.world.World)2 AntiPoints (uk.co.wehavecookies56.kk.common.network.packet.server.AntiPoints)2 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1 ItemStack (net.minecraft.item.ItemStack)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 IDriveState (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)1 PlayerStatsCapability (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability)1 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)1 MagicWisdomShot (uk.co.wehavecookies56.kk.common.network.packet.server.magics.MagicWisdomShot)1 PortalCoords (uk.co.wehavecookies56.kk.common.util.PortalCoords)1