distillation tower/distiller recipe localization improvement :3

This commit is contained in:
DrMangoTea
2023-11-04 20:10:14 +01:00
parent 17cc2d2e2e
commit 1f40e22f49
16 changed files with 300 additions and 186 deletions

View File

@@ -2,7 +2,7 @@ package com.drmangotea.createindustry.blocks.machines.oil_processing.distillatio
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryControllerBlockEntity;
import com.drmangotea.createindustry.recipes.distillation.ItemlessRecipe;
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.foundation.advancement.CreateAdvancement;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
@@ -23,7 +23,7 @@ public abstract class FluidProcessingBlockEntity extends KineticBlockEntity {
public DeferralBehaviour basinChecker;
public boolean basinRemoved;
protected Recipe<?> currentRecipe;
protected AbstractDistillationRecipe recipe;
public FluidProcessingBlockEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) {
super(typeIn, pos, state);
@@ -41,7 +41,7 @@ public abstract class FluidProcessingBlockEntity extends KineticBlockEntity {
public void tick() {
if (basinRemoved) {
basinRemoved = false;
onBasinRemoved();
onControllerRemoved();
sendData();
return;
}
@@ -50,26 +50,7 @@ public abstract class FluidProcessingBlockEntity extends KineticBlockEntity {
}
protected boolean updateController() {
if (isRunning())
return true;
if (level == null || level.isClientSide)
return true;
List<Recipe<?>> recipes = getMatchingRecipes();
if (recipes.isEmpty())
return true;
currentRecipe = recipes.get(0);
// if(currentRecipe instanceof DistillationRecipe) {
// if (((DistillationRecipe) currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid() != TFMGFluids.HEAVY_OIL.get()) {
// return true;
// }
// }
startProcessing();
sendData();
return true;
return false;
}
protected abstract boolean isRunning();
@@ -87,24 +68,13 @@ public abstract class FluidProcessingBlockEntity extends KineticBlockEntity {
if (!controller.isPresent())
return false;
return ItemlessRecipe.match(controller.get(), recipe);
return AbstractDistillationRecipe.match(controller.get(), recipe);
}
protected List<Recipe<?>> getMatchingRecipes() {
List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
return list.stream()
.filter(this::matchItemlessRecipe)
.sorted((r1, r2) -> r2.getIngredients()
.size()
- r1.getIngredients()
.size())
.collect(Collectors.toList());
}
protected abstract void onBasinRemoved();
protected abstract void onControllerRemoved();
public Optional<DistilleryControllerBlockEntity> getController() {
if (level == null)

View File

@@ -2,15 +2,16 @@ package com.drmangotea.createindustry.blocks.machines.oil_processing.distillatio
import com.drmangotea.createindustry.CreateTFMG;
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillery.DistilleryOutputBlockEntity;
import com.drmangotea.createindustry.recipes.distillation.ItemlessRecipe;
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
import com.drmangotea.createindustry.recipes.distillation.AdvancedDistillationRecipe;
import com.drmangotea.createindustry.registry.TFMGBlocks;
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
import com.simibubi.create.AllRecipeTypes;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.kinetics.press.MechanicalPressBlockEntity;
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
import com.simibubi.create.foundation.recipe.RecipeFinder;
import net.minecraft.core.BlockPos;
import net.minecraft.world.Container;
@@ -26,7 +27,6 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity implements IHaveGoggleInformation {
@@ -48,7 +48,7 @@ public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity i
Optional<DistillationControllerBlockEntity> controller = getDistillationController();
if (!controller.isPresent())
return false;
return ItemlessRecipe.match2(controller.get(), recipe);
return AbstractDistillationRecipe.match2(controller.get(), recipe);
}
@Override
@@ -58,10 +58,23 @@ public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity i
if (level == null || level.isClientSide)
return true;
List<Recipe<?>> recipes = getMatchingRecipes();
if (recipes.isEmpty())
DistillationControllerBlockEntity be=null;
if(level.getBlockEntity(getBlockPos().below())instanceof DistillationControllerBlockEntity)
be = (DistillationControllerBlockEntity) level.getBlockEntity(getBlockPos().below());
if(be==null)
return true;
currentRecipe = recipes.get(0);
recipe = getMatchingRecipes(be);
//List<Recipe<?>> recipes = getMatchingRecipes();
//if (recipes.isEmpty())
// return true;
//currentRecipe = recipes.get(0);
startProcessing();
sendData();
return true;
@@ -89,8 +102,7 @@ public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity i
protected void process() {
updateController();
if (currentRecipe == null)
return;
@@ -140,10 +152,11 @@ public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity i
}else foundOutputs = 4;
}
if (recipe == null)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe)currentRecipe)>foundOutputs)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>foundOutputs)
return;
FluidStack fluidInRecipe1=null;
FluidStack fluidInRecipe2=null;
@@ -152,17 +165,17 @@ public class DistillationOutputBlockEntity extends DistilleryOutputBlockEntity i
FluidStack fluidInRecipe5=null;
FluidStack fluidInRecipe6=null;
fluidInRecipe1 = ((AdvancedDistillationRecipe) currentRecipe).getFirstFluidResult();
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=2)
fluidInRecipe2 = ((AdvancedDistillationRecipe) currentRecipe).getSecondFluidResult();
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=3)
fluidInRecipe3 = ((AdvancedDistillationRecipe) currentRecipe).getThirdFluidResult();
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=4)
fluidInRecipe4 = ((AdvancedDistillationRecipe) currentRecipe).getFourthFluidResult();
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=5)
fluidInRecipe5 = ((AdvancedDistillationRecipe) currentRecipe).getFifthFluidResult();
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=6)
fluidInRecipe6 = ((AdvancedDistillationRecipe) currentRecipe).getSixthFluidResult();
fluidInRecipe1 = ((AdvancedDistillationRecipe) recipe).getFirstFluidResult();
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=2)
fluidInRecipe2 = ((AdvancedDistillationRecipe) recipe).getSecondFluidResult();
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=3)
fluidInRecipe3 = ((AdvancedDistillationRecipe) recipe).getThirdFluidResult();
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=4)
fluidInRecipe4 = ((AdvancedDistillationRecipe) recipe).getFourthFluidResult();
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=5)
fluidInRecipe5 = ((AdvancedDistillationRecipe) recipe).getFifthFluidResult();
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=6)
fluidInRecipe6 = ((AdvancedDistillationRecipe) recipe).getSixthFluidResult();
@@ -211,26 +224,26 @@ if(fluidInRecipe2!=null)
)
return;
//
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=1)
if(tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getFirstFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=1)
if(tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=2)
if(((DistillationOutputBlockEntity)above1).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getSecondFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=2)
if(((DistillationOutputBlockEntity)above1).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getAmount()>8000)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=3)
if(((DistillationOutputBlockEntity)above2).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getThirdFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=3)
if(((DistillationOutputBlockEntity)above2).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getAmount()>8000)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=4)
if(((DistillationOutputBlockEntity)above3).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getFourthFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=4)
if(((DistillationOutputBlockEntity)above3).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getAmount()>8000)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=5)
if(((DistillationOutputBlockEntity)above4).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getFifthFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=5)
if(((DistillationOutputBlockEntity)above4).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getAmount()>8000)
return;
if(((AdvancedDistillationRecipe) currentRecipe).getOutputCount((AdvancedDistillationRecipe) currentRecipe)>=6)
if(((DistillationOutputBlockEntity)above5).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) currentRecipe).getSixthFluidResult().getAmount()>8000)
if(((AdvancedDistillationRecipe) recipe).getOutputCount((AdvancedDistillationRecipe) recipe)>=6)
if(((DistillationOutputBlockEntity)above5).tankInventory.getFluidAmount()+((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getAmount()>8000)
return;
if(getDistillationController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((AdvancedDistillationRecipe) currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
if(getDistillationController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((AdvancedDistillationRecipe) recipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
return;
DistillationControllerBlockEntity controller = optionalController.get();
@@ -262,30 +275,30 @@ if(fluidInRecipe2!=null)
return;
controller.getTanks().get(true).getPrimaryHandler().drain(((AdvancedDistillationRecipe) currentRecipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
controller.getTanks().get(true).getPrimaryHandler().drain(((AdvancedDistillationRecipe) recipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getFirstFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getFirstFluidResult().getAmount() + this.tankInventory.getFluidAmount()));
tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFirstFluidResult().getAmount() + this.tankInventory.getFluidAmount()));
if(above1 instanceof DistillationOutputBlockEntity)
if(foundOutputs>=2)
if (((AdvancedDistillationRecipe) currentRecipe).getResults().toArray().length>1)
((DistillationOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getSecondFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getSecondFluidResult().getAmount() + ((DistillationOutputBlockEntity) above1).tankInventory.getFluidAmount()));
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>1)
((DistillationOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getSecondFluidResult().getAmount() + ((DistillationOutputBlockEntity) above1).tankInventory.getFluidAmount()));
if(above2 instanceof DistillationOutputBlockEntity)
if(foundOutputs>=3)
if (((AdvancedDistillationRecipe) currentRecipe).getResults().toArray().length>2)
((DistillationOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getThirdFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getThirdFluidResult().getAmount() + ((DistillationOutputBlockEntity) above2).tankInventory.getFluidAmount()));
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>2)
((DistillationOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getThirdFluidResult().getAmount() + ((DistillationOutputBlockEntity) above2).tankInventory.getFluidAmount()));
if(above3 instanceof DistillationOutputBlockEntity)
if(foundOutputs>=4)
if (((AdvancedDistillationRecipe) currentRecipe).getResults().toArray().length>3)
((DistillationOutputBlockEntity) above3).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getFourthFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getFourthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above3).tankInventory.getFluidAmount()));
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>3)
((DistillationOutputBlockEntity) above3).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFourthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above3).tankInventory.getFluidAmount()));
if(above4 instanceof DistillationOutputBlockEntity)
if(foundOutputs>=5)
if (((AdvancedDistillationRecipe) currentRecipe).getResults().toArray().length>4)
((DistillationOutputBlockEntity) above4).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getFifthFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getFifthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above4).tankInventory.getFluidAmount()));
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>4)
((DistillationOutputBlockEntity) above4).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getFifthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above4).tankInventory.getFluidAmount()));
if(above5 instanceof DistillationOutputBlockEntity)
if(foundOutputs>=6)
if (((AdvancedDistillationRecipe) currentRecipe).getResults().toArray().length>5)
((DistillationOutputBlockEntity) above5).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) currentRecipe).getSixthFluidResult().getFluid(), ((AdvancedDistillationRecipe) currentRecipe).getSixthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above5).tankInventory.getFluidAmount()));
if (((AdvancedDistillationRecipe) recipe).getResults().toArray().length>5)
((DistillationOutputBlockEntity) above5).tankInventory.setFluid(new FluidStack(((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getFluid(), ((AdvancedDistillationRecipe) recipe).getSixthFluidResult().getAmount() + ((DistillationOutputBlockEntity) above5).tankInventory.getFluidAmount()));
}
/*
@@ -302,27 +315,43 @@ if(!(((AdvancedDistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()
}
@Override
protected List<Recipe<?>> getMatchingRecipes() {
// @Override
// protected List<Recipe<?>> getMatchingRecipes() {
//
//
// List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
// return list.stream()
// .filter(this::matchItemlessRecipe)
// .sorted((r1, r2) -> r2.getIngredients()
// .size()
// - r1.getIngredients()
// .size())
// .collect(Collectors.toList());
// }
protected AdvancedDistillationRecipe getMatchingRecipes(DistillationControllerBlockEntity be) {
List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
return list.stream()
.filter(this::matchItemlessRecipe)
.sorted((r1, r2) -> r2.getIngredients()
.size()
- r1.getIngredients()
.size())
.collect(Collectors.toList());
for(int i = 0; i < list.toArray().length;i++){
AdvancedDistillationRecipe recipe = (AdvancedDistillationRecipe) list.get(i);
if(recipe.getOutputCount(recipe)!=foundOutputs)
continue;
for(int y = 0; y < recipe.getFluidIngredients().get(0).getMatchingFluidStacks().toArray().length;y++)
if(be.inputTank.getPrimaryHandler().getFluid().getFluid()==recipe.getFluidIngredients().get(0).getMatchingFluidStacks().get(y).getFluid())
if(be.inputTank.getPrimaryHandler().getFluidAmount()>=recipe.getFluidIngredients().get(0).getRequiredAmount())
return recipe;
}
return null;
}
@Override
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
return ((r instanceof CraftingRecipe && !(r instanceof IShapedRecipe<?>)
&& r.getIngredients()
.size() > 1
&& !MechanicalPressBlockEntity.canCompress(r)) && !AllRecipeTypes.shouldIgnoreInAutomation(r)
|| r.getType() == TFMGRecipeTypes.ADVANCED_DISTILLATION.getType());
return r instanceof AdvancedDistillationRecipe;
}
@Override
@@ -340,7 +369,7 @@ if(!(((AdvancedDistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()
}
@Override
protected void onBasinRemoved() {
protected void onControllerRemoved() {
if (!running)
return;

View File

@@ -2,7 +2,9 @@ package com.drmangotea.createindustry.blocks.machines.oil_processing.distillatio
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.FluidProcessingBlockEntity;
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationControllerBlockEntity;
import com.drmangotea.createindustry.blocks.machines.oil_processing.distillation.distillation_tower.DistillationOutputBlockEntity;
import com.drmangotea.createindustry.recipes.distillation.AbstractDistillationRecipe;
import com.drmangotea.createindustry.recipes.distillation.DistillationRecipe;
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
import com.simibubi.create.AllRecipeTypes;
@@ -78,10 +80,8 @@ public class DistilleryOutputBlockEntity extends FluidProcessingBlockEntity impl
if (level == null || level.isClientSide)
return true;
List<Recipe<?>> recipes = getMatchingRecipes();
if (recipes.isEmpty())
return true;
currentRecipe = recipes.get(0);
recipe = getMatchingRecipes();
startProcessing();
sendData();
return true;
@@ -150,7 +150,7 @@ public class DistilleryOutputBlockEntity extends FluidProcessingBlockEntity impl
protected void process() {
updateController();
if (currentRecipe == null)
if (recipe == null)
return;
// if((currentRecipe instanceof ShapelessRecipe))
@@ -192,9 +192,9 @@ if(above1 !=null&& above2 !=null
return;
FluidStack fluidInRecipe1 = ((DistillationRecipe) currentRecipe).getFirstFluidResult();
FluidStack fluidInRecipe2 = ((DistillationRecipe) currentRecipe).getSecondFluidResult();
FluidStack fluidInRecipe3 = ((DistillationRecipe) currentRecipe).getThirdFluidResult();
FluidStack fluidInRecipe1 = ((DistillationRecipe) recipe).getFirstFluidResult();
FluidStack fluidInRecipe2 = ((DistillationRecipe) recipe).getSecondFluidResult();
FluidStack fluidInRecipe3 = ((DistillationRecipe) recipe).getThirdFluidResult();
@@ -214,14 +214,14 @@ if(above1 !=null&& above2 !=null
return;
if(
tankInventory.getFluidAmount()+((DistillationRecipe) currentRecipe).getFirstFluidResult().getAmount()>8000||
((DistilleryOutputBlockEntity)above1).tankInventory.getFluidAmount()+((DistillationRecipe) currentRecipe).getFirstFluidResult().getAmount()>8000||
((DistilleryOutputBlockEntity)above2).tankInventory.getFluidAmount()+((DistillationRecipe) currentRecipe).getFirstFluidResult().getAmount()>8000
tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000||
((DistilleryOutputBlockEntity)above1).tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000||
((DistilleryOutputBlockEntity)above2).tankInventory.getFluidAmount()+((DistillationRecipe) recipe).getFirstFluidResult().getAmount()>8000
)
return;
if(getController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((DistillationRecipe) currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
if(getController().get().getTanks().get(true).getPrimaryHandler().getFluid().getFluid() != ((DistillationRecipe) recipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid())
return;
DistilleryControllerBlockEntity controller = optionalController.get();
@@ -237,21 +237,21 @@ if(above1 !=null&& above2 !=null
// if(((DistillationRecipe)currentRecipe).getInputFluid().getMatchingFluidStacks().get(0).getFluid() != TFMGFluids.HEAVY_OIL.get())
// return;
controller.getTanks().get(true).getPrimaryHandler().drain(((DistillationRecipe) currentRecipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
controller.getTanks().get(true).getPrimaryHandler().drain(((DistillationRecipe) recipe).getFluidIngredients().get(0).getRequiredAmount(), IFluidHandler.FluidAction.EXECUTE);
if (!(((DistillationRecipe) currentRecipe).getFluidResults().get(0).isEmpty()))
tankInventory.setFluid(new FluidStack(((DistillationRecipe) currentRecipe).getFluidResults().get(0).getFluid(), ((DistillationRecipe) currentRecipe).getFluidResults().get(0).getAmount() + this.tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) currentRecipe).getFluidResults().get(1).isEmpty()))
((DistilleryOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((DistillationRecipe) currentRecipe).getFluidResults().get(1).getFluid(), ((DistillationRecipe) currentRecipe).getFluidResults().get(1).getAmount() + ((DistilleryOutputBlockEntity) above1).tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) currentRecipe).getFluidResults().get(2).isEmpty()))
((DistilleryOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((DistillationRecipe) currentRecipe).getFluidResults().get(2).getFluid(), ((DistillationRecipe) currentRecipe).getFluidResults().get(2).getAmount() + ((DistilleryOutputBlockEntity) above2).tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) recipe).getFluidResults().get(0).isEmpty()))
tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(0).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(0).getAmount() + this.tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) recipe).getFluidResults().get(1).isEmpty()))
((DistilleryOutputBlockEntity) above1).tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(1).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(1).getAmount() + ((DistilleryOutputBlockEntity) above1).tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) recipe).getFluidResults().get(2).isEmpty()))
((DistilleryOutputBlockEntity) above2).tankInventory.setFluid(new FluidStack(((DistillationRecipe) recipe).getFluidResults().get(2).getFluid(), ((DistillationRecipe) recipe).getFluidResults().get(2).getAmount() + ((DistilleryOutputBlockEntity) above2).tankInventory.getFluidAmount()));
if (!(((DistillationRecipe) currentRecipe).getFirstItemResult().isEmpty()))
controller.outputInventory.setItem(0, ((DistillationRecipe) currentRecipe).getFirstItemResult());
if (!(((DistillationRecipe) recipe).getFirstItemResult().isEmpty()))
controller.outputInventory.setItem(0, ((DistillationRecipe) recipe).getFirstItemResult());
if (!(((DistillationRecipe) currentRecipe).getSecondItemResult().isEmpty()))
controller.outputInventory.setItem(1, ((DistillationRecipe) currentRecipe).getSecondItemResult());
if (!(((DistillationRecipe) recipe).getSecondItemResult().isEmpty()))
controller.outputInventory.setItem(1, ((DistillationRecipe) recipe).getSecondItemResult());
}
/*
if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
@@ -267,27 +267,33 @@ if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
}
@Override
protected List<Recipe<?>> getMatchingRecipes() {
protected DistillationRecipe getMatchingRecipes() {
DistilleryControllerBlockEntity be=null;
if(level.getBlockEntity(getBlockPos().below())instanceof DistilleryControllerBlockEntity)
be = (DistilleryControllerBlockEntity) level.getBlockEntity(getBlockPos().below());
if(be==null)
return null;
List<Recipe<?>> list = RecipeFinder.get(getRecipeCacheKey(), level, this::matchStaticFilters);
return list.stream()
.filter(this::matchItemlessRecipe)
.sorted((r1, r2) -> r2.getIngredients()
.size()
- r1.getIngredients()
.size())
.collect(Collectors.toList());
for(int i = 0; i < list.toArray().length;i++){
DistillationRecipe recipe = (DistillationRecipe) list.get(i);
for(int y = 0; y < recipe.getFluidIngredients().get(0).getMatchingFluidStacks().toArray().length;y++)
if(be.inputTank.getPrimaryHandler().getFluid().getFluid()==recipe.getFluidIngredients().get(0).getMatchingFluidStacks().get(y).getFluid())
if(be.inputTank.getPrimaryHandler().getFluidAmount()>=recipe.getFluidIngredients().get(0).getRequiredAmount())
return recipe;
}
return null;
}
@Override
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
return ((r instanceof CraftingRecipe && !(r instanceof IShapedRecipe<?>)
&& r.getIngredients()
.size() > 1
&& !MechanicalPressBlockEntity.canCompress(r)) && !AllRecipeTypes.shouldIgnoreInAutomation(r)
|| r.getType() == TFMGRecipeTypes.DISTILLATION.getType());
return r instanceof DistillationRecipe;
}
@Override
@@ -305,7 +311,7 @@ if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
}
@Override
protected void onBasinRemoved() {
protected void onControllerRemoved() {
if (!running)
return;
@@ -367,7 +373,7 @@ if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
@SuppressWarnings("removal")
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
return containedFluidTooltip(tooltip, isPlayerSneaking,
@@ -375,6 +381,7 @@ if(!(((DistillationRecipe) currentRecipe).getThirdItemResult().isEmpty()))
}
@Nonnull
@SuppressWarnings("removal")
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (!fluidCapability.isPresent())

View File

@@ -23,15 +23,15 @@ import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
@SuppressWarnings("removal")
public class AbstractDistillationRecipe extends ProcessingRecipe<SmartInventory> {
public static boolean match(DistilleryControllerBlockEntity controller, Recipe<?> recipe) {
if(recipe instanceof ItemlessRecipe) {
if(recipe instanceof AbstractDistillationRecipe) {
return apply(controller, recipe, true);
}
@@ -45,7 +45,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
}
private static boolean apply(DistilleryControllerBlockEntity controller, Recipe<?> recipe, boolean test) {
boolean isItemlessRecipe = recipe instanceof ItemlessRecipe;
boolean isItemlessRecipe = recipe instanceof AbstractDistillationRecipe;
IItemHandler availableItems = controller.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
.orElse(null);
IFluidHandler availableFluids = controller.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
@@ -57,7 +57,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
BlazeBurnerBlock.HeatLevel heat = DistilleryControllerBlockEntity.getHeatLevelOf(controller.getLevel()
.getBlockState(controller.getBlockPos()
.below(1)));
if (isItemlessRecipe && !((ItemlessRecipe) recipe).getRequiredHeat()
if (isItemlessRecipe && !((AbstractDistillationRecipe) recipe).getRequiredHeat()
.testBlazeBurner(heat))
return false;
@@ -66,7 +66,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
List<FluidIngredient> fluidIngredients =
isItemlessRecipe ? ((ItemlessRecipe) recipe).getFluidIngredients() : Collections.emptyList();
isItemlessRecipe ? ((AbstractDistillationRecipe) recipe).getFluidIngredients() : Collections.emptyList();
if(!fluidIngredients.isEmpty())
@@ -116,7 +116,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
}
if (simulate) {
if (recipe instanceof ItemlessRecipe ItemlessRecipe) {
if (recipe instanceof AbstractDistillationRecipe ItemlessRecipe) {
recipeOutputItems.addAll(ItemlessRecipe.rollResults());
recipeOutputFluids.addAll(ItemlessRecipe.getFluidResults());
@@ -132,7 +132,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
public static boolean match2(DistillationControllerBlockEntity controller, Recipe<?> recipe) {
if(recipe instanceof ItemlessRecipe) {
if(recipe instanceof AbstractDistillationRecipe) {
return apply(controller, recipe, true);
}
@@ -141,7 +141,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
}
private static boolean apply2(DistillationControllerBlockEntity controller, Recipe<?> recipe, boolean test) {
boolean isItemlessRecipe = recipe instanceof ItemlessRecipe;
boolean isItemlessRecipe = recipe instanceof AbstractDistillationRecipe;
IItemHandler availableItems = controller.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
.orElse(null);
IFluidHandler availableFluids = controller.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
@@ -153,7 +153,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
BlazeBurnerBlock.HeatLevel heat = DistilleryControllerBlockEntity.getHeatLevelOf(controller.getLevel()
.getBlockState(controller.getBlockPos()
.below(1)));
if (isItemlessRecipe && !((ItemlessRecipe) recipe).getRequiredHeat()
if (isItemlessRecipe && !((AbstractDistillationRecipe) recipe).getRequiredHeat()
.testBlazeBurner(heat))
return false;
@@ -162,7 +162,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
List<FluidIngredient> fluidIngredients =
isItemlessRecipe ? ((ItemlessRecipe) recipe).getFluidIngredients() : Collections.emptyList();
isItemlessRecipe ? ((AbstractDistillationRecipe) recipe).getFluidIngredients() : Collections.emptyList();
if(!fluidIngredients.isEmpty())
@@ -212,7 +212,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
}
if (simulate) {
if (recipe instanceof ItemlessRecipe ItemlessRecipe) {
if (recipe instanceof AbstractDistillationRecipe ItemlessRecipe) {
recipeOutputItems.addAll(ItemlessRecipe.rollResults());
recipeOutputFluids.addAll(ItemlessRecipe.getFluidResults());
@@ -226,7 +226,7 @@ public class ItemlessRecipe extends ProcessingRecipe<SmartInventory> {
return true;
}
protected ItemlessRecipe(IRecipeTypeInfo type, ProcessingRecipeBuilder.ProcessingRecipeParams params) {
protected AbstractDistillationRecipe(IRecipeTypeInfo type, ProcessingRecipeBuilder.ProcessingRecipeParams params) {
super(type, params);
}

View File

@@ -4,12 +4,12 @@ package com.drmangotea.createindustry.recipes.distillation;
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
import com.simibubi.create.foundation.fluid.FluidIngredient;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class AdvancedDistillationRecipe extends ItemlessRecipe {
public class AdvancedDistillationRecipe extends AbstractDistillationRecipe {
public AdvancedDistillationRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) {
super(TFMGRecipeTypes.ADVANCED_DISTILLATION, params);
@@ -56,4 +56,11 @@ public class AdvancedDistillationRecipe extends ItemlessRecipe {
protected int getMaxOutputCount() {
return 0;
}
public boolean matches(CombinedTankWrapper inv) {
if (inv.getFluidInTank(0).getAmount()==0)
return false;
return fluidIngredients.get(0)
.test(inv.getFluidInTank(0));
}
}

View File

@@ -5,11 +5,10 @@ package com.drmangotea.createindustry.recipes.distillation;
import com.drmangotea.createindustry.registry.TFMGRecipeTypes;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.fluid.FluidIngredient;
import mezz.jei.api.constants.RecipeTypes;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class DistillationRecipe extends ItemlessRecipe {
public class DistillationRecipe extends AbstractDistillationRecipe {
public DistillationRecipe(ProcessingRecipeBuilder.ProcessingRecipeParams params) {
super(TFMGRecipeTypes.DISTILLATION, params);

View File

@@ -500,7 +500,7 @@ public static final BlockEntry<DistillationOutputBlock> STEEL_DISTILLATION_OUTPU
public static final BlockEntry<DistillationControllerBlock> STEEL_DISTILLATION_CONTROLLER =
REGISTRATE.block("steel_distillation_controller", DistillationControllerBlock::new)
.initialProperties(SharedProperties::copperMetal)
.blockstate((ctx, prov) -> prov.simpleBlock(ctx.getEntry(), AssetLookup.partialBaseModel(ctx, prov)))
.blockstate((c, p) -> p.horizontalFaceBlock(c.get(), AssetLookup.partialBaseModel(c, p)))
.transform(pickaxeOnly())
.item()
.build()

View File

@@ -1,3 +1,6 @@
{
"parent": "block/air"
"parent": "block/air",
"textures": {
"particle": "createindustry:block/air_intake/air_intake_small"
}
}

View File

@@ -0,0 +1,24 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "createindustry:block/distillation_controller",
"1": "createindustry:block/distillation_controller_front",
"2": "createindustry:block/distillation_controller_top",
"particle": "createindustry:block/distillation_controller"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#2"},
"down": {"uv": [0, 0, 16, 16], "texture": "#2"}
}
}
]
}

View File

@@ -12,12 +12,12 @@
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#2"},
"down": {"uv": [0, 0, 16, 16], "texture": "#2"}
"north": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#2"},
"east": {"uv": [0, 0, 16, 16], "rotation": 270, "texture": "#0"},
"south": {"uv": [0, 0, 16, 16], "texture": "#2"},
"west": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#1"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]

View File

@@ -21,10 +21,6 @@
"fluid": "createindustry:kerosene",
"amount": 1
},
{
"fluid": "createindustry:naphtha",
"amount": 1
},
{
"fluid": "createindustry:gasoline",
"amount": 3