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 @@ -79,20 +79,6 @@ default boolean canShared() {
return false;
}

/**
* @param duration recipe progress time
* @return it's time for a new problem occurring;
*/
default boolean calculateTime(int duration) {
setTimeActive(duration + getTimeActive());
var value = getTimeActive() - ConfigHolder.INSTANCE.machines.maintenanceTime;
if (value > 0) {
setTimeActive(value);
return true;
}
return false;
}

/**
* Used to calculate whether a maintenance problem should happen based on machine time active
*
Expand All @@ -103,14 +89,24 @@ default void calculateMaintenance(IMaintenanceMachine maintenanceMachine, int du
return;
}

if (calculateTime((int) (duration * maintenanceMachine.getTimeMultiplier()))) {
if (GTValues.RNG.nextFloat() - 0.75f >= 0) {
setTimeActive(getTimeActive() + duration);
float rate = ConfigHolder.INSTANCE.machines.maintenanceCheckRate / maintenanceMachine.getTimeMultiplier();
if (getTimeActive() >= rate) {
setTimeActive(0);
if (GTValues.RNG.nextInt(6000) == 0) {
causeRandomMaintenanceProblems();
maintenanceMachine.setTaped(false);
}
}
}

/**
* Used to calculate whether a maintenance problem should happen based on machine time active
*/
default void calculateMaintenance(IMaintenanceMachine maintenanceMachine) {
calculateMaintenance(maintenanceMachine, 1);
}

default int getNumMaintenanceProblems() {
return ConfigHolder.INSTANCE.machines.enableMaintenance ? 6 - Integer.bitCount(getMaintenanceProblems()) : 0;
}
Expand All @@ -129,13 +125,10 @@ default void causeRandomMaintenanceProblems() {
}

@Override
default boolean afterWorking(IWorkableMultiController controller) {
if (ConfigHolder.INSTANCE.machines.enableMaintenance) {
calculateMaintenance(this, controller.getRecipeLogic().getProgress());
if (hasMaintenanceProblems()) {
controller.getRecipeLogic().markLastRecipeDirty();
return false;
}
default boolean onWorking(IWorkableMultiController controller) {
calculateMaintenance(this);
if (hasMaintenanceProblems()) {
controller.getRecipeLogic().markLastRecipeDirty();
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,10 @@ public static class MachineConfigs {
public boolean enableMaintenance = true;
@Configurable
@Configurable.Comment({
"Time in ticks between when Multiblocks can require Maintenance. By default, 48 hours.",
"Default: 3456000" })
public int maintenanceTime = 3456000;
"How often to check for maintenance, rolling a 1/6000 chance every X ticks (before secondary effects like Configurable Maintenance Hatch).",
"In default settings, this equates to a 5% chance every hour of a machine running.",
"Default: 1000 (ticks)" })
public int maintenanceCheckRate = 1000;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I purposefully renamed this since:

  1. It serves a very different purpose mathematically compared to before
  2. The old default value of this config would lead to an even less likely chance of maintenance occurring than before with the old math


@Configurable
@Configurable.Comment({
Expand Down