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
|
|
|
|
2017-06-17 00:48:49 +02:00
|
|
|
public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe{
|
|
|
|
|
|
|
|
public RecipePotionRingCharging(ResourceLocation location){
|
2017-06-29 18:36:33 +02:00
|
|
|
RecipeHelper.addRecipe(location.getResourcePath(), this);
|
2017-06-17 00:48:49 +02:00
|
|
|
}
|
2016-11-22 00:11:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean matches(InventoryCrafting inv, World worldIn){
|
|
|
|
boolean hasRing = false;
|
|
|
|
|
|
|
|
for(int i = 0; i < inv.getSizeInventory(); i++){
|
|
|
|
ItemStack stack = inv.getStackInSlot(i);
|
|
|
|
if(StackUtil.isValid(stack)){
|
|
|
|
if(stack.getItem() instanceof ItemPotionRing){
|
|
|
|
if(!hasRing){
|
|
|
|
hasRing = true;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(stack.getItem() != Items.BLAZE_POWDER){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasRing;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(int i = 0; i < inv.getSizeInventory(); i++){
|
|
|
|
ItemStack stack = inv.getStackInSlot(i);
|
|
|
|
if(StackUtil.isValid(stack)){
|
|
|
|
if(stack.getItem() instanceof ItemPotionRing){
|
|
|
|
inputRing = stack;
|
|
|
|
}
|
|
|
|
else if(stack.getItem() == Items.BLAZE_POWDER){
|
|
|
|
totalBlaze += 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(StackUtil.isValid(inputRing) && totalBlaze > 0){
|
|
|
|
ItemStack copy = inputRing.copy();
|
|
|
|
|
|
|
|
int total = ItemPotionRing.getStoredBlaze(copy)+totalBlaze;
|
|
|
|
if(total <= ItemPotionRing.MAX_BLAZE){
|
|
|
|
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
|
2017-06-29 18:30:02 +02:00
|
|
|
public boolean canFit(int width, int height){
|
2017-06-29 18:36:33 +02:00
|
|
|
return width*height > 3;
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getRecipeOutput(){
|
2017-11-02 22:49:53 +01:00
|
|
|
return StackUtil.getEmpty();
|
2016-11-22 00:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv){
|
|
|
|
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
|
|
|
}
|
|
|
|
}
|