From 358d65a8cc123c344a39597433611fea058d53b5 Mon Sep 17 00:00:00 2001 From: bakerjaid Date: Mon, 18 Mar 2024 15:48:07 +1300 Subject: [PATCH] Fix wireless chargers --- .../xmod/gregtech/common/helpers/ChargingHelper.java | 11 ++++++----- .../machines/basic/GregtechMetaWirelessCharger.java | 12 +----------- 2 files changed, 7 insertions(+), 16 deletions(-) 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 a2114ab375..122271b459 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 d1d937fc82..f79ab33162 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); - } }