Fix our fake player returning the wrong position and block position due to how forge handles things
@@ -7,9 +7,11 @@ import java.util.function.Function;
import javax.annotation.Nonnull;
import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
+import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.level.LevelAccessor;
+import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.FakePlayer;
/**
@@ -34,7 +36,7 @@ public class MekFakePlayer extends FakePlayer {
*/
private UUID emulatingUUID = null;
- public MekFakePlayer(ServerLevel world) {
+ private MekFakePlayer(ServerLevel world) {
super(world, new FakeGameProfile());
((FakeGameProfile) this.getGameProfile()).myFakePlayer = this;
}
@@ -54,6 +56,18 @@ public class MekFakePlayer extends FakePlayer {
return this.emulatingUUID != null ? this.emulatingUUID : super.getUUID();
}
+ @Override
+ public Vec3 position() {
+ //Provide the actual position that forge's fake player hides in this method
+ return new Vec3(getX(), getY(), getZ());
+ }
+
+ @Override
+ public BlockPos blockPosition() {
+ //Provide the actual block position that forge's fake player hides in this method
+ return new BlockPos(getBlockX(), getBlockY(), getBlockZ());
+ }
+
/**
* Acquire a Fake Player and call a function which makes use of the player. Afterwards, the Fake Player's world is nulled out to prevent GC issues. Emulated UUID is
* also reset.
