Skip to content

Commit

Permalink
add machine controller situation logic to covers and machines
Browse files Browse the repository at this point in the history
add capability related situation logic to covers
  • Loading branch information
PrototypeTrousers committed Nov 29, 2020
1 parent b8325af commit 60a2b47
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/main/java/gregtech/api/Situations.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ public class Situations {
public static Situation WORKING = new Situation(0, "working", SituationsTypes.WORKING, "gregtech.situation.working");

public static Situation IDLE = new Situation(1, "idle", SituationsTypes.IDLE, "gregtech.situation.idle");
public static Situation DISABLED_BY_CONTROLLER = new Situation(2, "workingdisabled", SituationsTypes.IDLE, "gregtech.situation.disabled_by_controller");

public static Situation EMPTY_SOURCE = new Situation(2, "emptysource", SituationsTypes.WARNING, "gregtech.situation.empty_source");
public static Situation INSUFFICIENT_POWER = new Situation(3, "nopower", SituationsTypes.WARNING, "gregtech.situation.insufficient_power");
public static Situation NO_MATCHING_RECIPE = new Situation(4, "norecipe", SituationsTypes.WARNING, "gregtech.situation.no_matching_recipe");
public static Situation OUTPUT_INVENTORY_FULL = new Situation(5, "outputfull", SituationsTypes.WARNING, "gregtech.situation.output_inventory_full");
public static Situation TARGET_INVENTORY_FULL = new Situation(6, "targetfull", SituationsTypes.WARNING, "gregtech.situation.target_inventory_full");
public static Situation EMPTY_SOURCE = new Situation(3, "emptysource", SituationsTypes.WARNING, "gregtech.situation.empty_source");
public static Situation INSUFFICIENT_POWER = new Situation(4, "nopower", SituationsTypes.WARNING, "gregtech.situation.insufficient_power");
public static Situation NO_MATCHING_RECIPE = new Situation(5, "norecipe", SituationsTypes.WARNING, "gregtech.situation.no_matching_recipe");
public static Situation OUTPUT_INVENTORY_FULL = new Situation(6, "outputfull", SituationsTypes.WARNING, "gregtech.situation.output_inventory_full");
public static Situation TARGET_INVENTORY_FULL = new Situation(7, "targetfull", SituationsTypes.WARNING, "gregtech.situation.target_inventory_full");

public static Situation EXPECTED_CAPABILITY_UNAVAILABLE = new Situation(7, "nullcapability", SituationsTypes.ERROR, "gregtech.situation.null_capability");
public static Situation NO_IMPORT_INVENTORY = new Situation(8, "noimportinv", SituationsTypes.ERROR, "gregtech.situation.no_import_inventory");
public static Situation NO_EXPORT_INVENTORY = new Situation(9, "noexportinv", SituationsTypes.ERROR, "gregtech.situation.no_export_inventory");
public static Situation NO_IMPORT_TANK = new Situation(10, "noimporttank", SituationsTypes.ERROR, "gregtech.situation.no_import_tank");
public static Situation NO_EXPORT_TANK = new Situation(11, "noexporttank", SituationsTypes.ERROR, "gregtech.situation.no_export_tank");
public static Situation EXPECTED_CAPABILITY_UNAVAILABLE = new Situation(12, "nullcapability", SituationsTypes.ERROR, "gregtech.situation.null_capability");

public enum SituationsTypes {
WORKING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public void update() {
metaTileEntity.setSituation(OUTPUT_INVENTORY_FULL);
}
}
else {
metaTileEntity.setSituation(DISABLED_BY_CONTROLLER);
}
}
if (wasActiveAndNeedsUpdate) {
this.wasActiveAndNeedsUpdate = false;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/gregtech/common/covers/CoverConveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void update() {
return;
}
if (itemHandler == null) {
setSituation(IDLE);
if (conveyorMode == ConveyorMode.IMPORT) setSituation(NO_IMPORT_INVENTORY);
if (conveyorMode == ConveyorMode.EXPORT) setSituation(NO_EXPORT_INVENTORY);
return;
}
int totalTransferred = doTransferItems(itemHandler, myItemHandler, itemsLeftToTransferLastSecond);
Expand All @@ -125,6 +126,9 @@ public void update() {
}
this.itemsLeftToTransferLastSecond = transferRate;
}
if (!isWorkingAllowed) {
setSituation(DISABLED_BY_CONTROLLER);
}
}

protected int doTransferItems(IItemHandler itemHandler, IItemHandler myItemHandler, int maxTransferAmount) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/gregtech/common/covers/CoverPump.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public void update() {
}
this.fluidLeftToTransferLastSecond = transferRate;
}
if (!isWorkingAllowed) {
setSituation(DISABLED_BY_CONTROLLER);
}
}

protected int doTransferFluids(int transferLimit) {
Expand All @@ -139,7 +142,8 @@ protected int doTransferFluids(int transferLimit) {
return 0;
}
else if (fluidHandler == null) {
setSituation(IDLE);
if (pumpMode == PumpMode.IMPORT) setSituation(NO_IMPORT_TANK);
if (pumpMode == PumpMode.EXPORT) setSituation(NO_EXPORT_TANK);
return 0;
}
return doTransferFluidsInternal(myFluidHandler, fluidHandler, transferLimit);
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,18 @@ cover.machine_controller.mode.cover_east=Control Cover (East)
cover.machine_controller.mode.cover_west=Control Cover (West)

gregtech.situation.idle=Idling
gregtech.situation.disabled_by_controller=Disabled by controller cover
gregtech.situation.working=Working
gregtech.situation.null_capability=Error accessing inventory from this side
gregtech.situation.empty_source=This inventory is empty
gregtech.situation.insufficient_power=Not enough power to run this recipe
gregtech.situation.no_matching_recipe=No recipe found
gregtech.situation.target_inventory_full=The target inventory is full
gregtech.situation.output_inventory_full=Output is full
gregtech.situation.no_import_inventory=Cant access inventory to import from
gregtech.situation.no_export_inventory=Cant access inventory to export to
gregtech.situation.no_import_tank=Cant access tank to import from
gregtech.situation.no_export_tank=Cant access tank to export to


# %s is a localized material name
Expand Down

0 comments on commit 60a2b47

Please sign in to comment.