|
45 | 45 | import org.objectweb.asm.tree.AnnotationNode; |
46 | 46 | import org.objectweb.asm.tree.InsnList; |
47 | 47 | import org.objectweb.asm.tree.MethodNode; |
| 48 | +import org.spongepowered.asm.mixin.ModUtil; |
48 | 49 | import org.spongepowered.asm.mixin.MixinEnvironment; |
49 | 50 | import org.spongepowered.asm.mixin.MixinEnvironment.Option; |
50 | 51 | import org.spongepowered.asm.mixin.injection.callback.CallbackInjector; |
@@ -552,14 +553,20 @@ static final class Shift extends InjectionPoint { |
552 | 553 |
|
553 | 554 | private final InjectionPoint input; |
554 | 555 | private final int shift; |
| 556 | + private final boolean respectSpecifier; |
555 | 557 |
|
556 | 558 | public Shift(InjectionPoint input, int shift) { |
| 559 | + this(input, shift, ModUtil.COMPATIBILITY_LATEST); |
| 560 | + } |
| 561 | + |
| 562 | + public Shift(InjectionPoint input, int shift, int fabricCompatibility) { |
557 | 563 | if (input == null) { |
558 | 564 | throw new IllegalArgumentException("Must supply an input injection point for SHIFT"); |
559 | 565 | } |
560 | 566 |
|
561 | 567 | this.input = input; |
562 | 568 | this.shift = shift; |
| 569 | + this.respectSpecifier = fabricCompatibility >= ModUtil.COMPATIBILITY_0_16_5; |
563 | 570 | } |
564 | 571 |
|
565 | 572 | /* (non-Javadoc) |
@@ -606,6 +613,11 @@ public boolean find(String desc, InsnList insns, Collection<AbstractInsnNode> no |
606 | 613 |
|
607 | 614 | return nodes.size() > 0; |
608 | 615 | } |
| 616 | + |
| 617 | + @Override |
| 618 | + public Specifier getSpecifier(Specifier defaultSpecifier) { |
| 619 | + return this.respectSpecifier ? this.input.getSpecifier(defaultSpecifier) : super.getSpecifier(defaultSpecifier); |
| 620 | + } |
609 | 621 | } |
610 | 622 |
|
611 | 623 | /** |
@@ -871,15 +883,17 @@ private static InjectionPoint create(IMixinContext context, InjectionPointData d |
871 | 883 |
|
872 | 884 | private static InjectionPoint shift(IInjectionPointContext context, InjectionPoint point, |
873 | 885 | At.Shift shift, int by) { |
| 886 | + |
| 887 | + int fabricCompatibility = ModUtil.getCompatibility(context); |
874 | 888 |
|
875 | 889 | if (point != null) { |
876 | 890 | if (shift == At.Shift.BEFORE) { |
877 | | - return InjectionPoint.before(point); |
| 891 | + return new InjectionPoint.Shift(point, -1, fabricCompatibility); |
878 | 892 | } else if (shift == At.Shift.AFTER) { |
879 | | - return InjectionPoint.after(point); |
| 893 | + return new InjectionPoint.Shift(point, 1, fabricCompatibility); |
880 | 894 | } else if (shift == At.Shift.BY) { |
881 | 895 | InjectionPoint.validateByValue(context.getMixin(), context.getMethod(), context.getAnnotationNode(), point, by); |
882 | | - return InjectionPoint.shift(point, by); |
| 896 | + return new InjectionPoint.Shift(point, by, fabricCompatibility); |
883 | 897 | } |
884 | 898 | } |
885 | 899 |
|
|
0 commit comments