mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 04:32:23 +00:00
79 lines
2.2 KiB
Java
79 lines
2.2 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as
|
|
* part of the Botania Mod. Get the Source Code in github:
|
|
* https://github.com/Vazkii/Botania
|
|
*
|
|
* Botania is Open Source and distributed under the
|
|
* Botania License: http://botaniamod.net/license.php
|
|
*
|
|
* File Created @ [Feb 22, 2015, 8:55:03 PM (GMT)]
|
|
*/
|
|
package vazkii.botania.common.crafting.recipe;
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.crafting.IRecipe;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.common.ForgeHooks;
|
|
import vazkii.botania.api.item.ICosmeticAttachable;
|
|
import vazkii.botania.api.item.ICosmeticBauble;
|
|
|
|
public class CosmeticRemoveRecipe implements IRecipe {
|
|
|
|
@Override
|
|
public boolean matches(@Nonnull InventoryCrafting var1, @Nonnull World var2) {
|
|
boolean foundAttachable = false;
|
|
|
|
for(int i = 0; i < var1.getSizeInventory(); i++) {
|
|
ItemStack stack = var1.getStackInSlot(i);
|
|
if(!stack.isEmpty()) {
|
|
if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null)
|
|
foundAttachable = true;
|
|
else return false;
|
|
}
|
|
}
|
|
|
|
return foundAttachable;
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) {
|
|
ItemStack attachableItem = ItemStack.EMPTY;
|
|
|
|
for(int i = 0; i < var1.getSizeInventory(); i++) {
|
|
ItemStack stack = var1.getStackInSlot(i);
|
|
if(!stack.isEmpty())
|
|
attachableItem = stack;
|
|
}
|
|
|
|
ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem();
|
|
if(attachable.getCosmeticItem(attachableItem) == null)
|
|
return ItemStack.EMPTY;
|
|
|
|
ItemStack copy = attachableItem.copy();
|
|
attachable.setCosmeticItem(copy, null);
|
|
return copy;
|
|
}
|
|
|
|
@Override
|
|
public int getRecipeSize() {
|
|
return 10;
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public ItemStack getRecipeOutput() {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
|
|
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
|
}
|
|
}
|