diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index b613c5d6b..a6855791f 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -40,5 +40,5 @@ dependencies { implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0' implementation group: 'commons-io', name: 'commons-io', version: '2.7' - implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.2.3' + implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.2.9' } \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle index c6c3d5c5c..6b97406fd 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -68,7 +68,7 @@ dependencies { processResources { inputs.property "version", project.version - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } } diff --git a/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java index 24e807f62..9f59a9adc 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java @@ -27,17 +27,37 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.world.entity.player.Abilities; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; + /** * @author Brady * @since 8/1/2018 */ @Mixin(LocalPlayer.class) public class MixinClientPlayerEntity { + @Unique + private static final MethodHandle MAY_FLY = baritone$resolveMayFly(); + + @Unique + private static MethodHandle baritone$resolveMayFly() { + try { + var lookup = MethodHandles.publicLookup(); + return lookup.findVirtual(LocalPlayer.class, "mayFly", MethodType.methodType(boolean.class)); + } catch (NoSuchMethodException e) { + return null; + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } @Inject( method = "tick", @@ -61,6 +81,7 @@ private void onPreUpdate(CallbackInfo ci) { target = "net/minecraft/world/entity/player/Abilities.mayfly:Z" ) ) + @Group(name = "mayFly", min = 1, max = 1) private boolean isAllowFlying(Abilities capabilities) { IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this); if (baritone == null) { @@ -69,6 +90,22 @@ private boolean isAllowFlying(Abilities capabilities) { return !baritone.getPathingBehavior().isPathing() && capabilities.mayfly; } + @Redirect( + method = "aiStep", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/player/LocalPlayer;mayFly()Z" + ) + ) + @Group(name = "mayFly", min = 1, max = 1) + private boolean onMayFlyNeoforge(LocalPlayer instance) throws Throwable { + IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this); + if (baritone == null) { + return (boolean) MAY_FLY.invokeExact(instance); + } + return !baritone.getPathingBehavior().isPathing() && (boolean) MAY_FLY.invokeExact(instance); + } + @Redirect( method = "aiStep", at = @At(