meteor-client icon indicating copy to clipboard operation
meteor-client copied to clipboard

Player null check lost.

Open class310 opened this issue 3 months ago • 5 comments

Steps to reproduce

When I'm playing a creative server, I open the creative inventory. When the mouse cursor hovers over an item, game crashed.

The crash report error line:

java.lang.NullPointerException: Cannot invoke "net.minecraft.client.player.LocalPlayer.getMainHandItem()" because "meteordevelopment.meteorclient.MeteorClient.mc.player" is null at knot//meteordevelopment.meteorclient.utils.player.InvUtils.testInMainHand(InvUtils.java:42) at knot//meteordevelopment.meteorclient.utils.player.InvUtils.testInHands(InvUtils.java:58) at knot//meteordevelopment.meteorclient.systems.modules.player.AirPlace.onTick(AirPlace.java:88) at knot//meteordevelopment.orbit.listeners.LambdaListener.call(LambdaListener.java:83) at knot//meteordevelopment.orbit.EventBus.post(EventBus.java:53)

How to fix Just add a

if (mc.player == null || mc.level == null) 
    return (for bool return:false, for void return: empty, for int return:-1/0);

Link to crash report/log (upload to https://mclo.gs and paste resulting link here)

Upper

Meteor Version

26.1.2-41

Minecraft Version

26.1.2

Operating System

Windows

Before submitting a crash report

  • [x] This crash wasn't already reported (I have searched crash reports on GitHub).

  • [x] This is a valid crash (I am able to reproduce this on the latest dev build).

class310 avatar Aug 24 '26 05:08 class310

crash-2026-08-24_12.33.05-client.txt Crash report file

class310 avatar Aug 24 '26 05:08 class310

i has met this bug since 1.20.4 & 1.21.8 build, and still not fixed in 26.1.2 build (decompiled from 26.1.2-41 build) Image Image Image

class310 avatar Aug 24 '26 05:08 class310

For example: In AirPlace.java Original:

    @EventHandler
    private void onTick(TickEvent.Pre event) {
        if (InvUtils.testInHands((Predicate<ItemStack>) this::placeable)) {
            if (this.f112mc.hitResult == null || this.f112mc.hitResult.getType() == HitResult.Type.MISS) {
                double r = this.customRange.get().booleanValue() ? this.range.get().doubleValue() : this.f112mc.player.blockInteractionRange();
                this.hitResult = this.f112mc.getCameraEntity().pick(r, 0.0f, false);
            }
        }
    }

Fixed

    @EventHandler
    private void onTick(TickEvent.Pre event) {

        if (this.f112mc.player == null || this.f112mc.level == null) return; // fix

        if (InvUtils.testInHands((Predicate<ItemStack>) this::placeable)) {
            if (this.f112mc.hitResult == null || this.f112mc.hitResult.getType() == HitResult.Type.MISS) {
                double r = this.customRange.get().booleanValue() ? this.range.get().doubleValue() : this.f112mc.player.blockInteractionRange();
                this.hitResult = this.f112mc.getCameraEntity().pick(r, 0.0f, false);
            }
        }
    }

class310 avatar Aug 24 '26 05:08 class310

For fix mod author:

Inject null check to utils and modules onTick() function

For addon author:

Remember to add check to your modules onTick() and other places that uses Minecraft player and level!

class310 avatar Aug 24 '26 05:08 class310

I cant reproduce it using the current 26.3 build. You are using a huge list of mods, which may cause some sort of incompatibility.

Gingerbeard5773 avatar Nov 13 '26 19:11 Gingerbeard5773