2424import com .lowdragmc .lowdraglib .syncdata .field .ManagedFieldHolder ;
2525
2626import net .minecraft .ChatFormatting ;
27+ import net .minecraft .core .BlockPos ;
2728import net .minecraft .network .chat .Component ;
2829import net .minecraft .network .chat .Style ;
2930import net .minecraft .resources .ResourceLocation ;
@@ -62,6 +63,11 @@ public class DroneMaintenanceInterfacePartMachine extends TieredPartMachine
6263 @ Getter
6364 private DroneStationConnection connection ;
6465
66+ // Can't sync a DroneStationConnection so magic value it is
67+ // -1 = no connection, otherwise it's the Long packed BPos
68+ @ DescSynced
69+ private long syncedConnectionPos ;
70+
6571 public DroneMaintenanceInterfacePartMachine (IMachineBlockEntity holder ) {
6672 super (holder , GTValues .HV );
6773 DUMMY_CLEANROOM = DummyCleanroom .createForTypes (Collections .singletonList (CleanroomType .CLEANROOM ));
@@ -116,6 +122,7 @@ public void update() {
116122 // Fix maintenance problems every second
117123 if (getOffsetTimer () % 20 == 0 ) {
118124 if (hasConnection ()) {
125+ syncedConnectionPos = connection .droneStationPos .asLong ();
119126 updateCleanroomStyle ();
120127 if (hasMaintenanceProblems ()) {
121128 // See if we are allowed to fix maintenance issues + potentially consume a drone
@@ -124,6 +131,7 @@ public void update() {
124131 }
125132 }
126133 } else {
134+ syncedConnectionPos = -1 ;
127135 // Find a new connection every 10 seconds
128136 if (getOffsetTimer () % 200 == 0 ) {
129137 tryFindConnection ();
@@ -172,20 +180,19 @@ public void attachTooltips(TooltipsPanel tooltipsPanel) {
172180 super .attachTooltips (tooltipsPanel );
173181 tooltipsPanel .attachTooltips (new IFancyTooltip .Basic (
174182 () -> GuiTextures .GREGTECH_LOGO ,
175- () -> List .of (Component .translatable ("gtceu.multiblock.drone_maintenance_interface.connection_location" ,
176- this .connection .droneStationPos .getX (),
177- this .connection .droneStationPos .getY (),
178- this .connection .droneStationPos .getZ ())
183+ () -> List .of (Component
184+ .translatable ("cosmiccore.multiblock.drone_maintenance_interface.connection_location" ,
185+ BlockPos .of (this .syncedConnectionPos ).getX (),
186+ BlockPos .of (this .syncedConnectionPos ).getY (),
187+ BlockPos .of (this .syncedConnectionPos ).getZ ())
179188 .setStyle (Style .EMPTY .withColor (ChatFormatting .GREEN ))),
180- (() -> !(this .connection == null || this .connection .droneStationPos != null ||
181- this .connection .droneStation != null )),
189+ () -> this .syncedConnectionPos != -1 ,
182190 () -> null ));
183191 tooltipsPanel .attachTooltips (new IFancyTooltip .Basic (
184192 () -> GuiTextures .GREGTECH_LOGO ,
185- () -> List .of (Component .translatable ("gtceu .multiblock.drone_maintenance_interface.no_connection" )
193+ () -> List .of (Component .translatable ("cosmiccore .multiblock.drone_maintenance_interface.no_connection" )
186194 .setStyle (Style .EMPTY .withColor (ChatFormatting .RED ))),
187- (() -> this .connection == null || this .connection .droneStationPos != null ||
188- this .connection .droneStation != null ),
195+ (() -> this .syncedConnectionPos == -1 ),
189196 () -> null ));
190197 }
191198
0 commit comments