Search in sources :

Example 11 with ItemStorage

use of com.minecolonies.api.crafting.ItemStorage in project minecolonies by Minecolonies.

the class CompatabilityManager method readFromNBT.

@Override
public void readFromNBT(@NotNull final NBTTagCompound compound) {
    leavesToSaplingMap.putAll(NBTUtils.streamCompound(compound.getTagList(TAG_SAP_LEAVE, Constants.NBT.TAG_COMPOUND)).map(CompatabilityManager::readLeaveSaplingEntryFromNBT).collect(Collectors.toMap(Tuple::getFirst, Tuple::getSecond)));
    final List<ItemStorage> storages = NBTUtils.streamCompound(compound.getTagList(TAG_SAPLINGS, Constants.NBT.TAG_COMPOUND)).map(tempCompound -> new ItemStorage(new ItemStack(tempCompound))).collect(Collectors.toList());
    // Filter duplicated values.
    for (final ItemStorage storage : storages) {
        if (!saplings.contains(storage)) {
            saplings.add(storage);
        }
    }
    final List<IBlockState> states = NBTUtils.streamCompound(compound.getTagList(TAG_ORES, Constants.NBT.TAG_COMPOUND)).map(NBTUtil::readBlockState).collect(Collectors.toList());
    for (final IBlockState state : states) {
        if (!ores.contains(state.getBlock())) {
            ores.add(state.getBlock());
        }
    }
}
Also used : ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Constants(net.minecraftforge.common.util.Constants) SAPLINGS(com.minecolonies.api.util.constant.Constants.SAPLINGS) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) NBTTagList(net.minecraft.nbt.NBTTagList) Block(net.minecraft.block.Block) OreDictionary(net.minecraftforge.oredict.OreDictionary) CreativeTabs(net.minecraft.creativetab.CreativeTabs) NonNullList(net.minecraft.util.NonNullList) Log(com.minecolonies.api.util.Log) BlockOre(net.minecraft.block.BlockOre) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BiMap(com.google.common.collect.BiMap) World(net.minecraft.world.World) Tuple(net.minecraft.util.Tuple) BlockRedstoneOre(net.minecraft.block.BlockRedstoneOre) Collectors(java.util.stream.Collectors) BlockLeaves(net.minecraft.block.BlockLeaves) IBlockState(net.minecraft.block.state.IBlockState) HashBiMap(com.google.common.collect.HashBiMap) List(java.util.List) NbtTagConstants(com.minecolonies.api.util.constant.NbtTagConstants) NBTUtils(com.minecolonies.api.util.NBTUtils) ItemBlock(net.minecraft.item.ItemBlock) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) NBTUtil(net.minecraft.nbt.NBTUtil) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) Tuple(net.minecraft.util.Tuple) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Aggregations

ItemStorage (com.minecolonies.api.crafting.ItemStorage)11 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 List (java.util.List)2 Predicate (java.util.function.Predicate)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 CreativeTabs (net.minecraft.creativetab.CreativeTabs)2 NotNull (org.jetbrains.annotations.NotNull)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 TypeToken (com.google.common.reflect.TypeToken)1 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)1 IDeliverable (com.minecolonies.api.colony.requestsystem.requestable.IDeliverable)1 Stack (com.minecolonies.api.colony.requestsystem.requestable.Stack)1 Tool (com.minecolonies.api.colony.requestsystem.requestable.Tool)1