Moved recipe utility methods to RecipeUtils

This commit is contained in:
drcrazy 2019-07-30 01:46:12 +03:00
parent 878734e4ad
commit aa7464ad4a
6 changed files with 38 additions and 40 deletions

View file

@ -45,7 +45,6 @@ import techreborn.init.TRContent;
import techreborn.init.TRBlockEntities;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@RebornRegister(TechReborn.MOD_ID)
public class IronAlloyFurnaceBlockEntity extends MachineBaseBlockEntity

View file

@ -38,8 +38,8 @@ import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.IInventoryAccess;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.ItemUtils;
import techreborn.events.TRRecipeHandler;
import techreborn.init.TRBlockEntities;
import techreborn.utils.RecipeUtils;
public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
implements InventoryProvider, IContainerProvider {
@ -120,7 +120,7 @@ public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
public void cookItems() {
if (this.canSmelt()) {
final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(this.input1));
final ItemStack itemstack = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(this.input1));
if (inventory.getInvStack(this.output).isEmpty()) {
inventory.setInvStack(this.output, itemstack.copy());
@ -138,7 +138,7 @@ public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
public boolean canSmelt() {
if (inventory.getInvStack(this.input1).isEmpty())
return false;
final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(this.input1));
final ItemStack itemstack = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(this.input1));
if (itemstack.isEmpty())
return false;
if (inventory.getInvStack(this.output).isEmpty())
@ -154,7 +154,7 @@ public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
}
public ItemStack getResultFor(final ItemStack stack) {
final ItemStack result = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, stack);
final ItemStack result = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, stack);
if (!result.isEmpty()) {
return result.copy();
}

View file

@ -48,9 +48,9 @@ import reborncore.common.util.IInventoryAccess;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.events.TRRecipeHandler;
import techreborn.init.ModSounds;
import techreborn.init.TRContent;
import techreborn.utils.RecipeUtils;
import techreborn.init.TRBlockEntities;
import javax.annotation.Nullable;
@ -93,7 +93,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return lastRecipe;
}
}
for (Recipe testRecipe : TRRecipeHandler.getRecipes(world, RecipeType.CRAFTING)) {
for (Recipe testRecipe : RecipeUtils.getRecipes(world, RecipeType.CRAFTING)) {
if (testRecipe.matches(crafting, world)) {
lastRecipe = testRecipe;
return testRecipe;
@ -118,7 +118,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
return inventoryCrafting;
}
public boolean canMake(Recipe recipe) {
public boolean canMake(Recipe<CraftingInventory> recipe) {
if (recipe != null && recipe.fits(3, 3)) {
boolean missingOutput = false;
int[] stacksInSlots = new int[9];

View file

@ -40,8 +40,8 @@ import reborncore.common.registration.RebornRegister;
import reborncore.common.registration.config.ConfigRegistry;
import reborncore.common.util.RebornInventory;
import techreborn.TechReborn;
import techreborn.events.TRRecipeHandler;
import techreborn.init.TRContent;
import techreborn.utils.RecipeUtils;
import techreborn.init.TRBlockEntities;
@RebornRegister(TechReborn.MOD_ID)
@ -71,7 +71,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
public void cookItems() {
if (canSmelt()) {
final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(input1));
final ItemStack itemstack = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(input1));
if (inventory.getInvStack(output).isEmpty()) {
inventory.setInvStack(output, itemstack.copy());
@ -90,7 +90,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
if (inventory.getInvStack(input1).isEmpty()) {
return false;
}
final ItemStack itemstack = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(input1));
final ItemStack itemstack = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, inventory.getInvStack(input1));
if (itemstack.isEmpty()) {
return false;
}
@ -109,7 +109,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
}
public ItemStack getResultFor(ItemStack stack) {
final ItemStack result = TRRecipeHandler.getMatchingRecipes(world, RecipeType.SMELTING, stack);
final ItemStack result = RecipeUtils.getMatchingRecipes(world, RecipeType.SMELTING, stack);
if (!result.isEmpty()) {
return result.copy();
}