Search in sources :

Example 11 with SyncDriveData

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

the class EntityEvents method OnEntityJoinWorld.

@SubscribeEvent
public void OnEntityJoinWorld(EntityJoinWorldEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.DriveRecovery.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.HighDriveRecovery.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MagicBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.PowerBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.DefenseBoost.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Elixir.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Megalixir.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Ether.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MegaEther.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Potion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.HiPotion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.MegaPotion.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), ModItems.Panacaea.getUnlocalizedName());
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilShard);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilStone);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilGem);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_MythrilCrystal);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_ManifestIllusion);
        FreeDevRecipeRegistry.learnFreeDevRecipe(event.getEntity().getCapability(ModCapabilities.SYNTHESIS_RECIPES, null).getFreeDevRecipes(), (EntityPlayer) event.getEntity(), Strings.SM_LostIllusion);
        if (event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getSlots() != InventoryKeychain.INV_SIZE) {
            ItemStackHandler oldInv = event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain();
            event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setInventory(new ItemStackHandler(InventoryKeychain.INV_SIZE));
            ItemStackHandler newInv = event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain();
            for (int i = 0; i < oldInv.getSlots(); i++) {
                newInv.setStackInSlot(i, oldInv.getStackInSlot(i));
            }
        }
        PacketDispatcher.sendTo(new SyncHudData(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncMagicInventory(event.getEntity().getCapability(ModCapabilities.MAGIC_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncItemsInventory(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncDriveInventory(event.getEntity().getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncDriveData(event.getEntity().getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncMagicData(event.getEntity().getCapability(ModCapabilities.MAGIC_STATE, null), event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncKeybladeData(event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncLevelData(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.getEntity());
        PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getEntity());
        FirstTimeJoinCapability.IFirstTimeJoin FTJ = event.getEntity().getCapability(ModCapabilities.FIRST_TIME_JOIN, null);
        if (!FTJ.getFirstTimeJoin()) {
            ((EntityPlayer) event.getEntity()).inventory.addItemStackToInventory(new ItemStack(ModItems.WoodenKeyblade));
            FTJ.setFirstTimeJoin(true);
            FTJ.setPosX(((EntityPlayer) event.getEntity()).getPosition().getX());
            FTJ.setPosY(((EntityPlayer) event.getEntity()).getPosition().getY());
            FTJ.setPosZ(((EntityPlayer) event.getEntity()).getPosition().getZ());
            if (((EntityPlayer) event.getEntity()).dimension != ModDimensions.diveToTheHeartID && MainConfig.worldgen.EnableStationOfAwakening)
                if (!event.getWorld().isRemote)
                    new TeleporterDiveToTheHeart(event.getWorld().getMinecraftServer().getServer().getWorld(ModDimensions.diveToTheHeartID)).teleport(((EntityPlayer) event.getEntity()));
        }
        ((EntityPlayer) event.getEntity()).getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null).getHP());
        if (((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() < 3) {
            ((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(3);
        }
        try {
            if (event.getEntity() instanceof EntityPlayerMP) {
                EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
                GameProfile profileWehavecookies56 = player.mcServer.getPlayerProfileCache().getGameProfileForUsername("Wehavecookies56");
                UUID uuidWehavecookies56 = profileWehavecookies56.getId();
                final MunnyCapability.IMunny munny = ((EntityPlayer) event.getEntity()).getCapability(ModCapabilities.MUNNY, null);
                if (event.getEntity().getUniqueID() == uuidWehavecookies56) {
                    munny.setMunny(munny.getMunny() + 10000);
                }
                GameProfile profileAbelatox = player.mcServer.getPlayerProfileCache().getGameProfileForUsername("Abelatox");
                UUID uuidAbelatox = profileAbelatox.getId();
                if (event.getEntity().getUniqueID() == uuidAbelatox) {
                    munny.setMunny(munny.getMunny() + 10000);
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : ItemStackHandler(net.minecraftforge.items.ItemStackHandler) SyncMagicInventory(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicInventory) SyncLevelData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData) SyncItemsInventory(uk.co.wehavecookies56.kk.common.network.packet.client.SyncItemsInventory) SyncHudData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncHudData) SyncKeybladeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) SyncDriveInventory(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveInventory) FirstTimeJoinCapability(uk.co.wehavecookies56.kk.common.capability.FirstTimeJoinCapability) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) GameProfile(com.mojang.authlib.GameProfile) TeleporterDiveToTheHeart(uk.co.wehavecookies56.kk.common.world.dimension.TeleporterDiveToTheHeart) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) MunnyCapability(uk.co.wehavecookies56.kk.common.capability.MunnyCapability) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 12 with SyncDriveData

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

the class EntityEvents method onHurt.

/* @SubscribeEvent
    public void onLivingUpdate (LivingEvent.LivingUpdateEvent event) {
        if (event.getEntityLiving() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getEntityLiving();

            if(player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() == 0 && player.isAirBorne){
                player.motionX=0;
                player.motionY=0;
                player.motionZ=0;
            }
        }
    }*/
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        PlayerStatsCapability.IPlayerStats STATS = event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null);
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (event.getAmount() - STATS.getDefense() <= 0)
            event.setAmount(1);
        else
            event.setAmount((float) (event.getAmount() - (STATS.getDefense() * 0.25)));
        if (event.getSource().getDamageType().equals("lightningBolt"))
            if (EntityThunder.summonLightning)
                event.setCanceled(true);
    }
    if (event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        player.getCapability(ModCapabilities.DRIVE_STATE, null).addDP(1);
        PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
    }
    if (event.getEntityLiving() instanceof IKHMob) {
        EntityPlayer player = null;
        IKHMob khMob = (IKHMob) event.getEntityLiving();
        if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
            player = (EntityPlayer) event.getSource().getImmediateSource();
        }
        if (player != null) {
            if (khMob.getType() == MobType.HEARTLESS_EMBLEM || khMob.getType() == MobType.HEARTLESS_PUREBLOOD || khMob.getType() == MobType.NOBODY) {
                // If the player has a real weapon in any slot
                if (!(player.getHeldItemMainhand().getItem() instanceof ItemKeyblade || player.getHeldItemMainhand().getItem() instanceof IOrgWeapon || player.getHeldItemOffhand().getItem() instanceof ItemKeyblade || player.getHeldItemOffhand().getItem() instanceof IOrgWeapon)) {
                    event.setCanceled(true);
                }
            // }
            }
        }
    }
    if (event.getSource().getImmediateSource() instanceof EntityPlayer && !event.getSource().damageType.equals(EnumHand.OFF_HAND.name())) {
        EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
        if (event.getSource().getDamageType().equals("thorns"))
            return;
        if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
            if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade || player.getHeldItem(player.getActiveHand()).getItem() instanceof IOrgWeapon) {
                event.setAmount(event.getAmount() - 4 + DamageCalculation.getStrengthDamage(player));
            }
        }
    }
}
Also used : IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 13 with SyncDriveData

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

the class ItemEvents method onEntityItemPickUp.

@SubscribeEvent
public void onEntityItemPickUp(EntityItemPickupEvent event) {
    IPlayerStats STATS = event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null);
    IDriveState DRIVE = event.getEntityPlayer().getCapability(ModCapabilities.DRIVE_STATE, null);
    if (event.getItem().getItem().getItem() instanceof ItemMunny) {
        final MunnyCapability.IMunny munny = event.getEntityPlayer().getCapability(ModCapabilities.MUNNY, null);
        MunnyPickup packet = new MunnyPickup(event.getItem().getItem());
        event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
        ;
        munny.addMunny(event.getItem().getItem().getTagCompound().getInteger("amount"));
        PacketDispatcher.sendTo(new SyncMunnyData(munny), (EntityPlayerMP) event.getEntityPlayer());
        PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getEntityPlayer());
    } else if (event.getItem().getItem().getItem() instanceof ItemHpOrb) {
        if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
            if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
                return;
        HpOrbPickup packet = new HpOrbPickup(event.getItem().getItem());
        if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
            if (event.getEntityPlayer().getHealth() >= event.getEntityPlayer().getMaxHealth()) {
                event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
                ;
                return;
            }
            if (event.getEntityPlayer().getHealth() < event.getEntityPlayer().getMaxHealth() - 1)
                event.getEntityPlayer().heal(2);
            else
                event.getEntityPlayer().heal(1);
            event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
            ;
        }
    } else if (event.getItem().getItem().getItem() == ModItems.DriveOrb) {
        if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
            event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
            ;
            DRIVE.addDP(event.getItem().getItem().getTagCompound().getInteger("amount"));
            EntityPlayer player = event.getEntityPlayer();
            PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
            PacketDispatcher.sendTo(new SyncDriveInventory(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntityPlayer());
        }
    } else if (event.getItem().getItem().getItem() == ModItems.MagicOrb) {
        double mp = STATS.getMP();
        if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
            if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
                return;
        if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
            event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
            ;
            STATS.addMP(event.getItem().getItem().getTagCompound().getInteger("amount"));
            PacketDispatcher.sendTo(new SyncMagicData(event.getEntityPlayer().getCapability(ModCapabilities.MAGIC_STATE, null), STATS), (EntityPlayerMP) event.getEntityPlayer());
        }
    } else if (event.getItem().getItem().getItem() instanceof ItemSynthesisMaterial) {
        for (int i = 0; i < event.getEntityPlayer().inventory.getSizeInventory(); i++) {
            if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().inventory.getStackInSlot(i), ItemStack.EMPTY)) {
                if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagL) {
                    IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
                    addSynthesisMaterialToBag(inv, event);
                } else if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagM) {
                    IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
                    addSynthesisMaterialToBag(inv, event);
                }
                if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagS) {
                    IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
                    addSynthesisMaterialToBag(inv, event);
                }
            }
        }
    }
}
Also used : MunnyPickup(uk.co.wehavecookies56.kk.common.network.packet.server.MunnyPickup) IItemHandler(net.minecraftforge.items.IItemHandler) ItemSynthesisMaterial(uk.co.wehavecookies56.kk.common.item.base.ItemSynthesisMaterial) ShowOverlayPacket(uk.co.wehavecookies56.kk.common.network.packet.client.ShowOverlayPacket) HpOrbPickup(uk.co.wehavecookies56.kk.common.network.packet.server.HpOrbPickup) IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) SyncMunnyData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMunnyData) ItemHpOrb(uk.co.wehavecookies56.kk.common.item.ItemHpOrb) ItemMunny(uk.co.wehavecookies56.kk.common.item.ItemMunny) SyncDriveInventory(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveInventory) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MunnyCapability(uk.co.wehavecookies56.kk.common.capability.MunnyCapability) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with SyncDriveData

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

