Search in sources :

Example 16 with CraftingInventory

use of net.minecraft.inventory.CraftingInventory in project Paradise-Lost by devs-immortal.

the class SheepuffEntity method createDyeMixingCraftingInventory.

private static CraftingInventory createDyeMixingCraftingInventory(DyeColor parentColor, DyeColor mateColor) {
    CraftingInventory craftingInventory_1 = new CraftingInventory(new ScreenHandler(null, -1) {

        @Override
        public boolean canUse(PlayerEntity playerIn) {
            return false;
        }
    }, 2, 1);
    craftingInventory_1.setStack(0, new ItemStack(DyeItem.byColor(parentColor)));
    craftingInventory_1.setStack(1, new ItemStack(DyeItem.byColor(mateColor)));
    return craftingInventory_1;
}
Also used : CraftingInventory(net.minecraft.inventory.CraftingInventory) ScreenHandler(net.minecraft.screen.ScreenHandler) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 17 with CraftingInventory

use of net.minecraft.inventory.CraftingInventory in project Paradise-Lost by devs-immortal.

the class SheepuffEntity method getChildColor.

private DyeColor getChildColor(AnimalEntity entity, AnimalEntity mate) {
    DyeColor parentColor = ((SheepuffEntity) entity).getColor();
    DyeColor mateColor = ((SheepuffEntity) mate).getColor();
    CraftingInventory craftingInventory_1 = createDyeMixingCraftingInventory(parentColor, mateColor);
    // TODO: ???
    Optional<Item> optionalItem = this.world.getRecipeManager().getAllMatches(RecipeType.CRAFTING, craftingInventory_1, this.world).stream().map((typedRecipe_1) -> typedRecipe_1.craft(craftingInventory_1)).map(ItemStack::getItem).findAny();
    optionalItem = optionalItem.filter(DyeItem.class::isInstance);
    return optionalItem.map(DyeItem.class::cast).map(DyeItem::getColor).orElseGet(() -> this.world.random.nextBoolean() ? parentColor : mateColor);
}
Also used : CraftingInventory(net.minecraft.inventory.CraftingInventory)

Aggregations

CraftingInventory (net.minecraft.inventory.CraftingInventory)17 ItemStack (net.minecraft.item.ItemStack)12 ArrayList (java.util.ArrayList)6 List (java.util.List)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 TransferRecipeCraftingTeachingMessage (com.minecolonies.coremod.network.messages.server.TransferRecipeCraftingTeachingMessage)4 HashMap (java.util.HashMap)4 ICraftingRecipe (net.minecraft.item.crafting.ICraftingRecipe)4 Map (java.util.Map)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 IInventory (net.minecraft.inventory.IInventory)3 IRecipeType (net.minecraft.item.crafting.IRecipeType)3 ITextComponent (net.minecraft.util.text.ITextComponent)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ModItems.buildTool (com.ldtteam.structurize.items.ModItems.buildTool)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)2 IGenericRecipe (com.minecolonies.api.crafting.IGenericRecipe)2 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)2