Compare commits

...
2 Commits
Author SHA1 Message Date
Martin Robertz 88725a144d update deps 2023-11-16 13:59:12 +01:00
Pelotrio 123f22f20e Add unload event handling to ClientNetworkManager (#137)
Added a new method `onWorldUnload` to `ClientNetworkManager` to destroy and clear any network instances when the world event `Unload` is triggered. The addition of this event handler was necessary to prevent the possibility of any network instances persisting on the client side beyond the World lifetime, thus potentially causing memory leaks.
2023-11-16 15:42:32 +03:00
2 changed files with 20 additions and 5 deletions

No files matched your search

+5 -5
View File
@@ -2,20 +2,20 @@
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.2.18:dev')
implementation('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
implementation('com.github.GTNewHorizons:ForestryMC:4.7.0:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.4.12-GTNH:dev')
implementation("com.github.GTNewHorizons:GTNHLib:0.0.13:dev")
api('com.github.GTNewHorizons:BuildCraft:7.1.36:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
compileOnly('com.github.GTNewHorizons:waila:1.6.2:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-280-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:waila:1.6.3:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-282-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.77:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.83:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.15.1:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.12.1-GTNH:api') {transitive = false}
implementation('com.github.GTNewHorizons:Chisel:2.12.0-GTNH:dev') {transitive = false}
implementation('com.github.GTNewHorizons:Chisel:2.12.2-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.19-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
@@ -4,13 +4,20 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.machine.capbank.TileCapBank;
public class ClientNetworkManager {
private static final ClientNetworkManager instance = new ClientNetworkManager();
static {
MinecraftForge.EVENT_BUS.register(instance);
}
public static ClientNetworkManager getInstance() {
return instance;
}
@@ -53,4 +60,12 @@ public class ClientNetworkManager {
CapBankClientNetwork network = getOrCreateNetwork(id);
network.addMember(tileCapBank);
}
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
if (event.world.isRemote) {
networks.forEach((id, network) -> network.destroyNetwork());
networks.clear();
}
}
}