Fix #3002: Crash when IDSU energy storage is queried on the client

This commit is contained in:
Technici4n 2022-11-17 13:33:36 +01:00
parent c6f6b6f49c
commit 268de10661

View file

@ -38,6 +38,7 @@ import reborncore.common.screen.BuiltScreenHandlerProvider;
import reborncore.common.screen.builder.ScreenHandlerBuilder;
import team.reborn.energy.api.EnergyStorage;
import team.reborn.energy.api.base.DelegatingEnergyStorage;
import team.reborn.energy.api.base.SimpleEnergyStorage;
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
@ -60,7 +61,8 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
return EnergyStorage.EMPTY;
}
if (world.isClient) {
throw new UnsupportedOperationException("Energy API may only be queried on the server side.");
// Can't access the global storage, return a dummy. (Only for existence checks)
return new SimpleEnergyStorage(TechRebornConfig.idsuMaxEnergy, 0, 0);
}
EnergyStorage globalStorage = IDSUManager.getPlayer(world.getServer(), ownerUdid).getStorage();
return new DelegatingEnergyStorage(globalStorage, null) {