mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-27 17:52:56 +00:00
Allow multiple slices for ModifyConstant, closes #194
This commit is contained in:
1 parent
a290e810ca
commit
55777fcf42
4 files changed
+21
-4
No files matched your search
@@ -183,6 +183,15 @@ public @interface Constant {
|
||||
*/
|
||||
public int ordinal() default -1;
|
||||
|
||||
/**
|
||||
* This specifies the ID of the slice to use for this query.
|
||||
*
|
||||
* <p>For more details see the {@link Slice#id}</p>
|
||||
*
|
||||
* @return the slice identifier, or empty string to use the default slice
|
||||
*/
|
||||
public String slice() default "";
|
||||
|
||||
/**
|
||||
* Whilst most constants can be located in the compiled method with relative
|
||||
* ease, there exists a special case when a <tt>zero</tt> is used in a
|
||||
|
||||
@@ -69,12 +69,12 @@ public @interface ModifyConstant {
|
||||
public String[] method();
|
||||
|
||||
/**
|
||||
* A {@link Slice} annotation which describes the method bisection used in
|
||||
* locating target instructions for this modifier.
|
||||
* Array of {@link Slice} annotations which describe the method bisections
|
||||
* used in locating target instructions for this modifier.
|
||||
*
|
||||
* @return slice
|
||||
* @return slices
|
||||
*/
|
||||
public Slice slice() default @Slice;
|
||||
public Slice[] slice() default {};
|
||||
|
||||
/**
|
||||
* Discriminator for the constant(s) to match (injection points), if not
|
||||
|
||||
@@ -143,6 +143,8 @@ public class BeforeConstant extends InjectionPoint {
|
||||
private final boolean log;
|
||||
|
||||
public BeforeConstant(IMixinContext context, AnnotationNode node, String returnType) {
|
||||
super(Annotations.<String>getValue(node, "slice", ""), Selector.DEFAULT, null);
|
||||
|
||||
Boolean empty = Annotations.<Boolean>getValue(node, "nullValue", (Boolean)null);
|
||||
this.ordinal = Annotations.<Integer>getValue(node, "ordinal", Integer.valueOf(-1));
|
||||
this.nullValue = empty != null ? empty.booleanValue() : false;
|
||||
|
||||
+6
@@ -35,6 +35,7 @@ import org.spongepowered.asm.mixin.injection.invoke.ModifyConstantInjector;
|
||||
import org.spongepowered.asm.mixin.injection.points.BeforeConstant;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
@@ -78,4 +79,9 @@ public class ModifyConstantInjectionInfo extends InjectionInfo {
|
||||
return "Constant modifier method";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSliceId(String id) {
|
||||
return Strings.nullToEmpty(id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user