Search in sources :

Example 1 with ClassType

use of com.wynntils.core.framework.enums.ClassType in project Wynntils by Wynntils.

the class InventoryData method getFreeInventorySlots.

/**
 * @return The number of free slots in the user's inventory
 *
 * -1 if unable to determine
 */
public int getFreeInventorySlots() {
    EntityPlayerSP player = getPlayer();
    ClassType currentClass = get(CharacterData.class).getCurrentClass();
    if (currentClass == ClassType.NONE || player == null)
        return -1;
    return (int) player.inventory.mainInventory.stream().filter(ItemStack::isEmpty).count();
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ClassType(com.wynntils.core.framework.enums.ClassType) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ClassType

use of com.wynntils.core.framework.enums.ClassType in project Wynntils by Wynntils.

the class ClientEvents method changeClass.

/**
 * Detects the user class based on the class selection GUI
 * This detection happens when the user click on an item that contains the class name pattern, inside the class selection GUI
 *
 * @param e Represents the click event
 */
@SubscribeEvent
public void changeClass(GuiOverlapEvent.ChestOverlap.HandleMouseClick e) {
    if (!e.getGui().getLowerInv().getName().contains("Select a Class"))
        return;
    if (e.getMouseButton() != 0 || e.getSlotIn() == null || !e.getSlotIn().getHasStack() || !e.getSlotIn().getStack().hasDisplayName() || !e.getSlotIn().getStack().getDisplayName().contains("[>] Select"))
        return;
    get(CharacterData.class).setClassId(e.getSlotId());
    String classLore = ItemUtils.getLore(e.getSlotIn().getStack()).get(1);
    String className = classLore.substring(classLore.indexOf(TextFormatting.WHITE.toString()) + 2);
    ClassType selectedClass = ClassType.fromName(className);
    boolean selectedClassIsReskinned = ClassType.isReskinned(className);
    get(CharacterData.class).updatePlayerClass(selectedClass, selectedClassIsReskinned);
}
Also used : CharacterData(com.wynntils.core.framework.instances.data.CharacterData) ClassType(com.wynntils.core.framework.enums.ClassType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ClassType

use of com.wynntils.core.framework.enums.ClassType in project Wynntils by Wynntils.

the class InventoryData method getSoulPoints.

/**
 * @return The current number of soul points the current player has
 *
 * -1 if unable to determine
 */
public int getSoulPoints() {
    EntityPlayerSP player = getPlayer();
    ClassType currentClass = get(CharacterData.class).getCurrentClass();
    if (currentClass == ClassType.NONE || player == null)
        return -1;
    ItemStack soulPoints = player.inventory.mainInventory.get(8);
    if (soulPoints.getItem() != Items.NETHER_STAR && soulPoints.getItem() != Item.getItemFromBlock(Blocks.SNOW_LAYER)) {
        return -1;
    }
    return soulPoints.getCount();
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ClassType(com.wynntils.core.framework.enums.ClassType) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ClassType

use of com.wynntils.core.framework.enums.ClassType in project Wynntils by Wynntils.

the class InventoryData method getTicksToNextSoulPoint.

/**
 * @return Time in game ticks (1/20th of a second, 50ms) until next soul point
 *
 * -1 if unable to determine
 *
 * Also check that {@code {@link #getMaxSoulPoints()} >= {@link #getSoulPoints()}},
 * in which case soul points are already full
 */
public int getTicksToNextSoulPoint() {
    EntityPlayerSP player = getPlayer();
    ClassType currentClass = get(CharacterData.class).getCurrentClass();
    if (currentClass == ClassType.NONE || player.world == null)
        return -1;
    int ticks = ((int) (player.world.getWorldTime() % 24000) + 24000) % 24000;
    return ((24000 - ticks) % 24000);
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ClassType(com.wynntils.core.framework.enums.ClassType)

Example 5 with ClassType

use of com.wynntils.core.framework.enums.ClassType in project Wynntils by Wynntils.

the class InventoryData method getIngredientPouchCount.

/**
 * @return The amount of items inside the players ingredient pouch (parsed from the items lore)
 * If countSlotsOnly is true, it only counts the number of used slots
 *
 * -1 if unable to determine
 */
public int getIngredientPouchCount(boolean countSlotsOnly) {
    EntityPlayerSP player = getPlayer();
    ClassType currentClass = get(CharacterData.class).getCurrentClass();
    if (currentClass == ClassType.NONE || player == null)
        return -1;
    ItemStack pouch = player.inventory.mainInventory.get(13);
    NBTTagCompound nbt = pouch.getTagCompound();
    int count = 0;
    List<String> lore = ItemUtils.getLore(pouch);
    if (nbt != null && nbt.hasKey("originalItems")) {
        int[] slots = nbt.getIntArray("originalItems");
        for (int slot : slots) {
            if (slot == 0)
                break;
            if (countSlotsOnly)
                count += 1;
            else
                count += slot;
        }
    } else {
        boolean foundFirstItem = false;
        for (String line : lore) {
            if (line == null)
                continue;
            Matcher matcher = INGREDIENT_SPLIT_PATTERN.matcher(line);
            // Account for ironman
            if (!matcher.matches() && foundFirstItem)
                break;
            else if (!matcher.matches())
                continue;
            foundFirstItem = true;
            int itemCount = Integer.parseInt(matcher.group(1));
            if (countSlotsOnly)
                count += 1;
            else
                count += itemCount;
        }
    }
    return count;
}
Also used : Matcher(java.util.regex.Matcher) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ClassType(com.wynntils.core.framework.enums.ClassType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ClassType (com.wynntils.core.framework.enums.ClassType)8 CharacterData (com.wynntils.core.framework.instances.data.CharacterData)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 ItemStack (net.minecraft.item.ItemStack)4 SpellType (com.wynntils.core.framework.enums.SpellType)3 ItemProfile (com.wynntils.webapi.profiles.item.ItemProfile)3 IdentificationContainer (com.wynntils.webapi.profiles.item.objects.IdentificationContainer)3 MajorIdentification (com.wynntils.webapi.profiles.item.objects.MajorIdentification)3 Matcher (java.util.regex.Matcher)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ItemRequirementsContainer (com.wynntils.webapi.profiles.item.objects.ItemRequirementsContainer)2 ArrayList (java.util.ArrayList)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 Powder (com.wynntils.core.framework.enums.Powder)1 IdentificationType (com.wynntils.modules.utilities.configs.enums.IdentificationType)1 IdentificationResult (com.wynntils.modules.utilities.instances.IdentificationResult)1 IdentificationOrderer (com.wynntils.webapi.profiles.item.IdentificationOrderer)1