diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index a2114ab37..122271b45 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -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) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index d1d937fc8..f79ab3316 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -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; @@ -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; } @@ -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); - } }