11package github .kasuminova .novaeng .common .tile ;
22
33import com .circulation .circulation_networks .api .EnergyAmount ;
4+ import com .circulation .circulation_networks .api .EnergyAmounts ;
45import com .circulation .circulation_networks .api .IEnergyHandler ;
56import com .circulation .circulation_networks .api .IMachineNodeBlockEntity ;
67import com .circulation .circulation_networks .api .node .IMachineNode ;
@@ -67,7 +68,7 @@ public TileMultiblockMachineController getCtrl() {
6768 return null ;
6869 }
6970 if (this .world .getTileEntity (ctrlPos ) instanceof TileMultiblockMachineController ctrl ) {
70- if (ctrl .getFoundMachine () != null && ctrl .getFoundMachine ().getRegistryName ().equals (DreamEnergyCore .REGISTRY_NAME )) {
71+ if (ctrl .getFoundMachine () != null && ctrl .getFoundMachine ().getRegistryName ().getPath (). equals (DreamEnergyCore .REGISTRY_NAME . getPath () )) {
7172 return ctrl ;
7273 }
7374 }
@@ -121,6 +122,10 @@ public final class DreamenergyHandler implements IEnergyHandler {
121122
122123 @ Override
123124 public IEnergyHandler init (TileEntity tileEntity , HubNode .HubMetadata hubMetadata ) {
125+ if (getCtrlStructureFormed ()) {
126+ canSend .init (DreamEnergyCore .getEnergyStoredString (getCtrl ()));
127+ init = SUCCEEDED ;
128+ } else init = FAILED ;
124129 return this ;
125130 }
126131
@@ -157,12 +162,14 @@ public EnergyAmount extractEnergy(EnergyAmount energyAmount, HubNode.HubMetadata
157162
158163 @ Override
159164 public EnergyAmount canExtractValue (HubNode .HubMetadata hubMetadata ) {
160- return EnergyAmount .obtain (canSend );
165+ if (init == SUCCEEDED ) return EnergyAmount .obtain (canSend );
166+ return EnergyAmounts .ZERO ;
161167 }
162168
163169 @ Override
164170 public EnergyAmount canReceiveValue (HubNode .HubMetadata hubMetadata ) {
165- return EnergyAmount .obtain (max );
171+ if (init == SUCCEEDED ) return EnergyAmount .obtain (max );
172+ return EnergyAmounts .ZERO ;
166173 }
167174
168175 @ Override
@@ -185,12 +192,6 @@ public void recycle() {
185192
186193 @ Override
187194 public EnergyType getType (HubNode .HubMetadata hubMetadata ) {
188- if (init == 0 ) {
189- if (getCtrlStructureFormed ()) {
190- canSend .init (DreamEnergyCore .getEnergyStoredString (getCtrl ()));
191- init = SUCCEEDED ;
192- } else init = FAILED ;
193- }
194195 if (init == SUCCEEDED ) {
195196 return EnergyType .STORAGE ;
196197 }
0 commit comments