Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,27 @@ public static void setBuilt(MachineDefinition state) {
public static void clearBuilt() {
STATE.remove();
}

/**
* Gets the input size for a machine for the capability with the machine having the specified recipe types
*/
public int getInputSize(RecipeCapability<?> cap, GTRecipeType... recipeTypes) {
int recipeTypeInputSize = 0;
for (var recipeType : recipeTypes) {
recipeTypeInputSize = Math.max(recipeType.getMaxInputs(cap), recipeTypeInputSize);
}
return recipeTypeInputSize;
}

/**
* Gets the output size for a machine for the capability with the machine having the specified recipe types
*/
public int getOutputSize(RecipeCapability<?> cap, GTRecipeType... recipeTypes) {
int recipeTypeOutputSize = 0;
for (var recipeType : recipeTypes) {
recipeTypeOutputSize = Math.max(recipeType.getMaxOutputs(cap), recipeTypeOutputSize);
}
int machineTypeOutputLimit = this.getRecipeOutputLimits().getOrDefault(cap, recipeTypeOutputSize);
return Math.min(recipeTypeOutputSize, machineTypeOutputLimit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,17 @@ public WorkableTieredMachine(BlockEntityCreationInfo info, int tier, boolean ene
this.recipeLogic = attachTrait(new RecipeLogic());
this.recipeLogic.setKeepSubscribing(false);
this.importItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxInputs(ItemRecipeCapability.CAP),
new NotifiableItemStackHandler(getDefinition().getInputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.IN, IO.BOTH));
this.exportItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxOutputs(ItemRecipeCapability.CAP),
new NotifiableItemStackHandler(
getDefinition().getOutputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.OUT));
this.importFluids = attachTrait(new NotifiableFluidTank(getRecipeType().getMaxInputs(FluidRecipeCapability.CAP),
tankScalingFunction.applyAsInt(getTier()), IO.IN));
this.importFluids = attachTrait(
new NotifiableFluidTank(getDefinition().getInputSize(FluidRecipeCapability.CAP, getRecipeTypes()),
tankScalingFunction.applyAsInt(getTier()), IO.IN));
this.exportFluids = attachTrait(
new NotifiableFluidTank(getRecipeType().getMaxOutputs(FluidRecipeCapability.CAP),
new NotifiableFluidTank(getDefinition().getOutputSize(FluidRecipeCapability.CAP, getRecipeTypes()),
tankScalingFunction.applyAsInt(getTier()), IO.OUT));
this.importComputation = attachTrait(new NotifiableComputationContainer(IO.IN, true));
this.exportComputation = attachTrait(new NotifiableComputationContainer(IO.OUT, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public SimpleSteamMachine(BlockEntityCreationInfo info, RecipeLogic recipeLogic,
public SimpleSteamMachine(BlockEntityCreationInfo info, boolean isHighPressure) {
super(info, isHighPressure);
this.importItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxInputs(ItemRecipeCapability.CAP), IO.IN, IO.BOTH));
new NotifiableItemStackHandler(getDefinition().getInputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.IN, IO.BOTH));
this.exportItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxOutputs(ItemRecipeCapability.CAP), IO.OUT));
new NotifiableItemStackHandler(
getDefinition().getOutputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.OUT));

this.exhaustVentTrait = attachTrait(new ExhaustVentMachineTrait());
exhaustVentTrait.setVentingDamageAmount(isHighPressure() ? 12F : 6F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ public PrimitiveWorkableMachine(BlockEntityCreationInfo info, RecipeLogic recipe
public PrimitiveWorkableMachine(BlockEntityCreationInfo info) {
super(info);
this.importItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxInputs(ItemRecipeCapability.CAP), IO.IN));
new NotifiableItemStackHandler(getDefinition().getInputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.IN));
this.exportItems = attachTrait(
new NotifiableItemStackHandler(getRecipeType().getMaxOutputs(ItemRecipeCapability.CAP), IO.OUT));
this.importFluids = attachTrait(new NotifiableFluidTank(getRecipeType().getMaxInputs(FluidRecipeCapability.CAP),
32 * FluidType.BUCKET_VOLUME, IO.IN));
new NotifiableItemStackHandler(
getDefinition().getOutputSize(ItemRecipeCapability.CAP, getRecipeTypes()),
IO.OUT));
this.importFluids = attachTrait(
new NotifiableFluidTank(getDefinition().getInputSize(FluidRecipeCapability.CAP, getRecipeTypes()),
32 * FluidType.BUCKET_VOLUME, IO.IN));
this.exportFluids = attachTrait(
new NotifiableFluidTank(getRecipeType().getMaxOutputs(FluidRecipeCapability.CAP),
new NotifiableFluidTank(getDefinition().getOutputSize(FluidRecipeCapability.CAP, getRecipeTypes()),
32 * FluidType.BUCKET_VOLUME, IO.OUT));
this.hazardEmitter = attachTrait(
new EnvironmentalHazardEmitterTrait(GTMedicalConditions.CARBON_MONOXIDE_POISONING,
Expand Down
Loading