Search in sources :

Example 26 with PlayerDataManager

use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.

the class ExtractionDevice method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!full)
        return false;
    if (!world.isRemote && player.getHeldItem(hand).getItem() instanceof InfusionBowl) {
        PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
        ItemStack heldStack = player.getHeldItem(hand);
        if (world.getBlockState(pos.down()).getMaterial().isReplaceable() || world.isOutsideBuildHeight(pos.down())) {
            int lvl = plData.stats().getLevel(Enums.Skills.EXTRACTION);
            world.setBlockState(pos, BlockRegister.EXTRACTION_DEVICE.getDefaultState());
            if (plData.equipment().getCurrentFullArmourSet() != Enums.ArmourSets.EXTRACTION)
                world.setBlockState(pos.down(), Blocks.OBSIDIAN.getDefaultState());
            if (ExtractionUtil.shouldGetLoot(lvl)) {
                if (!player.capabilities.isCreativeMode)
                    heldStack.damageItem(1, player);
                List<ItemStack> loot = ExtractionUtil.getLoot(player);
                for (ItemStack stack : loot) {
                    if (!stack.isEmpty()) {
                        player.sendMessage(StringUtil.getLocale("message.feedback.extraction").appendSibling(new TextComponentTranslation(stack.getTranslationKey() + ".name")));
                    } else {
                        player.sendMessage(StringUtil.getLocale("message.feedback.extraction.nothing"));
                    }
                    ItemHandlerHelper.giveItemToPlayer(player, stack);
                }
                player.addStat(StatList.getObjectUseStats(heldStack.getItem()));
                plData.stats().addXp(Enums.Skills.EXTRACTION, PlayerUtil.getXpRequiredForNextLevel(lvl) / ExtractionUtil.getXpDenominator(lvl), false, false);
                world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundsRegister.EXTRACTION_SUCCESS, SoundCategory.BLOCKS, 1.0f, 1.0f);
                if (player.dimension == 0)
                    plData.stats().addTribute(Enums.Deities.PLUTON, 4);
            } else {
                player.sendMessage(StringUtil.getLocale("message.feedback.extraction.fail"));
            }
        } else {
            player.sendMessage(StringUtil.getColourLocale("message.feedback.extraction.noSpace", TextFormatting.RED));
        }
    }
    return true;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) InfusionBowl(net.tslat.aoa3.item.tool.misc.InfusionBowl) ItemStack(net.minecraft.item.ItemStack) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Example 27 with PlayerDataManager

use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.

the class GoldAccumulator method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote && player.getHeldItem(hand).getItem() == ItemRegister.IMPURE_GOLD) {
        PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
        if (!player.capabilities.isCreativeMode)
            player.getHeldItem(hand).shrink(1);
        plData.stats().addTribute(Enums.Deities.PLUTON, Math.min(100 - plData.stats().getTribute(Enums.Deities.PLUTON), 20));
        if (plData.stats().getTribute(Enums.Deities.PLUTON) >= 100)
            plData.sendThrottledChatMessage("message.feedback.immortallisProgression.goldEnd", player.getDisplayNameString());
    }
    return true;
}
Also used : PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Example 28 with PlayerDataManager

use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.

the class InfusionTable method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        ItemStack stack = player.getHeldItem(hand);
        Item item = stack.getItem();
        if (item instanceof InfusionStone) {
            PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
            InfusionStone stone = (InfusionStone) item;
            int count = stack.getCount();
            if (player.capabilities.isCreativeMode || plData.stats().getLevel(Enums.Skills.INFUSION) >= stone.getLvl()) {
                plData.stats().addXp(Enums.Skills.INFUSION, stone.getXp() * count, false, false);
                world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundsRegister.INFUSION_SUCCESS, SoundCategory.BLOCKS, 1.0f, 1.0f);
                int chanceMod = plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.INFUSION ? 33 : 100;
                int powerStoneCount = 0;
                for (int i = 0; i < count; i++) {
                    if (AdventOfAscension.rand.nextInt(chanceMod) == 0)
                        powerStoneCount++;
                }
                if (!player.capabilities.isCreativeMode) {
                    if (powerStoneCount > 0) {
                        player.setHeldItem(hand, new ItemStack(stone.getPowerStone(), powerStoneCount));
                    } else {
                        player.setHeldItem(hand, ItemStack.EMPTY);
                    }
                } else {
                    ItemUtil.givePlayerItemOrDrop(player, new ItemStack(stone.getPowerStone(), powerStoneCount));
                }
            }
        } else {
            player.openGui(AdventOfAscension.instance(), Enums.ModGuis.INFUSION_TABLE.guiId, world, pos.getX(), pos.getY(), pos.getZ());
        }
    }
    return true;
}
Also used : Item(net.minecraft.item.Item) InfusionStone(net.tslat.aoa3.item.misc.InfusionStone) ItemStack(net.minecraft.item.ItemStack) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Example 29 with PlayerDataManager

