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