org.spongepowered.asm.mixin.gen.Invoker Java Examples
The following examples show how to use
org.spongepowered.asm.mixin.gen.Invoker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TargetValidator.java From Mixin with MIT License | 6 votes |
private void validateInterfaceMixin(TypeElement mixin, Collection<TypeHandle> targets) { boolean containsNonAccessorMethod = false; for (Element element : mixin.getEnclosedElements()) { if (element.getKind() == ElementKind.METHOD) { boolean isAccessor = AnnotationHandle.of(element, Accessor.class).exists(); boolean isInvoker = AnnotationHandle.of(element, Invoker.class).exists(); containsNonAccessorMethod |= (!isAccessor && !isInvoker); } } if (!containsNonAccessorMethod) { return; } for (TypeHandle target : targets) { TypeElement targetType = target.getElement(); if (targetType != null && !(targetType.getKind() == ElementKind.INTERFACE)) { this.error("Targetted type '" + target + " of " + mixin + " is not an interface", mixin); } } }
Example #2
Source File: MixinObfuscationProcessorTargets.java From Mixin with MIT License | 6 votes |
/** * Searches for {@link Invoker} annotations and registers them with their * parent mixins */ private void processInvokers(RoundEnvironment roundEnv) { for (Element elem : roundEnv.getElementsAnnotatedWith(Invoker.class)) { Element parent = elem.getEnclosingElement(); if (!(parent instanceof TypeElement)) { this.mixins.printMessage(Kind.ERROR, "Unexpected parent with type " + TypeUtils.getElementType(parent), elem); continue; } if (elem.getKind() == ElementKind.METHOD) { this.mixins.registerInvoker((TypeElement)parent, (ExecutableElement)elem); } else { this.mixins.printMessage(Kind.ERROR, "Element is not a method", elem); } } }
Example #3
Source File: AnnotatedMixins.java From Mixin with MIT License | 5 votes |
/** * Register an {@link org.spongepowered.asm.mixin.gen.Accessor} method * * @param mixinType Mixin class * @param method Accessor method */ public void registerInvoker(TypeElement mixinType, ExecutableElement method) { AnnotatedMixin mixinClass = this.getMixin(mixinType); if (mixinClass == null) { this.printMessage(Kind.ERROR, "Found @Accessor annotation on a non-mixin method", method); return; } AnnotationHandle invoker = AnnotationHandle.of(method, Invoker.class); mixinClass.registerInvoker(method, invoker, AnnotatedMixins.shouldRemap(mixinClass, invoker)); }
Example #4
Source File: ClassInfo.java From Mixin with MIT License | 5 votes |
@SuppressWarnings("unchecked") public Method(MethodNode method, boolean injected) { super(Type.METHOD, method.name, method.desc, method.access, injected); this.frames = this.gatherFrames(method); this.setUnique(Annotations.getVisible(method, Unique.class) != null); this.isAccessor = Annotations.getSingleVisible(method, Accessor.class, Invoker.class) != null; boolean decoratedFinal = Annotations.getVisible(method, Final.class) != null; boolean decoratedMutable = Annotations.getVisible(method, Mutable.class) != null; this.setDecoratedFinal(decoratedFinal, decoratedMutable); }
Example #5
Source File: MixinPostProcessor.java From Mixin with MIT License | 5 votes |
private boolean processAccessor(ClassNode classNode, MixinInfo mixin) { if (!MixinEnvironment.getCompatibilityLevel().supports(LanguageFeature.METHODS_IN_INTERFACES)) { return false; } boolean transformed = false; MixinClassNode mixinClassNode = mixin.getClassNode(0); ClassInfo targetClass = mixin.getTargets().get(0); for (MixinMethodNode methodNode : mixinClassNode.mixinMethods) { if (!Bytecode.hasFlag(methodNode, Opcodes.ACC_STATIC)) { continue; } AnnotationNode accessor = methodNode.getVisibleAnnotation(Accessor.class); AnnotationNode invoker = methodNode.getVisibleAnnotation(Invoker.class); if (accessor != null || invoker != null) { Method method = this.getAccessorMethod(mixin, methodNode, targetClass); MixinPostProcessor.createProxy(methodNode, targetClass, method); Annotations.setVisible(methodNode, MixinProxy.class, "sessionId", this.sessionId); classNode.methods.add(methodNode); transformed = true; } } if (!transformed) { return false; } Bytecode.replace(mixinClassNode, classNode); return true; }
Example #6
Source File: FireBlockAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker int invokeGetSpreadChance(BlockState state);
Example #7
Source File: CustomPayloadS2CPacketAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("PublicStaticMixinMember") @Invoker("<init>") static CustomPayloadS2CPacket patchwork$create() { throw new AssertionError("Mixin not applied"); }
Example #8
Source File: FireBlockAccessor.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Invoker void callRegisterFlammableBlock(Block block, int burnChance, int spreadChance);
Example #9
Source File: SpawnRestrictionInvoker.java From the-hallow with MIT License | 4 votes |
@Invoker public static <T extends MobEntity> void invokeRegister(EntityType<T> type, SpawnRestriction.Location location, Heightmap.Type heightmapType, SpawnRestriction.SpawnPredicate<T> restriction) { throw new UnsupportedOperationException(); }
Example #10
Source File: MixinRecipeBookWidget.java From multiconnect with MIT License | 4 votes |
@Invoker("isWide") @Override public abstract boolean multiconnect_isWide();
Example #11
Source File: UpgradeDataAccessor.java From multiconnect with MIT License | 4 votes |
@Invoker static BlockState callApplyAdjacentBlock(BlockState oldState, Direction dir, WorldAccess world, BlockPos currentPos, BlockPos otherPos) { return MixinHelper.fakeInstance(); }
Example #12
Source File: CrackParticleAccessor.java From multiconnect with MIT License | 4 votes |
@Invoker("<init>") static CrackParticle constructor(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, ItemStack stack) { return MixinHelper.fakeInstance(); }
Example #13
Source File: SuspendParticleAccessor.java From multiconnect with MIT License | 4 votes |
@Invoker("<init>") static SuspendParticle constructor(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { return MixinHelper.fakeInstance(); }
Example #14
Source File: MinecraftClientAccessor.java From multiconnect with MIT License | 4 votes |
@Invoker void callInitializeSearchableContainers();
Example #15
Source File: AccessorBiomeLayers.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("stack") static <T extends LayerSampler, C extends LayerSampleContext<T>> LayerFactory<T> patchwork$stack(long seed, ParentedLayer layer, LayerFactory<T> parent, int count, LongFunction<C> contextProvider) { throw new RuntimeException("Failed to create invoker: BiomeLayers#stack!"); }
Example #16
Source File: LoginQueryResponseC2SPacketAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("PublicStaticMixinMember") @Invoker("<init>") static LoginQueryResponseC2SPacket patchwork$create() { throw new AssertionError("Mixin not applied"); }
Example #17
Source File: CustomPayloadC2SPacketAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("PublicStaticMixinMember") @Invoker("<init>") static CustomPayloadC2SPacket patchwork$create() { throw new AssertionError("Mixin not applied"); }
Example #18
Source File: EntityAttributeInstanceAccessor.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Invoker void callAddModifier(EntityAttributeModifier modifier);
Example #19
Source File: StructurePoolProjectionAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static StructurePool.Projection invokeConstructor(String name, int ordinal, String id, ImmutableList<StructureProcessor> processors) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #20
Source File: BannerPatternAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static BannerPattern invokeConstructor(String constantName, int ordinal, String name, String id, ItemStack baseStack) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #21
Source File: BannerPatternAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static BannerPattern invokeConstructor(String constantName, int ordinal, String name, String id, String recipePattern0, String recipePattern1, String recipePattern2) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #22
Source File: EntityCategoryAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static EntityCategory invokeConstructor(String constantName, int index, String name, int spawnCap, boolean peaceful, boolean animal) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #23
Source File: SpawnRestrictionLocationAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static SpawnRestriction.Location invokeConstructor(String name, int ordinal) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #24
Source File: RarityAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static Rarity invokeConstructor(String name, int ordinal, Formatting formatting) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #25
Source File: OreFeatureConfigTargetAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Invoker("<init>") static OreFeatureConfig.Target invokeConstructor(String constantName, int ordinal, String name, Predicate<BlockState> predicate) { throw new IllegalStateException("Mixin did not transform accessor! Something is very wrong!"); }
Example #26
Source File: PointOfInterest_scarpetMixin.java From fabric-carpet with MIT License | 4 votes |
@Invoker boolean callReserveTicket();
Example #27
Source File: IMixinViewFrustum.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Invoker RenderChunk invokeGetRenderChunk(BlockPos pos);
Example #28
Source File: IMixinCompiledChunk.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Invoker void invokeSetLayerUsed(BlockRenderLayer layer);
Example #29
Source File: IMixinNBTBase.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Invoker("write") void invokeWrite(DataOutput output) throws IOException;
Example #30
Source File: MixinApplicatorStandard.java From Mixin with MIT License | 4 votes |
/** * Check whether this method was already merged into the target, returns * false if the method was <b>not</b> already merged or if the incoming * method has a higher priority than the already merged method. * * @param mixin Mixin context * @param method Method being merged * @param isOverwrite True if the incoming method is tagged with Override * @param target target method being checked * @return true if the target was already merged and should be skipped */ @SuppressWarnings("unchecked") protected boolean isAlreadyMerged(MixinTargetContext mixin, MethodNode method, boolean isOverwrite, MethodNode target) { AnnotationNode merged = Annotations.getVisible(target, MixinMerged.class); if (merged == null) { if (Annotations.getVisible(target, Final.class) != null) { this.logger.warn("Overwrite prohibited for @Final method {} in {}. Skipping method.", method.name, mixin); return true; } return false; } String sessionId = Annotations.<String>getValue(merged, "sessionId"); if (!this.context.getSessionId().equals(sessionId)) { throw new ClassFormatError("Invalid @MixinMerged annotation found in" + mixin + " at " + method.name + " in " + this.targetClass.name); } if (Bytecode.hasFlag(target, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE) && Bytecode.hasFlag(method, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE)) { if (mixin.getEnvironment().getOption(Option.DEBUG_VERBOSE)) { this.logger.warn("Synthetic bridge method clash for {} in {}", method.name, mixin); } return true; } String owner = Annotations.<String>getValue(merged, "mixin"); int priority = Annotations.<Integer>getValue(merged, "priority"); AnnotationNode accMethod = Annotations.getSingleVisible(method, Accessor.class, Invoker.class); if (accMethod != null) { AnnotationNode accTarget = Annotations.getSingleVisible(target, Accessor.class, Invoker.class); if (accTarget != null) { String myTarget = Annotations.<String>getValue(accMethod, "target"); String trTarget = Annotations.<String>getValue(accTarget, "target"); if (myTarget == null) { throw new MixinError("Encountered undecorated Accessor method in " + mixin + " applying to " + this.targetName); } if (myTarget.equals(trTarget)) { // This is fine, the accessors overlap return true; } throw new InvalidMixinException(mixin, String.format("Incompatible @%s %s (for %s) in %s previously written by %s (for %s)", Bytecode.getSimpleName(accMethod), method.name, myTarget, mixin, owner, trTarget)); } } if (priority >= mixin.getPriority() && !owner.equals(mixin.getClassName())) { this.logger.warn("Method overwrite conflict for {} in {}, previously written by {}. Skipping method.", method.name, mixin, owner); return true; } if (Annotations.getVisible(target, Final.class) != null) { this.logger.warn("Method overwrite conflict for @Final method {} in {} declared by {}. Skipping method.", method.name, mixin, owner); return true; } return false; }