diff --git a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java index b404ca0ce..c71fb5150 100644 --- a/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/BlastFurnaceRecipe.java @@ -34,7 +34,7 @@ import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEnti public class BlastFurnaceRecipe extends RebornRecipe { - int heat; + private int heat; public BlastFurnaceRecipe(RebornRecipeType type, Identifier name) { super(type, name); @@ -61,8 +61,4 @@ public class BlastFurnaceRecipe extends RebornRecipe { return false; } - @Override - public boolean onCraft(final BlockEntity blockEntity) { - return true; - } } diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java index 9e0e83597..018d05496 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialGrinderRecipe.java @@ -26,65 +26,32 @@ package techreborn.api.recipe.recipes; import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.Identifier; +import reborncore.common.crafting.RebornFluidRecipe; import reborncore.common.crafting.RebornRecipe; import reborncore.common.crafting.RebornRecipeType; import io.github.prospector.silk.fluid.FluidInstance; +import reborncore.common.util.Tank; import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity; -public class IndustrialGrinderRecipe extends RebornRecipe { - - //TODO 1.14 fluids - FluidInstance fluidStack = null; +public class IndustrialGrinderRecipe extends RebornFluidRecipe { public IndustrialGrinderRecipe(RebornRecipeType type, Identifier name) { super(type, name); } @Override - public boolean canCraft(final BlockEntity be) { + public Tank getTank(BlockEntity be) { + IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be; + return blockEntity.getTank(); + } + + @Override + public boolean canCraft(BlockEntity be) { IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be; if (!blockEntity.getMultiBlock()) { return false; } - final FluidInstance recipeFluid = fluidStack; - final FluidInstance tankFluid = blockEntity.tank.getFluidInstance(); - if (fluidStack == null) { - return true; - } - if (tankFluid == null) { - return false; - } - if (tankFluid.getFluid().equals(recipeFluid.getFluid())) { - if (tankFluid.getAmount() >= recipeFluid.getAmount()) { - return true; - } - } - return false; + return super.canCraft(be); } - @Override - public boolean onCraft(final BlockEntity be) { - IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be; - final FluidInstance recipeFluid = fluidStack; - final FluidInstance tankFluid = blockEntity.tank.getFluidInstance(); - if (fluidStack == null) { - return true; - } - if (tankFluid == null) { - return false; - } - if (tankFluid.getFluid().equals(recipeFluid.getFluid())) { - if (tankFluid.getAmount() >= recipeFluid.getAmount()) { - if (tankFluid.getAmount() == recipeFluid.getAmount()) { - blockEntity.tank.setFluid(null); - } - else { - tankFluid.subtractAmount(recipeFluid.getAmount()); - } - blockEntity.syncWithAll(); - return true; - } - } - return false; - } } diff --git a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java index 8978159f3..dc4fb9cfc 100644 --- a/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java +++ b/src/main/java/techreborn/api/recipe/recipes/IndustrialSawmillRecipe.java @@ -24,31 +24,23 @@ package techreborn.api.recipe.recipes; -import com.google.gson.JsonObject; -import io.github.prospector.silk.fluid.FluidInstance; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.fluid.Fluids; import net.minecraft.util.Identifier; - -import javax.annotation.Nonnull; - -import reborncore.common.crafting.RebornRecipe; +import reborncore.common.crafting.RebornFluidRecipe; import reborncore.common.crafting.RebornRecipeType; +import reborncore.common.util.Tank; import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity; -public class IndustrialSawmillRecipe extends RebornRecipe { - - @Nonnull - private FluidInstance fluidInstance = FluidInstance.EMPTY; +public class IndustrialSawmillRecipe extends RebornFluidRecipe { public IndustrialSawmillRecipe(RebornRecipeType type, Identifier name) { super(type, name); } @Override - public void deserialize(JsonObject jsonObject) { - super.deserialize(jsonObject); - fluidInstance = new FluidInstance(Fluids.WATER, 1000); + public Tank getTank(BlockEntity be) { + IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be; + return blockEntity.getTank(); } @Override @@ -57,39 +49,7 @@ public class IndustrialSawmillRecipe extends RebornRecipe { if (!blockEntity.getMutliBlock()) { return false; } - final FluidInstance recipeFluid = fluidInstance; - final FluidInstance tankFluid = blockEntity.tank.getFluidInstance(); - if (fluidInstance.isEmpty()) { - return true; - } - if (tankFluid.isEmpty()) { - return false; - } - if (tankFluid.getFluid().equals(recipeFluid.getFluid())) { - if (tankFluid.getAmount() >= recipeFluid.getAmount()) { - return true; - } - } - return false; + return super.canCraft(be); } - @Override - public boolean onCraft(BlockEntity be) { - IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be; - final FluidInstance recipeFluid = fluidInstance; - final FluidInstance tankFluid = blockEntity.tank.getFluidInstance(); - if (fluidInstance.isEmpty()) { - return true; - } - if (tankFluid.isEmpty()) { - return false; - } - if (tankFluid.getFluid().equals(recipeFluid.getFluid())) { - if (tankFluid.getAmount() >= recipeFluid.getAmount()) { - tankFluid.subtractAmount(recipeFluid.getAmount()); - return true; - } - } - return false; - } } diff --git a/src/main/java/techreborn/blocks/GenericMachineBlock.java b/src/main/java/techreborn/blocks/GenericMachineBlock.java index 4015653b2..a053779db 100644 --- a/src/main/java/techreborn/blocks/GenericMachineBlock.java +++ b/src/main/java/techreborn/blocks/GenericMachineBlock.java @@ -1,63 +1,63 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2018 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.blocks; - -import java.util.function.Supplier; - -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.world.BlockView; -import reborncore.api.blockentity.IMachineGuiHandler; -import reborncore.common.blocks.BlockMachineBase; -import techreborn.client.EGui; - -/** - * @author drcrazy - * - */ -public class GenericMachineBlock extends BlockMachineBase { - - private EGui gui; - private Supplier blockEntityClass; - - public GenericMachineBlock(EGui gui, Supplier blockEntityClass) { - super(); - this.blockEntityClass = blockEntityClass; - this.gui = gui; - } - - @Override - public BlockEntity createBlockEntity(BlockView worldIn) { - if (blockEntityClass == null) { - return null; - } - return blockEntityClass.get(); - } - - @Override - public IMachineGuiHandler getGui() { - return gui; - } - -} +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2018 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.blocks; + +import java.util.function.Supplier; + +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.world.BlockView; +import reborncore.api.blockentity.IMachineGuiHandler; +import reborncore.common.blocks.BlockMachineBase; +import techreborn.client.EGui; + +/** + * @author drcrazy + * + */ +public class GenericMachineBlock extends BlockMachineBase { + + private EGui gui; + private Supplier blockEntityClass; + + public GenericMachineBlock(EGui gui, Supplier blockEntityClass) { + super(); + this.blockEntityClass = blockEntityClass; + this.gui = gui; + } + + @Override + public BlockEntity createBlockEntity(BlockView worldIn) { + if (blockEntityClass == null) { + return null; + } + return blockEntityClass.get(); + } + + @Override + public IMachineGuiHandler getGui() { + return gui; + } + +} diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json index 93d659faa..e64a92d08 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:acacia_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json index edf99cdea..0db2140ca 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/acacia_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_acacia_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json index ffa2b2188..f87712ea8 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:birch_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json index 21ea1aea7..0f89150cb 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/birch_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_birch_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json index 0de793c26..5f3777751 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:dark_oak_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json index fad40cc45..0f2466b89 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/dark_oak_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_dark_oak_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json index 52a7757c7..4e4e57bd6 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:jungle_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json index d18d7cfa3..c024ffb34 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/jungle_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_jungle_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json index f6ed9ee14..22bff37c2 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:oak_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json index 796a6fa35..c5bc5b35c 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/oak_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_oak_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json index 75be81c9d..60b2451f6 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/rubber_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "techreborn:rubber_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json index e85417694..91c46ccd3 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:spruce_log" diff --git a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json index f1dae0fb7..424f35909 100644 --- a/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json +++ b/src/main/resources/data/techreborn/recipes/industrial_sawmill/auto/spruce_planks_1.json @@ -2,6 +2,10 @@ "type": "techreborn:industrial_sawmill", "power": 128, "time": 100, + "tank" : { + "fluid": "minecraft:water", + "amount": 1000 + }, "ingredients": [ { "item": "minecraft:stripped_spruce_log"