fix neoforge and forge for 1.20.4
cherry picked, squashed and adapted from commits74d82f2339and81f7375591
This commit is contained in:
@@ -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.1.0'
|
||||
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '1.2.9'
|
||||
}
|
||||
@@ -27,17 +27,37 @@ import net.minecraft.client.KeyMapping;
|
||||
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 @@ public class MixinClientPlayerEntity {
|
||||
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 @@ public class MixinClientPlayerEntity {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user