Skip to content

Commit

Permalink
Add selective voiding and ME hatch capabillity to Distillation Tower …
Browse files Browse the repository at this point in the history
…multiblocks (#2261)
  • Loading branch information
krossgg authored Nov 6, 2024
1 parent 13c6604 commit d868b95
Show file tree
Hide file tree
Showing 11 changed files with 516 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public List<Object> compressIngredients(Collection<Object> ingredients) {

@Override
public int limitParallel(GTRecipe recipe, IRecipeCapabilityHolder holder, int multiplier) {
if (holder instanceof ICustomParallel p) return p.limitParallel(recipe, multiplier);

long maxVoltage = Long.MAX_VALUE;
if (holder instanceof IOverclockMachine overclockMachine) {
maxVoltage = overclockMachine.getOverclockVoltage();
Expand Down Expand Up @@ -71,4 +73,16 @@ public int getMaxParallelRatio(IRecipeCapabilityHolder holder, GTRecipe recipe,
}
return Math.abs(Ints.saturatedCast(maxVoltage / recipeEUt));
}

public interface ICustomParallel {

/**
* Custom impl of the parallel limiter used by ParallelLogic to limit by outputs
*
* @param recipe Recipe
* @param multiplier Initial multiplier
* @return Limited multiplier
*/
int limitParallel(GTRecipe recipe, int multiplier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public boolean isRecipeSearchFilter() {

@Override
public int limitParallel(GTRecipe recipe, IRecipeCapabilityHolder holder, int multiplier) {
if (holder instanceof ICustomParallel p) return p.limitParallel(recipe, multiplier);

int minMultiplier = 0;
int maxMultiplier = multiplier;

Expand Down Expand Up @@ -387,4 +389,16 @@ public static Either<List<Pair<TagKey<Fluid>, Integer>>, List<FluidStack>> mapFl
public Object2IntMap<FluidIngredient> makeChanceCache() {
return super.makeChanceCache();
}

public interface ICustomParallel {

/**
* Custom impl of the parallel limiter used by ParallelLogic to limit by outputs
*
* @param recipe Recipe
* @param multiplier Initial multiplier
* @return Limited multiplier
*/
int limitParallel(GTRecipe recipe, int multiplier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public boolean isRecipeSearchFilter() {

@Override
public int limitParallel(GTRecipe recipe, IRecipeCapabilityHolder holder, int multiplier) {
if (holder instanceof ICustomParallel p) return p.limitParallel(recipe, multiplier);

int minMultiplier = 0;
int maxMultiplier = multiplier;

Expand Down Expand Up @@ -721,4 +723,16 @@ private static Either<List<Pair<TagKey<Item>, Integer>>, List<ItemStack>> mapIte
public Object2IntMap<Ingredient> makeChanceCache() {
return new Object2IntOpenCustomHashMap<>(IngredientEquality.IngredientHashStrategy.INSTANCE);
}

public interface ICustomParallel {

/**
* Custom impl of the parallel limiter used by ParallelLogic to limit by outputs
*
* @param recipe Recipe
* @param multiplier Initial multiplier
* @return Limited multiplier
*/
int limitParallel(GTRecipe recipe, int multiplier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum Status {
@Persisted
@DescSynced
@UpdateListener(methodName = "onActiveSynced")
private boolean isActive;
protected boolean isActive;

@Nullable
@Persisted
Expand Down Expand Up @@ -308,7 +308,7 @@ public void findAndHandleRecipe() {
recipeDirty = false;
}

private void handleSearchingRecipes(Iterator<GTRecipe> matches) {
protected void handleSearchingRecipes(Iterator<GTRecipe> matches) {
while (matches != null && matches.hasNext()) {
GTRecipe match = matches.next();
if (match == null) continue;
Expand Down
74 changes: 54 additions & 20 deletions src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Supplier;
Expand Down Expand Up @@ -1581,27 +1578,64 @@ public static BiConsumer<ItemStack, List<Component>> createTankTooltips(String n
.register();

public static final MultiblockMachineDefinition DISTILLATION_TOWER = REGISTRATE
.multiblock("distillation_tower", WorkableElectricMultiblockMachine::new)
.multiblock("distillation_tower", DistillationTowerMachine::new)
.rotationState(RotationState.NON_Y_AXIS)
.recipeType(GTRecipeTypes.DISTILLATION_RECIPES)
.recipeModifiers(
GTRecipeModifiers.ELECTRIC_OVERCLOCK.apply(OverclockingLogic.NON_PERFECT_OVERCLOCK_SUBTICK))
.appearanceBlock(CASING_STAINLESS_CLEAN)
.pattern(definition -> FactoryBlockPattern.start(RIGHT, BACK, UP)
.aisle("YSY", "YYY", "YYY")
.aisle("XXX", "X#X", "XXX").setRepeatable(1, 11)
.aisle("XXX", "XXX", "XXX")
.where('S', Predicates.controller(blocks(definition.getBlock())))
.where('Y', blocks(CASING_STAINLESS_CLEAN.get())
.or(Predicates.abilities(PartAbility.EXPORT_ITEMS).setMaxGlobalLimited(1))
.or(Predicates.abilities(PartAbility.INPUT_ENERGY).setMinGlobalLimited(1)
.setMaxGlobalLimited(2))
.or(Predicates.abilities(PartAbility.IMPORT_FLUIDS).setExactLimit(1)))
.where('X', blocks(CASING_STAINLESS_CLEAN.get())
.or(Predicates.abilities(PartAbility.EXPORT_FLUIDS_1X).setMinLayerLimited(1)
.setMaxLayerLimited(1)))
.where('#', Predicates.air())
.build())
.pattern(definition -> {
TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X);
if (GTCEu.isAE2Loaded())
exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get()));
exportPredicate.setMaxLayerLimited(1);
return FactoryBlockPattern.start(RIGHT, BACK, UP)
.aisle("YSY", "YYY", "YYY")
.aisle("XXX", "X#X", "XXX").setRepeatable(1, 11)
.aisle("XXX", "XXX", "XXX")
.where('S', Predicates.controller(blocks(definition.getBlock())))
.where('Y', blocks(CASING_STAINLESS_CLEAN.get())
.or(Predicates.abilities(PartAbility.EXPORT_ITEMS).setMaxGlobalLimited(1))
.or(Predicates.abilities(PartAbility.INPUT_ENERGY).setMinGlobalLimited(1)
.setMaxGlobalLimited(2))
.or(Predicates.abilities(PartAbility.IMPORT_FLUIDS).setExactLimit(1))
.or(autoAbilities(true, false, false)))
.where('X', blocks(CASING_STAINLESS_CLEAN.get()).or(exportPredicate))
.where('#', Predicates.air())
.build();
})
.shapeInfos(definition -> {
List<MultiblockShapeInfo> shapeInfos = new ArrayList<>();
var builder = MultiblockShapeInfo.builder()
.where('C', definition, Direction.NORTH)
.where('S', CASING_STAINLESS_CLEAN.getDefaultState())
.where('X', ITEM_EXPORT_BUS[HV], Direction.NORTH)
.where('I', FLUID_IMPORT_HATCH[HV], Direction.NORTH)
.where('E', ENERGY_INPUT_HATCH[HV], Direction.SOUTH)
.where('M', MAINTENANCE_HATCH, Direction.SOUTH)
.where('#', Blocks.AIR.defaultBlockState())
.where('F', FLUID_EXPORT_HATCH[HV], Direction.SOUTH);
List<String> front = new ArrayList<>(15);
front.add("XCI");
front.add("SSS");
List<String> middle = new ArrayList<>(15);
middle.add("SSS");
middle.add("SSS");
List<String> back = new ArrayList<>(15);
back.add("MES");
back.add("SFS");
for (int i = 1; i <= 11; ++i) {
front.add("SSS");
middle.add(1, "S#S");
back.add("SFS");
var copy = builder.shallowCopy()
.aisle(front.toArray(String[]::new))
.aisle(middle.toArray(String[]::new))
.aisle(back.toArray(String[]::new));
shapeInfos.add(copy.build());
}
return shapeInfos;
})
.allowExtendedFacing(false)
.partSorter(Comparator.comparingInt(a -> a.self().getPos().getY()))
.workableCasingRenderer(GTCEu.id("block/casings/solid/machine_casing_clean_stainless_steel"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate;
import com.gregtechceu.gtceu.api.recipe.OverclockingLogic;
import com.gregtechceu.gtceu.common.data.*;
import com.gregtechceu.gtceu.common.machine.multiblock.electric.DistillationTowerMachine;
import com.gregtechceu.gtceu.common.machine.multiblock.part.ParallelHatchPartMachine;
import com.gregtechceu.gtceu.utils.FormattingUtil;

Expand Down Expand Up @@ -643,7 +644,7 @@ public static void init() {}
.register();

public final static MultiblockMachineDefinition LARGE_DISTILLERY = REGISTRATE
.multiblock("large_distillery", WorkableElectricMultiblockMachine::new)
.multiblock("large_distillery", DistillationTowerMachine::new)
.langValue("Large Fractionating Distillery")
.tooltips(Component.translatable("gtceu.multiblock.parallelizable.tooltip"))
.tooltips(Component.translatable("gtceu.machine.available_recipe_map_2.tooltip",
Expand All @@ -655,7 +656,10 @@ public static void init() {}
.appearanceBlock(CASING_WATERTIGHT)
.pattern(definition -> {
TraceabilityPredicate casingPredicate = blocks(CASING_WATERTIGHT.get()).setMinGlobalLimited(40);

TraceabilityPredicate exportPredicate = abilities(PartAbility.EXPORT_FLUIDS_1X);
if (GTCEu.isAE2Loaded())
exportPredicate = exportPredicate.or(blocks(GTAEMachines.FLUID_EXPORT_HATCH_ME.get()));
exportPredicate.setMaxLayerLimited(1);
return FactoryBlockPattern.start(RIGHT, BACK, UP)
.aisle("#YYY#", "YYYYY", "YYYYY", "YYYYY", "#YYY#")
.aisle("#YSY#", "YAAAY", "YAAAY", "YAAAY", "#YYY#")
Expand All @@ -667,15 +671,64 @@ public static void init() {}
.or(abilities(IMPORT_FLUIDS).setMinGlobalLimited(1))
.or(abilities(EXPORT_ITEMS))
.or(autoAbilities(true, false, true)))
.where('X', casingPredicate
.or(abilities(EXPORT_FLUIDS_1X).setMinLayerLimited(1).setMaxLayerLimited(1)))
.where('X', casingPredicate.or(exportPredicate))
.where('Z', casingPredicate)
.where('P', blocks(CASING_STEEL_PIPE.get()))
.where('C', abilities(MUFFLER))
.where('A', air())
.where('#', any())
.build();
})
.shapeInfos(definition -> {
List<MultiblockShapeInfo> shapeInfos = new ArrayList<>();
var builder = MultiblockShapeInfo.builder()
.where('S', definition, Direction.NORTH)
.where('C', CASING_WATERTIGHT.getDefaultState())
.where('M', MUFFLER_HATCH[IV], Direction.UP)
.where('X', PARALLEL_HATCH[IV], Direction.NORTH)
.where('H', FLUID_IMPORT_HATCH[IV], Direction.NORTH)
.where('B', ITEM_EXPORT_BUS[IV], Direction.NORTH)
.where('N', MAINTENANCE_HATCH, Direction.NORTH)
.where('P', CASING_STEEL_PIPE.getDefaultState())
.where('F', FLUID_EXPORT_HATCH[IV], Direction.SOUTH)
.where('E', ENERGY_INPUT_HATCH[IV], Direction.SOUTH)
.where('#', Blocks.AIR.defaultBlockState());
List<String> aisle1 = new ArrayList<>(16);
aisle1.add("#HCB#");
aisle1.add("#NSX#");
aisle1.add("#####");
List<String> aisle2 = new ArrayList<>(16);
aisle2.add("CCCCC");
aisle2.add("C###C");
aisle2.add("#CCC#");
List<String> aisle3 = new ArrayList<>(16);
aisle3.add("CCCCC");
aisle3.add("C###C");
aisle3.add("#CMC#");
List<String> aisle4 = new ArrayList<>(16);
aisle4.add("CCCCC");
aisle4.add("C###C");
aisle4.add("#CCC#");
List<String> aisle5 = new ArrayList<>(16);
aisle5.add("#CEC#");
aisle5.add("#CCC#");
aisle5.add("#####");
for (int i = 1; i <= 12; ++i) {
aisle1.add(2, "##C##");
aisle2.add(2, "#C#C#");
aisle3.add(2, "C#P#C");
aisle4.add(2, "#C#C#");
aisle5.add(2, "##F##");
var copy = builder.shallowCopy()
.aisle(aisle1.toArray(String[]::new))
.aisle(aisle2.toArray(String[]::new))
.aisle(aisle3.toArray(String[]::new))
.aisle(aisle4.toArray(String[]::new))
.aisle(aisle5.toArray(String[]::new));
shapeInfos.add(copy.build());
}
return shapeInfos;
})
.partSorter(Comparator.comparingInt(a -> a.self().getPos().getY()))
.workableCasingRenderer(GTCEu.id("block/casings/gcym/watertight_casing"),
GTCEu.id("block/multiblock/gcym/large_distillery"))
Expand Down
Loading

0 comments on commit d868b95

Please sign in to comment.