Skip to content

Commit 60a2b47

Browse files
add machine controller situation logic to covers and machines
add capability related situation logic to covers
1 parent b8325af commit 60a2b47

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/main/java/gregtech/api/Situations.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ public class Situations {
44
public static Situation WORKING = new Situation(0, "working", SituationsTypes.WORKING, "gregtech.situation.working");
55

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

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

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

1621
public enum SituationsTypes {
1722
WORKING,

src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ public void update() {
127127
metaTileEntity.setSituation(OUTPUT_INVENTORY_FULL);
128128
}
129129
}
130+
else {
131+
metaTileEntity.setSituation(DISABLED_BY_CONTROLLER);
132+
}
130133
}
131134
if (wasActiveAndNeedsUpdate) {
132135
this.wasActiveAndNeedsUpdate = false;

src/main/java/gregtech/common/covers/CoverConveyor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public void update() {
111111
return;
112112
}
113113
if (itemHandler == null) {
114-
setSituation(IDLE);
114+
if (conveyorMode == ConveyorMode.IMPORT) setSituation(NO_IMPORT_INVENTORY);
115+
if (conveyorMode == ConveyorMode.EXPORT) setSituation(NO_EXPORT_INVENTORY);
115116
return;
116117
}
117118
int totalTransferred = doTransferItems(itemHandler, myItemHandler, itemsLeftToTransferLastSecond);
@@ -125,6 +126,9 @@ public void update() {
125126
}
126127
this.itemsLeftToTransferLastSecond = transferRate;
127128
}
129+
if (!isWorkingAllowed) {
130+
setSituation(DISABLED_BY_CONTROLLER);
131+
}
128132
}
129133

130134
protected int doTransferItems(IItemHandler itemHandler, IItemHandler myItemHandler, int maxTransferAmount) {

src/main/java/gregtech/common/covers/CoverPump.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public void update() {
125125
}
126126
this.fluidLeftToTransferLastSecond = transferRate;
127127
}
128+
if (!isWorkingAllowed) {
129+
setSituation(DISABLED_BY_CONTROLLER);
130+
}
128131
}
129132

130133
protected int doTransferFluids(int transferLimit) {
@@ -139,7 +142,8 @@ protected int doTransferFluids(int transferLimit) {
139142
return 0;
140143
}
141144
else if (fluidHandler == null) {
142-
setSituation(IDLE);
145+
if (pumpMode == PumpMode.IMPORT) setSituation(NO_IMPORT_TANK);
146+
if (pumpMode == PumpMode.EXPORT) setSituation(NO_EXPORT_TANK);
143147
return 0;
144148
}
145149
return doTransferFluidsInternal(myFluidHandler, fluidHandler, transferLimit);

src/main/resources/assets/gregtech/lang/en_us.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,18 @@ cover.machine_controller.mode.cover_east=Control Cover (East)
740740
cover.machine_controller.mode.cover_west=Control Cover (West)
741741

742742
gregtech.situation.idle=Idling
743+
gregtech.situation.disabled_by_controller=Disabled by controller cover
743744
gregtech.situation.working=Working
744745
gregtech.situation.null_capability=Error accessing inventory from this side
745746
gregtech.situation.empty_source=This inventory is empty
746747
gregtech.situation.insufficient_power=Not enough power to run this recipe
747748
gregtech.situation.no_matching_recipe=No recipe found
748749
gregtech.situation.target_inventory_full=The target inventory is full
749750
gregtech.situation.output_inventory_full=Output is full
751+
gregtech.situation.no_import_inventory=Cant access inventory to import from
752+
gregtech.situation.no_export_inventory=Cant access inventory to export to
753+
gregtech.situation.no_import_tank=Cant access tank to import from
754+
gregtech.situation.no_export_tank=Cant access tank to export to
750755

751756

752757
# %s is a localized material name

0 commit comments

Comments
 (0)