Merge pull request #4138 from rfresh2/fix-forge-1-20-1-crash

Fix forge 1.20.1 crash
This commit is contained in:
leijurv 2023-09-27 22:19:09 -07:00 committed by GitHub
commit e1e620a0d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -26,8 +26,6 @@ import baritone.behavior.LookBehavior;
import net.minecraft.client.KeyMapping; import net.minecraft.client.KeyMapping;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Abilities;
import net.minecraft.world.item.ElytraItem;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@ -112,14 +110,14 @@ public class MixinClientPlayerEntity {
method = "aiStep", method = "aiStep",
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
target = "net/minecraft/world/item/ElytraItem.isFlyEnabled(Lnet/minecraft/world/item/ItemStack;)Z" target = "Lnet/minecraft/client/player/LocalPlayer;tryToStartFallFlying()Z"
) )
) )
private boolean isFlyEnabled(ItemStack stack) { private boolean tryToStartFallFlying(final LocalPlayer instance) {
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this); IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer(instance);
if (baritone != null && baritone.getPathingBehavior().isPathing()) { if (baritone != null && baritone.getPathingBehavior().isPathing()) {
return false; return false;
} }
return ElytraItem.isFlyEnabled(stack); return instance.tryToStartFallFlying();
} }
} }