Search in sources :

Example 6 with SyncMagicData

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

the class LevelUpMagic method process.

@Override
public void process(EntityPlayer player, Side side) {
    int firstEmptySlot = -1;
    boolean hasMagicInSlot = false;
    for (int i = 0; i < InventorySpells.INV_SIZE; i++) {
        if (!ItemStack.areItemStacksEqual(player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i), ItemStack.EMPTY)) {
            if (player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i).getItem() == player.getHeldItem(EnumHand.MAIN_HAND).getItem()) {
                hasMagicInSlot = true;
            }
        } else {
            firstEmptySlot = i;
            break;
        }
    }
    if (!hasMagicInSlot) {
        player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().setStackInSlot(firstEmptySlot, player.getHeldItem(EnumHand.MAIN_HAND));
        player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
        TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Magic_Learn, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
        learnMessage.getStyle().setColor(TextFormatting.YELLOW);
        player.sendMessage(learnMessage);
    } else {
        if (player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) < Constants.MAX_MAGIC_LEVEL) {
            player.getCapability(ModCapabilities.MAGIC_STATE, null).setMagicLevel(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) + 1);
            player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
            TextComponentTranslation levelupMessage = new TextComponentTranslation(Strings.Chat_Magic_Levelup, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) - 1)), new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
            levelupMessage.getStyle().setColor(TextFormatting.YELLOW);
            player.sendMessage(levelupMessage);
        } else {
            TextComponentTranslation errorMessage = new TextComponentTranslation(Strings.Chat_Magic_Error, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
            errorMessage.getStyle().setColor(TextFormatting.YELLOW);
            player.sendMessage(errorMessage);
        }
    }
    PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
    PacketDispatcher.sendTo(new SyncMagicInventory(player.getCapability(ModCapabilities.MAGIC_STATE, null)), (EntityPlayerMP) player);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SyncMagicInventory(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicInventory) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData)

Example 7 with SyncMagicData

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

the class MagicAero method process.

@Override
public void process(EntityPlayer player, Side side) {
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
        player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Aero));
    World world = player.world;
    if (!world.isRemote) {
        switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Aero)) {
            case 1:
                world.spawnEntity(new EntityAero(world, player, player.posX, player.posY, player.posZ));
                PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 1), player, 64.0D);
                break;
            case 2:
                world.spawnEntity(new EntityAerora(world, player, player.posX, player.posY, player.posZ));
                PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 2), player, 64.0D);
                break;
            case 3:
                world.spawnEntity(new EntityAeroga(world, player, player.posX, player.posY, player.posZ));
                PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 3), player, 64.0D);
                break;
        }
        PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
    }
}
Also used : EntityAero(uk.co.wehavecookies56.kk.common.entity.magic.EntityAero) EntityAeroga(uk.co.wehavecookies56.kk.common.entity.magic.EntityAeroga) SpawnAeroParticles(uk.co.wehavecookies56.kk.common.network.packet.client.SpawnAeroParticles) EntityAerora(uk.co.wehavecookies56.kk.common.entity.magic.EntityAerora) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) World(net.minecraft.world.World)

Example 8 with SyncMagicData

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

the class MagicBlizzard method process.

@Override
public void process(EntityPlayer player, Side side) {
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
        player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Blizzard));
    World world = player.world;
    switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Blizzard)) {
        case 1:
            EntityBlizzard entityBlizzard = new EntityBlizzard(world, player);
            world.spawnEntity(entityBlizzard);
            entityBlizzard.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
            // PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzard(world), 1), player, 64.0D);
            break;
        case 2:
            EntityBlizzara entityBlizzara = new EntityBlizzara(world, player);
            world.spawnEntity(entityBlizzara);
            entityBlizzara.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 2, 0);
            // PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzara(world), 2), player, 64.0D);
            break;
        case 3:
            EntityBlizzaga entityBlizzaga = new EntityBlizzaga(world, player);
            world.spawnEntity(entityBlizzaga);
            entityBlizzaga.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 3, 0);
            // PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzaga(world), 3), player, 64.0D);
            break;
    }
    world.playSound(player.posX, player.posY, player.posZ, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.PLAYERS, 1, 1, false);
    PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
