Search in sources :

Example 1 with IRememberedInventory

use of baritone.api.cache.IRememberedInventory in project Spark-Client by Spark-Client-Development.

the class ChestsCommand method execute.

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
    args.requireMax(0);
    Set<Map.Entry<BlockPos, IRememberedInventory>> entries = ctx.worldData().getContainerMemory().getRememberedInventories().entrySet();
    if (entries.isEmpty()) {
        throw new CommandInvalidStateException("No remembered inventories");
    }
    for (Map.Entry<BlockPos, IRememberedInventory> entry : entries) {
        // betterblockpos has censoring
        BetterBlockPos pos = new BetterBlockPos(entry.getKey());
        IRememberedInventory inv = entry.getValue();
        logDirect(pos.toString());
        for (ItemStack item : inv.getContents()) {
            ITextComponent component = item.getTextComponent();
            component.appendText(String.format(" x %d", item.getCount()));
            logDirect(component);
        }
    }
}
Also used : IRememberedInventory(baritone.api.cache.IRememberedInventory) BetterBlockPos(baritone.api.utils.BetterBlockPos) ITextComponent(net.minecraft.util.text.ITextComponent) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos) CommandInvalidStateException(baritone.api.command.exception.CommandInvalidStateException) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Aggregations

IRememberedInventory (baritone.api.cache.IRememberedInventory)1 CommandInvalidStateException (baritone.api.command.exception.CommandInvalidStateException)1 BetterBlockPos (baritone.api.utils.BetterBlockPos)1 Map (java.util.Map)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 ITextComponent (net.minecraft.util.text.ITextComponent)1