2016-11-22 00:11:58 +01:00
|
|
|
/*
|
|
|
|
* This file ("RecipePotionRingCharging.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* 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-11-22 00:11:58 +01:00
|
|
|
*/
|
|
|
|
|
2016-12-06 18:10:43 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
2016-11-22 00:11:58 +01:00
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.ItemPotionRing;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2017-06-29 18:30:02 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper;
|
2016-11-22 00:11:58 +01:00
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
|
|
|
import net.minecraft.util.NonNullList;
|
2017-06-17 00:48:49 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-11-22 00:11:58 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.ForgeHooks;
|
2017-06-29 13:00:11 +02:00
|
|
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
2016-11-22 00:11:58 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
2017-06-17 00:48:49 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public RecipePotionRingCharging(ResourceLocation location) {
|
2018-08-04 04:22:20 +02:00
|
|
|
RecipeHelper.addRecipe(location.getPath(), this);
|
2017-06-17 00:48:49 +02:00
|
|
|
}
|
2016-11-22 00:11:58 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean matches(InventoryCrafting inv, World worldIn) {
|
2016-11-22 00:11:58 +01:00
|
|
|
boolean hasRing = false;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
2016-11-22 00:11:58 +01:00
|
|
|
ItemStack stack = inv.getStackInSlot(i);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(stack)) {
|
|
|
|
if (stack.getItem() instanceof ItemPotionRing) {
|
|
|
|
if (!hasRing) {
|
2016-11-22 00:11:58 +01:00
|
|
|
hasRing = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2016-11-22 00:11:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (stack.getItem() != Items.BLAZE_POWDER) { return false; }
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasRing;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
2017-11-02 22:49:53 +01:00
|
|
|
ItemStack inputRing = StackUtil.getEmpty();
|
2016-11-22 00:11:58 +01:00
|
|
|
int totalBlaze = 0;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
2016-11-22 00:11:58 +01:00
|
|
|
ItemStack stack = inv.getStackInSlot(i);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(stack)) {
|
|
|
|
if (stack.getItem() instanceof ItemPotionRing) {
|
2016-11-22 00:11:58 +01:00
|
|
|
inputRing = stack;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (stack.getItem() == Items.BLAZE_POWDER) {
|
2016-11-22 00:11:58 +01:00
|
|
|
totalBlaze += 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(inputRing) && totalBlaze > 0) {
|
2016-11-22 00:11:58 +01:00
|
|
|
ItemStack copy = inputRing.copy();
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
int total = ItemPotionRing.getStoredBlaze(copy) + totalBlaze;
|
|
|
|
if (total <= ItemPotionRing.MAX_BLAZE) {
|
2016-11-22 00:11:58 +01:00
|
|
|
ItemPotionRing.setStoredBlaze(copy, total);
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-02 22:49:53 +01:00
|
|
|
return StackUtil.getEmpty();
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean canFit(int width, int height) {
|
|
|
|
return width * height > 3;
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public ItemStack getRecipeOutput() {
|
2017-11-02 22:49:53 +01:00
|
|
|
return StackUtil.getEmpty();
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
2016-11-22 00:11:58 +01:00
|
|
|
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
|
|
|
}
|
|
|
|
}
|