Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Fix memory leak by tesla, but problem still exists when using tesla c…
Browse files Browse the repository at this point in the history
…over. (#275)

* Fixed memory leak.
But leak still exists in tesla cover, because when chunk unloads, the TeslaCoverConnection object is not removed from the set.

* Fixed memory leak.
But leak still exists in tesla cover, because when chunk unloads, the TeslaCoverConnection object is not removed from the set.
  • Loading branch information
koiNoCirculation authored Mar 21, 2024
1 parent 5f3db97 commit 931c218
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.technus.tectech.thing.cover;

import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd;
import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove;
import static ic2.api.info.Info.DMG_ELECTRIC;

import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -30,6 +31,16 @@ public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID,
return super.doCoverThings(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer);
}

@Override
public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity,
boolean aForced) {
teslaSimpleNodeSetRemove(
new TeslaCoverConnection(
aTileEntity.getIGregTechTileEntityOffset(0, 0, 0),
getTeslaReceptionCapability()));
return super.onCoverRemoval(side, aCoverID, aCoverVariable, aTileEntity, aForced);
}

@Override
public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) {
return "Do not attempt to use screwdriver!"; // TODO Translation support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,13 @@ public void onRemoval() {
}
}

@Override
public void onUnload() {
if (!getBaseMetaTileEntity().isClientSide()) {
teslaSimpleNodeSetRemove(this);
}
}

@Override
protected void parametersInstantiation_EM() {
Parameters.Group hatch_0 = parametrization.getGroup(0, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ public void onRemoval() {
}
}

@Override
public void onUnload() {
if (!this.getBaseMetaTileEntity().isClientSide()) {
teslaSimpleNodeSetRemove(this);
}
}

@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
Expand Down

0 comments on commit 931c218

Please sign in to comment.