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

Commit

Permalink
Fix wireless chargers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonodonozym committed Mar 18, 2024
1 parent 4552944 commit 358d65a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ public void onPlayerTick(LivingUpdateEvent event) {
}
}

public static GregtechMetaWirelessCharger getEntry(BlockPos mPos) {
return mChargerMap.get(mPos);
}

public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) {
if (mEntity == null) {
return false;
}
if (!mChargerMap.containsKey(mPos)) {
return mChargerMap.put(mPos, mEntity) == null;
} else {
return true;
}
mChargerMap.put(mPos, mEntity);
return true;
}

public static boolean removeEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity {

private boolean mHasBeenMapped = false;
private int mCurrentDimension = 0;
public int mMode = 0;
public boolean mLocked = true;
Expand Down Expand Up @@ -471,6 +470,7 @@ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long
this.mCurrentDimension = aBaseMetaTileEntity.getWorld().provider.dimensionId;
}

boolean mHasBeenMapped = this.equals(ChargingHelper.getEntry(getTileEntityPosition()));
if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)) {
mHasBeenMapped = true;
}
Expand Down Expand Up @@ -655,14 +655,4 @@ public void doExplosion(long aExplosionPower) {
ChargingHelper.removeEntry(getTileEntityPosition(), this);
super.doExplosion(aExplosionPower);
}

@Override
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)) {
mHasBeenMapped = true;
}
}
super.onPreTick(aBaseMetaTileEntity, aTick);
}
}

0 comments on commit 358d65a

Please sign in to comment.