use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.

the class AncientCavernShrine method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote && !player.isSneaking() && world.provider.getDimension() == ConfigurationUtil.MainConfig.dimensionIds.ancientCavern && player.hasCapability(AdventPlayerProvider.ADVENT_PLAYER, null)) {
        PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
        BlockPos teleportPos = new BlockPos(0, 17, 0);
        switch(deity) {
            case EREBON:
                if (pos.getX() > -20 || pos.getZ() < 60) {
                    teleportPos = new BlockPos(-70, 18, 80);
                    if (!player.capabilities.isCreativeMode) {
                        if (/*plData.stats().getLevel(Enums.Skills.AUGURY) < 70 || */
                        plData.stats().getLevel(Enums.Skills.HUNTER) < 70) {
                            if (player instanceof EntityPlayerMP) {
                                // PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP)player, Enums.Skills.AUGURY, 70);
                                PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP) player, Enums.Skills.HUNTER, 70);
                            }
                            return true;
                        }
                        if (plData.stats().getTribute(Enums.Deities.EREBON) < 200) {
                            if (player instanceof EntityPlayerMP)
                                PlayerUtil.notifyPlayerOfInsufficientTribute((EntityPlayerMP) player, Enums.Deities.EREBON, 200);
                            return true;
                        } else {
                            plData.stats().addTribute(Enums.Deities.EREBON, -20);
                        }
                    }
                    EntityPenumbra penumbra = new EntityPenumbra(world);
                    penumbra.setLocationAndAngles(-51, 18, 92, 0, 0);
                    world.spawnEntity(penumbra);
                }
                break;
            case LUXON:
                if (pos.getX() < 60 || pos.getZ() > -20) {
                    teleportPos = new BlockPos(80, 18, -70);
                    if (!player.capabilities.isCreativeMode) {
                        if (/*plData.stats().getLevel(Enums.Skills.AUGURY) < 70 || */
                        plData.stats().getLevel(Enums.Skills.RUNATION) < 70) {
                            if (player instanceof EntityPlayerMP) {
                                // PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP)player, Enums.Skills.AUGURY, 70);
                                PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP) player, Enums.Skills.RUNATION, 70);
                            }
                            return true;
                        }
                        if (plData.stats().getTribute(Enums.Deities.LUXON) < 200) {
                            if (player instanceof EntityPlayerMP)
                                PlayerUtil.notifyPlayerOfInsufficientTribute((EntityPlayerMP) player, Enums.Deities.LUXON, 200);
                            return true;
                        } else {
                            plData.stats().addTribute(Enums.Deities.LUXON, -20);
                        }
                    }
                    EntityHoron horon = new EntityHoron(world);
                    horon.setLocationAndAngles(80, 18, -70, 0, 0);
                    world.spawnEntity(horon);
                }
                break;
            case PLUTON:
                if (pos.getX() < 60 || pos.getZ() < 60) {
                    teleportPos = new BlockPos(80, 18, 80);
                    if (!player.capabilities.isCreativeMode) {
                        if (/*plData.stats().getLevel(Enums.Skills.AUGURY) < 70 || */
                        plData.stats().getLevel(Enums.Skills.FORAGING) < 70) {
                            if (player instanceof EntityPlayerMP) {
                                // PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP)player, Enums.Skills.AUGURY, 70);
                                PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP) player, Enums.Skills.FORAGING, 70);
                            }
                            return true;
                        }
                        if (plData.stats().getTribute(Enums.Deities.PLUTON) < 200) {
                            if (player instanceof EntityPlayerMP)
                                PlayerUtil.notifyPlayerOfInsufficientTribute((EntityPlayerMP) player, Enums.Deities.PLUTON, 200);
                            return true;
                        } else {
                            plData.stats().addTribute(Enums.Deities.PLUTON, -20);
                        }
                    }
                    EntityGoldorth goldorth = new EntityGoldorth(world);
                    goldorth.setLocationAndAngles(80, 18, 80, 0, 0);
                    world.spawnEntity(goldorth);
                }
                break;
            case SELYAN:
                if (pos.getX() > -20 || pos.getZ() > -20) {
                    teleportPos = new BlockPos(-60, 18, -65);
                    if (!player.capabilities.isCreativeMode) {
                        if (/*plData.stats().getLevel(Enums.Skills.AUGURY) < 70 || */
                        plData.stats().getLevel(Enums.Skills.INFUSION) < 70) {
                            if (player instanceof EntityPlayerMP) {
                                // PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP)player, Enums.Skills.AUGURY, 70);
                                PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP) player, Enums.Skills.INFUSION, 70);
                            }
                            return true;
                        }
                        if (plData.stats().getTribute(Enums.Deities.SELYAN) < 200) {
                            if (player instanceof EntityPlayerMP)
                                PlayerUtil.notifyPlayerOfInsufficientTribute((EntityPlayerMP) player, Enums.Deities.SELYAN, 200);
                            return true;
                        } else {
                            plData.stats().addTribute(Enums.Deities.SELYAN, -20);
                        }
                    }
                    EntityConiferon coniferon = new EntityConiferon(world);
                    coniferon.setLocationAndAngles(-60, 18, -65, 0, 0);
                    world.spawnEntity(coniferon);
                }
                break;
        }
        player.setPositionAndUpdate(teleportPos.getX(), teleportPos.getY(), teleportPos.getZ());
    }
    return true;
}
Also used : EntityGoldorth(net.tslat.aoa3.entity.boss.goldorth.EntityGoldorth) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityConiferon(net.tslat.aoa3.entity.boss.coniferon.EntityConiferon) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager) EntityPenumbra(net.tslat.aoa3.entity.boss.penumbra.EntityPenumbra) EntityHoron(net.tslat.aoa3.entity.boss.horon.EntityHoron)

