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();
}
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);
}
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();
}
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);
}
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;
}
Aggregations