2016-08-04 11:57:35 +02:00
|
|
|
/*
|
2016-10-31 19:05:29 +01:00
|
|
|
* This file ("RecipeKeepDataShaped.java") is part of the Actually Additions mod for Minecraft.
|
2016-08-04 11:57:35 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015-2016 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
2016-11-16 20:31:16 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2016-08-04 11:57:35 +02:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
|
|
|
|
|
|
public class RecipeKeepDataShaped extends ShapedOreRecipe{
|
|
|
|
|
|
|
|
private final ItemStack nbtCopyStack;
|
|
|
|
|
|
|
|
public RecipeKeepDataShaped(ItemStack result, ItemStack nbtCopyStack, Object... recipe){
|
|
|
|
super(result, recipe);
|
|
|
|
this.nbtCopyStack = nbtCopyStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getCraftingResult(InventoryCrafting inventory){
|
|
|
|
ItemStack stack = super.getCraftingResult(inventory);
|
2016-11-16 20:31:16 +01:00
|
|
|
if(StackUtil.isValid(stack)){
|
2016-08-04 11:57:35 +02:00
|
|
|
for(int i = 0; i < inventory.getSizeInventory(); i++){
|
|
|
|
ItemStack input = inventory.getStackInSlot(i);
|
|
|
|
if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){
|
|
|
|
stack.setTagCompound(input.getTagCompound());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|