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;
}
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);
}
Aggregations