Example 30 with PlayerDataManager

use of net.tslat.aoa3.utils.player.PlayerDataManager in project Advent-Of-Ascension by Tslat.

the class RuneRandomizer method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (player.isSneaking())
        return false;
    if (world.isRemote)
        return true;
    ItemStack heldItem = player.getHeldItem(hand);
    if (heldItem.getItem() != ItemRegister.UNPOWERED_RUNE && heldItem.getItem() != ItemRegister.CHARGED_RUNE)
        return true;
    PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
    if (!player.capabilities.isCreativeMode && plData.stats().getLevel(Enums.Skills.RUNATION) < 20) {
        if (player instanceof EntityPlayerMP)
            PlayerUtil.notifyPlayerOfInsufficientLevel((EntityPlayerMP) player, Enums.Skills.RUNATION, 20);
        return false;
    }
    if (!player.capabilities.isCreativeMode)
        heldItem.shrink(1);
    LootUtil.generateAndProvideLootDirectly((EntityPlayerMP) player, LootSystemRegister.blockRuneRandomizer);
    if (plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.RUNATION)
        LootUtil.generateAndProvideLootDirectly((EntityPlayerMP) player, LootSystemRegister.blockRuneRandomizer);
    plData.stats().addXp(Enums.Skills.RUNATION, 5, false, false);
    player.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundsRegister.RUNE_RANDOMIZER_USE, SoundCategory.BLOCKS, 1.0f, 1.0f);
    return true;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Aggregations

PlayerDataManager (net.tslat.aoa3.utils.player.PlayerDataManager)49 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 ItemStack (net.minecraft.item.ItemStack)18 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)7 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)7 BlockPos (net.minecraft.util.math.BlockPos)6 Entity (net.minecraft.entity.Entity)5 EntityTameable (net.minecraft.entity.passive.EntityTameable)4 Block (net.minecraft.block.Block)3 Item (net.minecraft.item.Item)3 CapabilityBaseMiscStackSerializable (net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable)3 Enums (net.tslat.aoa3.library.Enums)3 PortalCoordinatesContainer (net.tslat.aoa3.library.misc.PortalCoordinatesContainer)3 IBlockState (net.minecraft.block.state.IBlockState)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 PotionEffect (net.minecraft.potion.PotionEffect)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 WorldServer (net.minecraft.world.WorldServer)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1