2016-08-04 11:57:35 +02:00
|
|
|
/*
|
2016-10-31 19:05:29 +01:00
|
|
|
* This file ("RecipeKeepDataShapeless.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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-08-04 11:57:35 +02:00
|
|
|
*/
|
|
|
|
|
2016-12-06 18:10:43 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
2016-08-04 11:57:35 +02:00
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
2016-11-16 20:31:16 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2017-06-29 18:30:02 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper;
|
2016-08-04 11:57:35 +02:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-06-17 00:48:49 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-08-04 11:57:35 +02:00
|
|
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class RecipeKeepDataShapeless extends ShapelessOreRecipe {
|
2016-08-04 11:57:35 +02:00
|
|
|
|
|
|
|
private final ItemStack nbtCopyStack;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public RecipeKeepDataShapeless(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) {
|
2017-06-17 00:48:49 +02:00
|
|
|
super(group, result, recipe);
|
2016-08-04 11:57:35 +02:00
|
|
|
this.nbtCopyStack = nbtCopyStack;
|
2017-06-17 00:48:49 +02:00
|
|
|
|
2018-08-04 04:22:20 +02:00
|
|
|
RecipeHelper.addRecipe(group.getPath(), this);
|
2016-08-04 11:57:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
2016-08-04 11:57:35 +02:00
|
|
|
ItemStack stack = super.getCraftingResult(inventory);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(stack)) {
|
|
|
|
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
2016-08-04 11:57:35 +02:00
|
|
|
ItemStack input = inventory.getStackInSlot(i);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) {
|
2016-08-04 11:57:35 +02:00
|
|
|
stack.setTagCompound(input.getTagCompound());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|