Skip to content

Commit 5d0ff46

Browse files
committed
Let ICleanroomProviders have priorities and only set the cleanroom provider in RecipeMapMultiblockControllers if the priority is higher than the existing one.
1 parent 32c6d59 commit 5d0ff46

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/DummyCleanroom.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ public void setCleanAmount(int amount) {}
6464

6565
@Override
6666
public void adjustCleanAmount(int amount) {}
67+
68+
// Have a higher priority than the cleanroom multiblock (which doesn't override getPriority so it'll return 0)
69+
// doesn't replace the set cleanroom in multiblocks.
70+
@Override
71+
public int getPriority() {
72+
return 1;
73+
}
6774
}

src/main/java/gregtech/api/metatileentity/multiblock/ICleanroomProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,13 @@ public interface ICleanroomProvider {
4949
* @return the tier {@link gregtech.api.GTValues#V} of energy the cleanroom uses at minimum
5050
*/
5151
int getEnergyTier();
52+
53+
/**
54+
* Get the priority of this cleanroom provider to determine which should be used.
55+
*
56+
* @return the priority this cleanroom provider should have over other cleanrooms.
57+
*/
58+
default int getPriority() {
59+
return 0;
60+
}
5261
}

src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapMultiblockController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ public ICleanroomProvider getCleanroom() {
321321

322322
@Override
323323
public void setCleanroom(ICleanroomProvider provider) {
324-
this.cleanroom = provider;
324+
if (cleanroom == null || provider.getPriority() > cleanroom.getPriority()) {
325+
this.cleanroom = provider;
326+
}
325327
}
326328
}

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/MetaTileEntityCleaningMaintenanceHatch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
5252
@Override
5353
public void addToMultiBlock(MultiblockControllerBase controllerBase) {
5454
super.addToMultiBlock(controllerBase);
55-
if (controllerBase instanceof ICleanroomReceiver &&
56-
((ICleanroomReceiver) controllerBase).getCleanroom() == null) {
57-
((ICleanroomReceiver) controllerBase).setCleanroom(DUMMY_CLEANROOM);
55+
if (controllerBase instanceof ICleanroomReceiver cleanroomReceiver &&
56+
cleanroomReceiver.getCleanroom() == null) {
57+
cleanroomReceiver.setCleanroom(DUMMY_CLEANROOM);
5858
}
5959
}
6060

0 commit comments

Comments
 (0)