Also used : EntityBlizzaga(uk.co.wehavecookies56.kk.common.entity.magic.EntityBlizzaga) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) World(net.minecraft.world.World) EntityBlizzard(uk.co.wehavecookies56.kk.common.entity.magic.EntityBlizzard) EntityBlizzara(uk.co.wehavecookies56.kk.common.entity.magic.EntityBlizzara)

Example 9 with SyncMagicData

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

the class MagicCure method process.

@Override
public void process(EntityPlayer player, Side side) {
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
        player.getCapability(ModCapabilities.PLAYER_STATS, null).setMP(0);
    World world = player.world;
    player.extinguish();
    switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Cure)) {
        case 1:
            if (player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 + player.getHealth() > player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP())
                player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
            else
                player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3);
            world.spawnEntity(new EntityCure(world, player, player.posX, player.posY, player.posZ));
            break;
        case 2:
            if (player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 * 2 + player.getHealth() > player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP())
                player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
            else
                player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 * 2);
            world.spawnEntity(new EntityCura(world, player, player.posX, player.posY, player.posZ));
            break;
        case 3:
            player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
            world.spawnEntity(new EntityCuraga(world, player, player.posX, player.posY, player.posZ));
            break;
    }
    PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
Also used : EntityCura(uk.co.wehavecookies56.kk.common.entity.magic.EntityCura) EntityCuraga(uk.co.wehavecookies56.kk.common.entity.magic.EntityCuraga) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) World(net.minecraft.world.World) EntityCure(uk.co.wehavecookies56.kk.common.entity.magic.EntityCure)

Example 10 with SyncMagicData

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

the class MagicKH1Fire method process.

@Override
public void process(EntityPlayer player, Side side) {
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
        player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Fire));
    World world = player.world;
    switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Fire)) {
        case 1:
            EntityKH1Fire entityKH1Fire = new EntityKH1Fire(world, player);
            world.spawnEntity(entityKH1Fire);
            entityKH1Fire.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
            PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Fire(world), 1), player, 64.0D);
            break;
        case 2:
            EntityKH1Fira entityKH1Fira = new EntityKH1Fira(world, player);
            world.spawnEntity(entityKH1Fira);
            entityKH1Fira.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
            PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Fira(world), 1), player, 64.0D);
            break;
        case 3:
            EntityKH1Firaga entityKH1Firaga = new EntityKH1Firaga(world, player);
            world.spawnEntity(entityKH1Firaga);
            entityKH1Firaga.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
            PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Firaga(world), 1), player, 64.0D);
            break;
    }
    PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
Also used : SpawnKH1FireParticles(uk.co.wehavecookies56.kk.common.network.packet.client.SpawnKH1FireParticles) EntityKH1Fira(uk.co.wehavecookies56.kk.common.entity.magic.EntityKH1Fira) EntityKH1Firaga(uk.co.wehavecookies56.kk.common.entity.magic.EntityKH1Firaga) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) World(net.minecraft.world.World) EntityKH1Fire(uk.co.wehavecookies56.kk.common.entity.magic.EntityKH1Fire)

Aggregations

SyncMagicData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData)14 World (net.minecraft.world.World)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 IPlayerStats (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats)3 SyncDriveData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData)3 SyncLevelData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData)3 Entity (net.minecraft.entity.Entity)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 MunnyCapability (uk.co.wehavecookies56.kk.common.capability.MunnyCapability)2 SyncDriveInventory (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveInventory)2 SyncMagicInventory (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicInventory)2 GameProfile (com.mojang.authlib.GameProfile)1 List (java.util.List)1 UUID (java.util.UUID)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 ItemStack (net.minecraft.item.ItemStack)1