use of at.haha007.edenclient.utils.config.wrappers.ItemList in project EdenClient by HahaOO7.
the class ItemListLoader method save.
public NbtList save(Object value) {
ItemList list = cast(value);
NbtList tag = new NbtList();
list.forEach(item -> tag.add(PerWorldConfig.get().toNbt(item)));
return tag;
}
use of at.haha007.edenclient.utils.config.wrappers.ItemList in project EdenClient by HahaOO7.
the class ContainerInfo method onOpenInventory.
private void onOpenInventory(List<ItemStack> itemStacks) {
if (lastInteractedBlock == null)
return;
// smallest only chests and shulkerboxes!
if (itemStacks.size() < 27)
return;
ChunkPos cp = new ChunkPos(new BlockPos(lastInteractedBlock));
Registry<Block> registry = PlayerUtils.getPlayer().world.getRegistryManager().get(BlockTags.SHULKER_BOXES.registry());
Map<Item, List<ItemStack>> items = itemStacks.stream().flatMap(stack -> registry.containsId(Registry.BLOCK.getId(Block.getBlockFromItem(stack.getItem()))) ? mapShulkerBox(stack) : Stream.of(stack)).collect(Collectors.groupingBy(ItemStack::getItem));
items.remove(Items.AIR);
Map<Item, Integer> counts = new HashMap<>();
items.forEach((item, stacks) -> counts.put(item, stacks.stream().mapToInt(ItemStack::getCount).sum()));
ItemList list = new ItemList();
list.addAll(counts.keySet());
list.sort(Comparator.comparingInt(i -> -counts.get(i)));
ChestMap map = chunkMap.computeIfAbsent(cp, chunkPos -> new ChestMap());
if (list.isEmpty())
map.remove(lastInteractedBlock);
else
map.put(lastInteractedBlock, list);
}
use of at.haha007.edenclient.utils.config.wrappers.ItemList in project EdenClient by HahaOO7.
the class ItemListLoader method load.
public ItemList load(NbtList tag) {
ItemList list = new ItemList();
tag.forEach(entry -> list.add(PerWorldConfig.get().toObject(entry, Item.class)));
return list;
}
Aggregations