the class DriveFormMaster method getXP.

@SubscribeEvent
public static void getXP(EntityItemPickupEvent event) {
    EntityPlayer player = event.getEntityPlayer();
    DriveStateCapability.IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
    if (DRIVE.getActiveDriveName().equals(Strings.Form_Master)) {
        if (event.getItem().getItem().getItem() == ModItems.DriveOrb) {
            int amount = (event.getItem().getItem().getTagCompound().getInteger("amount") / 5) > 0 ? event.getItem().getItem().getTagCompound().getInteger("amount") / 5 : 1;
            DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName()) + amount);
            System.out.println(DRIVE.getDriveExp(DRIVE.getActiveDriveName()) + (event.getItem().getItem().getTagCompound().getInteger("amount") / 5));
            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) DriveStateCapability(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 15 with SyncDriveData

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

the class DriveFormWisdom method getXP.

@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
    if (!event.getEntity().world.isRemote && event.getEntity() instanceof IKHMob) {
        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_Wisdom)) {
                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) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) IDriveState(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SyncDriveData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)9 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 IDriveState (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability.IDriveState)4 SyncLevelData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData)4 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 DriveStateCapability (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability)3 PlayerStatsCapability (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability)3 SyncDriveInventory (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveInventory)3 SyncMagicData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData)3 MunnyCapability (uk.co.wehavecookies56.kk.common.capability.MunnyCapability)2 IPlayerStats (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats)2 IKHMob (uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob)2 IOrgWeapon (uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon)2 SyncKeybladeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData)2 SyncMunnyData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMunnyData)2 SyncOrgXIIIData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData)2 GameProfile (com.mojang.authlib.GameProfile)1 UUID (java.util.UUID)1