Search in sources :

Example 1 with DyeItem

use of net.minecraft.item.DyeItem in project SophisticatedBackpacks by P3pp3rF1y.

the class BackpackDyeRecipe method matches.

@Override
public boolean matches(CraftingInventory inv, World worldIn) {
    boolean backpackPresent = false;
    boolean dyePresent = false;
    for (int slot = 0; slot < inv.getContainerSize(); slot++) {
        ItemStack slotStack = inv.getItem(slot);
        if (slotStack.isEmpty()) {
            continue;
        }
        Item item = slotStack.getItem();
        if (item instanceof BackpackItem) {
            if (backpackPresent) {
                return false;
            }
            backpackPresent = true;
        } else if (item instanceof DyeItem) {
            dyePresent = true;
        } else {
            return false;
        }
    }
    return backpackPresent && dyePresent;
}
Also used : Item(net.minecraft.item.Item) DyeItem(net.minecraft.item.DyeItem) BackpackItem(net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem) DyeItem(net.minecraft.item.DyeItem) ItemStack(net.minecraft.item.ItemStack) BackpackItem(net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem)

Example 2 with DyeItem

use of net.minecraft.item.DyeItem in project xercamods by ercanserteli.

the class RecipeCraftPalette method getCraftingResult.

/**
 * Returns an Item that is the result of this recipe
 */
@Override
public ItemStack getCraftingResult(CraftingInventory inv) {
    int plankRow = findPlankRow(inv);
    if (plankRow < 0) {
        return ItemStack.EMPTY;
    }
    ArrayList<ItemStack> dyes = findDyes(inv, plankRow);
    if (dyes == null || dyes.isEmpty()) {
        return ItemStack.EMPTY;
    }
    byte[] basicColors = new byte[16];
    for (ItemStack dye : dyes) {
        DyeColor color = ((DyeItem) (dye.getItem())).getDyeColor();
        basicColors[15 - color.getId()] = 1;
    }
    ItemStack result = new ItemStack(Items.ITEM_PALETTE);
    CompoundNBT tag = result.getOrCreateTag();
    tag.putByteArray("basic", basicColors);
    return result;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) DyeItem(net.minecraft.item.DyeItem) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.item.DyeColor)

Example 3 with DyeItem

use of net.minecraft.item.DyeItem in project Jineric-Mod by Jiingy.

the class ManxLoaghtan method getChildColor.

private DyeColor getChildColor(AnimalEntity firstParent, AnimalEntity secondParent) {
    DyeColor dyeColor = ((SheepEntity) firstParent).getColor();
    DyeColor dyeColor2 = ((SheepEntity) secondParent).getColor();
    CraftingInventory craftingInventory = createDyeMixingCraftingInventory(dyeColor, dyeColor2);
    return (DyeColor) this.world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftingInventory, this.world).map(recipe -> recipe.craft(craftingInventory)).map(ItemStack::getItem).filter(DyeItem.class::isInstance).map(DyeItem.class::cast).map(DyeItem::getColor).orElseGet(() -> this.world.random.nextBoolean() ? dyeColor : dyeColor2);
}
Also used : CraftingInventory(net.minecraft.inventory.CraftingInventory) SheepEntity(net.minecraft.entity.passive.SheepEntity) DyeItem(net.minecraft.item.DyeItem) DyeColor(net.minecraft.util.DyeColor)

Example 4 with DyeItem

use of net.minecraft.item.DyeItem in project endergetic by team-abnormals.

the class BolloomBalloonEntity method interactAt.

@Override
public ActionResultType interactAt(PlayerEntity player, Vector3d vec, Hand hand) {
    ItemStack itemstack = player.getItemInHand(hand);
    if (itemstack.getItem() instanceof DyeItem && this.getColor().color != ((DyeItem) itemstack.getItem()).getDyeColor()) {
        if (!this.level.isClientSide) {
            this.setColor(BalloonColor.byDyeColor(((DyeItem) itemstack.getItem()).getDyeColor()));
            EntityItemStackHelper.consumeItemFromStack(player, itemstack);
        }
        return ActionResultType.CONSUME;
    }
    return super.interactAt(player, vec, hand);
}
Also used : DyeItem(net.minecraft.item.DyeItem) ItemStack(net.minecraft.item.ItemStack)

Example 5 with DyeItem

use of net.minecraft.item.DyeItem in project xercamods by ercanserteli.

the class RecipeFillPalette method getCraftingResult.

/**
 * Returns an Item that is the result of this recipe
 */
@Override
public ItemStack getCraftingResult(CraftingInventory inv) {
    int paletteId = findPalette(inv);
    if (paletteId < 0) {
        return ItemStack.EMPTY;
    }
    ArrayList<ItemStack> dyes = findDyes(inv, paletteId);
    if (dyes == null || dyes.isEmpty()) {
        return ItemStack.EMPTY;
    }
    byte[] basicColors;
    ItemStack inputPalette = inv.getStackInSlot(paletteId);
    CompoundNBT orgTag = inputPalette.getOrCreateTag().copy();
    if (orgTag.contains("basic")) {
        basicColors = orgTag.getByteArray("basic");
    // XercaPaint.LOGGER.debug("Basic found. Len: " + basicColors.length);
    } else {
        basicColors = new byte[16];
    // XercaPaint.LOGGER.debug("Basic not found. Creating");
    }
    for (ItemStack dye : dyes) {
        DyeColor color = ((DyeItem) (dye.getItem())).getDyeColor();
        int realColorId = 15 - color.getId();
        if (basicColors[realColorId] > 0) {
            // XercaPaint.LOGGER.debug("Color already exists in palette.");
            return ItemStack.EMPTY;
        }
        basicColors[realColorId] = 1;
    }
    orgTag.putByteArray("basic", basicColors);
    ItemStack result = new ItemStack(Items.ITEM_PALETTE);
    result.setTag(orgTag);
    return result;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) DyeItem(net.minecraft.item.DyeItem) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.item.DyeColor) XercaPaint(xerca.xercapaint.common.XercaPaint)

Aggregations

DyeItem (net.minecraft.item.DyeItem)10 ItemStack (net.minecraft.item.ItemStack)9 DyeColor (net.minecraft.item.DyeColor)3 Item (net.minecraft.item.Item)3 Entity (net.minecraft.entity.Entity)2 SheepEntity (net.minecraft.entity.passive.SheepEntity)2 CompoundNBT (net.minecraft.nbt.CompoundNBT)2 MushroomSheepEntity (cech12.extendedmushrooms.entity.passive.MushroomSheepEntity)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableTable (com.google.common.collect.ImmutableTable)1 Table (com.google.common.collect.Table)1 UtilLib (de.teamlapen.lib.lib.util.UtilLib)1 VampirismPlayerAttributes (de.teamlapen.vampirism.player.VampirismPlayerAttributes)1 CoffinTileEntity (de.teamlapen.vampirism.tileentity.CoffinTileEntity)1 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 net.minecraft.block (net.minecraft.block)1 Material (net.minecraft.block.material.Material)1 PushReaction (net.minecraft.block.material.PushReaction)1