Refactor tank recipes
This commit is contained in:
parent
ea91d852af
commit
536de89742
17 changed files with 134 additions and 159 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:acacia_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stripped_acacia_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:birch_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stripped_birch_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:dark_oak_log"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:jungle_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stripped_jungle_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:oak_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stripped_oak_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "techreborn:rubber_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:spruce_log"
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
"type": "techreborn:industrial_sawmill",
|
||||
"power": 128,
|
||||
"time": 100,
|
||||
"tank" : {
|
||||
"fluid": "minecraft:water",
|
||||
"amount": 1000
|
||||
},
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:stripped_spruce_log"
|
||||
|
|
Loading…
Reference in a new issue