public class BattleItemScanner
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BattleItemScanner.InventoryScanner
Class holding functional interface instances which handle the logic of an individual inventory type.
|
static interface |
BattleItemScanner.ItemConsumer |
static interface |
BattleItemScanner.ItemFinder |
static interface |
BattleItemScanner.ItemScanner |
Modifier and Type | Method and Description |
---|---|
static void |
addItem(BagSection section,
net.minecraft.item.ItemStack stack,
java.util.List<ItemData> items)
Attempts to add an
ItemStack to the list of ItemData s, if it is valid for the given
BagSection , and if it isn't appended to an existing ItemData via the
attemptUpdate(ItemStack, List) method. |
static void |
addScanner(BattleItemScanner.InventoryScanner scanner)
Register a new inventory scanner to look for battle items in.
|
static boolean |
attemptUpdate(net.minecraft.item.ItemStack stack,
java.util.List<ItemData> items)
Attempts to combine
ItemStack s into one ItemData entry if a matching entry is already present. |
static void |
checkInventory(net.minecraft.entity.player.ServerPlayerEntity player,
BagSection section,
net.minecraft.inventory.IInventory inventory,
java.util.List<ItemData> items)
Iterates over a given
IInventory and checks for battle items of the given BagSection , populating
the given list of ItemData with any matches. |
static void |
checkInventory(net.minecraft.entity.player.ServerPlayerEntity player,
BagSection section,
java.util.List<net.minecraft.item.ItemStack> inventory,
boolean checkSubInventories,
java.util.List<ItemData> items)
Iterates over a given list of
ItemStack s and checks for battle items of the given BagSection ,
populating the given list of ItemData with any matches. |
static void |
checkInventory(net.minecraft.entity.player.ServerPlayerEntity player,
BagSection section,
java.util.List<net.minecraft.item.ItemStack> inventory,
java.util.List<ItemData> items)
Iterates over a given list of
ItemStack s and checks for battle items of the given BagSection ,
populating the given list of ItemData with any matches. |
static net.minecraft.item.ItemStack |
consumeItem(net.minecraft.item.ItemStack toMatch,
net.minecraft.entity.player.ServerPlayerEntity player)
Attempts to consume an
ItemStack matching a given ItemStack within a player's inventory, seeking
through any sub-inventories within items known about. |
static net.minecraft.item.ItemStack |
consumeItem(net.minecraft.item.ItemStack toMatch,
net.minecraft.entity.player.ServerPlayerEntity player,
net.minecraft.inventory.IInventory inventory)
Attempts to consume an
ItemStack matching a given ItemStack within a given inventory, seeking
through any sub-inventories within items known about. |
static net.minecraft.item.ItemStack |
findItemFromIterable(net.minecraft.item.ItemStack toMatch,
int size,
java.util.function.IntFunction<net.minecraft.item.ItemStack> getter)
Attempts to find an
ItemStack matching a given ItemStack for an iterable collection of items
represented by an IntFunction of index to ItemStack . |
static net.minecraft.item.ItemStack |
findMatchingItem(net.minecraft.item.ItemStack toMatch,
net.minecraft.entity.player.ServerPlayerEntity player)
Attempts to find an
ItemStack matching a given ItemStack within a player's inventory, seeking
through any sub-inventories within items known about. |
static net.minecraft.item.ItemStack |
findMatchingItem(net.minecraft.item.ItemStack toMatch,
net.minecraft.entity.player.ServerPlayerEntity player,
net.minecraft.inventory.IInventory inventory)
Attempts to find an
ItemStack matching a given ItemStack within a given inventory, seeking
through any sub-inventories within items known about. |
static java.util.List<ItemData> |
scan(net.minecraft.entity.player.ServerPlayerEntity player,
BagSection section)
Performs an inventory scan for battle items.
|
public static void addScanner(BattleItemScanner.InventoryScanner scanner)
ItemData
list for delivery to the client, and the second function is
used to find the item again once the client has chosen.scanner
- The inventory scanner to register.public static java.util.List<ItemData> scan(net.minecraft.entity.player.ServerPlayerEntity player, BagSection section)
player
- The player to scan.section
- The type of item to scan for.public static void checkInventory(net.minecraft.entity.player.ServerPlayerEntity player, BagSection section, net.minecraft.inventory.IInventory inventory, java.util.List<ItemData> items)
IInventory
and checks for battle items of the given BagSection
, populating
the given list of ItemData
with any matches.player
- The player to scan.section
- The type of item to scan for.inventory
- The inventory to scan.items
- Output for the items found during the scan.public static void checkInventory(net.minecraft.entity.player.ServerPlayerEntity player, BagSection section, java.util.List<net.minecraft.item.ItemStack> inventory, java.util.List<ItemData> items)
ItemStack
s and checks for battle items of the given BagSection
,
populating the given list of ItemData
with any matches.player
- The player to scan.section
- The type of item to scan for.inventory
- The items to scan.items
- Output for the items found during the scan.public static void checkInventory(net.minecraft.entity.player.ServerPlayerEntity player, BagSection section, java.util.List<net.minecraft.item.ItemStack> inventory, boolean checkSubInventories, java.util.List<ItemData> items)
ItemStack
s and checks for battle items of the given BagSection
,
populating the given list of ItemData
with any matches.player
- The player to scan.section
- The type of item to scan for.inventory
- The items to scan.checkSubInventories
- Whether to attempt to look inside sub-inventories or not.items
- Output for the items found during the scan.public static void addItem(BagSection section, net.minecraft.item.ItemStack stack, java.util.List<ItemData> items)
ItemStack
to the list of ItemData
s, if it is valid for the given
BagSection
, and if it isn't appended to an existing ItemData
via the
attemptUpdate(ItemStack, List)
method.section
- The type of item being scanned for.stack
- The stack to test.items
- The items already found.public static boolean attemptUpdate(net.minecraft.item.ItemStack stack, java.util.List<ItemData> items)
ItemStack
s into one ItemData
entry if a matching entry is already present.stack
- The stack to check against already found items.items
- The items already found.ItemData
or not.public static net.minecraft.item.ItemStack findMatchingItem(net.minecraft.item.ItemStack toMatch, net.minecraft.entity.player.ServerPlayerEntity player)
ItemStack
matching a given ItemStack
within a player's inventory, seeking
through any sub-inventories within items known about.toMatch
- The ItemStack
to match other items against.player
- The player being searched.public static net.minecraft.item.ItemStack findMatchingItem(net.minecraft.item.ItemStack toMatch, net.minecraft.entity.player.ServerPlayerEntity player, net.minecraft.inventory.IInventory inventory)
ItemStack
matching a given ItemStack
within a given inventory, seeking
through any sub-inventories within items known about.toMatch
- The ItemStack
to match other items against.player
- The player being searched.public static net.minecraft.item.ItemStack findItemFromIterable(net.minecraft.item.ItemStack toMatch, int size, java.util.function.IntFunction<net.minecraft.item.ItemStack> getter)
ItemStack
matching a given ItemStack
for an iterable collection of items
represented by an IntFunction
of index to ItemStack
.toMatch
- The ItemStack
to match other items against.size
- The size of the given iterable collection.getter
- The function to map index to ItemStack
s to compare to.public static net.minecraft.item.ItemStack consumeItem(net.minecraft.item.ItemStack toMatch, net.minecraft.entity.player.ServerPlayerEntity player)
ItemStack
matching a given ItemStack
within a player's inventory, seeking
through any sub-inventories within items known about.toMatch
- The ItemStack
to match other items against.player
- The player being searched.public static net.minecraft.item.ItemStack consumeItem(net.minecraft.item.ItemStack toMatch, net.minecraft.entity.player.ServerPlayerEntity player, net.minecraft.inventory.IInventory inventory)
ItemStack
matching a given ItemStack
within a given inventory, seeking
through any sub-inventories within items known about.toMatch
- The ItemStack
to match other items against.player
- The player being searched.