Search in sources :

Example 6 with ItemFrameEntity

use of net.minecraft.entity.item.ItemFrameEntity in project minecolonies by ldtteam.

the class ItemStackUtils method getListOfStackForEntity.

/**
 * Adds entities to the builder building if he needs it.
 *
 * @param entity the entity object.
 * @param placer the entity placer.
 * @return a list of stacks.
 */
public static List<ItemStorage> getListOfStackForEntity(final Entity entity, final Entity placer) {
    if (entity != null) {
        final List<ItemStorage> request = new ArrayList<>();
        if (entity instanceof ItemFrameEntity) {
            final ItemStack stack = ((ItemFrameEntity) entity).getItem();
            if (!ItemStackUtils.isEmpty(stack)) {
                ItemStackUtils.setSize(stack, 1);
                request.add(new ItemStorage(stack));
            }
            request.add(new ItemStorage(new ItemStack(Items.ITEM_FRAME, 1)));
        } else if (entity instanceof ArmorStandEntity) {
            request.add(new ItemStorage(entity.getPickedResult(new EntityRayTraceResult(placer))));
            entity.getArmorSlots().forEach(item -> request.add(new ItemStorage(item)));
            entity.getHandSlots().forEach(item -> request.add(new ItemStorage(item)));
        }
        return request.stream().filter(stack -> !stack.getItemStack().isEmpty()).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : EntityType(net.minecraft.entity.EntityType) java.util(java.util) SMELTABLE_SLOT(com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT) ModTags.fungi(com.minecolonies.api.items.ModTags.fungi) Compatibility(com.minecolonies.api.compatibility.Compatibility) CompoundNBT(net.minecraft.nbt.CompoundNBT) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) JsonToNBT(net.minecraft.nbt.JsonToNBT) MinecoloniesAPIProxy(com.minecolonies.api.MinecoloniesAPIProxy) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ModItems(com.minecolonies.api.items.ModItems) FUEL_SLOT(com.minecolonies.api.util.constant.Constants.FUEL_SLOT) ListNBT(net.minecraft.nbt.ListNBT) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ItemTags(net.minecraft.tags.ItemTags) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) IColonyManager(com.minecolonies.api.colony.IColonyManager) net.minecraft.item(net.minecraft.item) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) ResourceLocation(net.minecraft.util.ResourceLocation) ToolType(com.minecolonies.api.util.constant.ToolType) ItemStorage(com.minecolonies.api.crafting.ItemStorage) IToolType(com.minecolonies.api.util.constant.IToolType) NotNull(org.jetbrains.annotations.NotNull) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Aggregations

ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)6 Entity (net.minecraft.entity.Entity)4 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 ArmorStandEntity (net.minecraft.entity.item.ArmorStandEntity)3 net.minecraft.item (net.minecraft.item)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 World (net.minecraft.world.World)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 Lists (com.google.common.collect.Lists)2 MinecoloniesAPIProxy (com.minecolonies.api.MinecoloniesAPIProxy)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Compatibility (com.minecolonies.api.compatibility.Compatibility)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 ModItems (com.minecolonies.api.items.ModItems)2 ModTags.fungi (com.minecolonies.api.items.ModTags.fungi)2 FUEL_SLOT (com.minecolonies.api.util.constant.Constants.FUEL_SLOT)2 SMELTABLE_SLOT (com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT)2