From fff627b2ec32ab915e01bbb38905aedca91585ba Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Fri, 7 Oct 2016 22:39:50 +0200 Subject: [PATCH] Remove SoldererRecipe - it's now a factory method in ISoldererRegistry --- .../api/solderer/ISoldererRegistry.java | 12 ++++ .../api/solderer/SoldererRecipe.java | 58 ------------------- .../apiimpl/solderer/SoldererRegistry.java | 27 +++++++++ .../apiimpl/storage/fluid/FluidUtils.java | 1 + .../refinedstorage/proxy/CommonProxy.java | 13 ++--- 5 files changed, 46 insertions(+), 65 deletions(-) delete mode 100755 src/main/java/refinedstorage/api/solderer/SoldererRecipe.java diff --git a/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java b/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java index ffbd5ce10..93cb7e739 100755 --- a/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java +++ b/src/main/java/refinedstorage/api/solderer/ISoldererRegistry.java @@ -1,5 +1,6 @@ package refinedstorage.api.solderer; +import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; import javax.annotation.Nonnull; @@ -30,4 +31,15 @@ public interface ISoldererRegistry { * @return a list with all the solderer recipes */ List getRecipes(); + + /** + * Creates a simple solderer recipe. + * + * @param result the result + * @param duration the duration in ticks + * @param rows the rows of this recipe, has to be 3 rows (null for an empty row) + * @return a solderer recipe + */ + @Nonnull + ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, ItemStack... rows); } diff --git a/src/main/java/refinedstorage/api/solderer/SoldererRecipe.java b/src/main/java/refinedstorage/api/solderer/SoldererRecipe.java deleted file mode 100755 index d63254441..000000000 --- a/src/main/java/refinedstorage/api/solderer/SoldererRecipe.java +++ /dev/null @@ -1,58 +0,0 @@ -package refinedstorage.api.solderer; - -import net.minecraft.item.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * A basic solderer recipe. - * Implement {@link ISoldererRecipe} for custom behavior. - */ -public class SoldererRecipe implements ISoldererRecipe { - private int duration; - private ItemStack result; - private ItemStack[] rows; - - /** - * @param result the result - * @param duration the duration in ticks - * @param rows the rows of this recipe, has to be 3 rows (null for an empty row) - */ - public SoldererRecipe(@Nonnull ItemStack result, int duration, ItemStack... rows) { - if (rows.length != 3) { - throw new IllegalArgumentException("Solderer recipe expects 3 rows, got " + rows.length + " rows"); - } - - this.duration = duration; - this.result = result; - this.rows = rows; - } - - /** - * @param row the row in the solderer that we want the stack for (between 0 - 2) - * @return a stack for that row, null if there is no stack - */ - @Override - @Nullable - public ItemStack getRow(int row) { - return rows[row]; - } - - /** - * @return the result stack - */ - @Override - @Nonnull - public ItemStack getResult() { - return result; - } - - /** - * @return the time it takes to complete this recipe - */ - @Override - public int getDuration() { - return duration; - } -} diff --git a/src/main/java/refinedstorage/apiimpl/solderer/SoldererRegistry.java b/src/main/java/refinedstorage/apiimpl/solderer/SoldererRegistry.java index 3096873a7..f57ee959a 100755 --- a/src/main/java/refinedstorage/apiimpl/solderer/SoldererRegistry.java +++ b/src/main/java/refinedstorage/apiimpl/solderer/SoldererRegistry.java @@ -51,4 +51,31 @@ public class SoldererRegistry implements ISoldererRegistry { public List getRecipes() { return recipes; } + + @Nonnull + @Override + public ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, ItemStack... rows) { + if (rows.length != 3) { + throw new IllegalArgumentException("Solderer recipe expects 3 rows, got " + rows.length + " rows"); + } + + return new ISoldererRecipe() { + @Nullable + @Override + public ItemStack getRow(int row) { + return rows[row]; + } + + @Nonnull + @Override + public ItemStack getResult() { + return result; + } + + @Override + public int getDuration() { + return duration; + } + }; + } } diff --git a/src/main/java/refinedstorage/apiimpl/storage/fluid/FluidUtils.java b/src/main/java/refinedstorage/apiimpl/storage/fluid/FluidUtils.java index 0f5cae010..61c0bb9b4 100755 --- a/src/main/java/refinedstorage/apiimpl/storage/fluid/FluidUtils.java +++ b/src/main/java/refinedstorage/apiimpl/storage/fluid/FluidUtils.java @@ -10,6 +10,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import refinedstorage.api.network.INetworkMaster; import refinedstorage.api.util.IComparer; +// @TODO: Move to RSUtils public final class FluidUtils { public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET); diff --git a/src/main/java/refinedstorage/proxy/CommonProxy.java b/src/main/java/refinedstorage/proxy/CommonProxy.java index 9d4d6b505..88fe3003b 100755 --- a/src/main/java/refinedstorage/proxy/CommonProxy.java +++ b/src/main/java/refinedstorage/proxy/CommonProxy.java @@ -19,7 +19,6 @@ import refinedstorage.RS; import refinedstorage.RSBlocks; import refinedstorage.RSItems; import refinedstorage.api.RSAPI; -import refinedstorage.api.solderer.SoldererRecipe; import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementRoot; import refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementToTake; import refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactoryNormal; @@ -216,7 +215,7 @@ public class CommonProxy { ); // Disk Drive - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.DISK_DRIVE), 500, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), @@ -258,7 +257,7 @@ public class CommonProxy { ); // Crafting Grid - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.GRID, 1, EnumGridType.CRAFTING.getId()), 500, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), @@ -267,7 +266,7 @@ public class CommonProxy { )); // Pattern Grid - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.GRID, 1, EnumGridType.PATTERN.getId()), 500, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), @@ -276,7 +275,7 @@ public class CommonProxy { )); // Fluid Grid - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.GRID, 1, EnumGridType.FLUID.getId()), 500, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), @@ -570,7 +569,7 @@ public class CommonProxy { )); // Interface - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.INTERFACE), 200, new ItemStack(RSBlocks.IMPORTER), @@ -579,7 +578,7 @@ public class CommonProxy { )); // Fluid Interface - RSAPI.instance().getSoldererRegistry().addRecipe(new SoldererRecipe( + RSAPI.instance().getSoldererRegistry().addRecipe(RSAPI.instance().getSoldererRegistry().createSimpleRecipe( new ItemStack(RSBlocks.FLUID_INTERFACE), 200, new ItemStack(Items.BUCKET),