Skip to content

ClassNotFoundException when calling a custom event via mixin #3

Description

@Vekhove

With my own custom event:

    public static class ExampleEvent implements IEvent<Void> {
        private final String string;

        public ExampleEvent(String string) {
            this.string = string;
        }

        public String getString() {
            return this.string;
        }
    }

and the mixin:

@Mixin(Player.class)
public final class PlayerMixin {

    @Inject(
            method = "notifyPickupItem",
            at = @At("HEAD")
    )
    public void mixintests_injectNotifyPickupItem(Ref<EntityStore> ref, ItemStack itemStack, Vector3d position, ComponentAccessor<EntityStore> componentAccessor, CallbackInfo ci) {
        System.out.println("Picked up!");

        IEventDispatcher<EventTests.ExampleEvent, EventTests.ExampleEvent> dispatcher = HytaleServer.get().getEventBus().dispatchFor(EventTests.ExampleEvent.class);
        dispatcher.dispatch(new EventTests.ExampleEvent("From Mixin Pickup!"));
    }

}

causes the error:

org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered
	at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:381)
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:237)
	at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClassBytes(MixinTransformer.java:202)
	at com.build_9.hyxin.HyxinTransformer.transform(HyxinTransformer.java:81)
	at com.hypixel.hytale.plugin.early.TransformingClassLoader.transformAndDefine(TransformingClassLoader.java:97)
	at com.hypixel.hytale.plugin.early.TransformingClassLoader.loadClass(TransformingClassLoader.java:80)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
	at com.hypixel.hytale.server.core.modules.entity.EntityModule.setup(EntityModule.java:343)
	at com.hypixel.hytale.server.core.plugin.PluginBase.setup0(PluginBase.java:389)
	at com.hypixel.hytale.server.core.plugin.PluginManager.setup(PluginManager.java:757)
	at com.hypixel.hytale.server.core.plugin.PluginManager.setup(PluginManager.java:236)
	at com.hypixel.hytale.server.core.HytaleServer.boot(HytaleServer.java:326)
	at com.hypixel.hytale.server.core.HytaleServer.<init>(HytaleServer.java:284)
	at com.hypixel.hytale.LateMain.lateMain(LateMain.java:54)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at com.hypixel.hytale.Main.launchWithTransformingClassLoader(Main.java:64)
	at com.hypixel.hytale.Main.main(Main.java:40)
Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinPreProcessorException: Attach error for mixintests.mixins.json:PlayerMixin from mod (unknown) during activity: [Transform -> Method mixintests_injectNotifyPickupItem(Lcom/hypixel/hytale/component/Ref;Lcom/hypixel/hytale/server/core/inventory/ItemStack;Lcom/hypixel/hytale/math/vector/Vector3d;Lcom/hypixel/hytale/component/ComponentAccessor;Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfo;)V -> INVOKESPECIAL -> me/lilac/eventtests/EventTests$ExampleEvent::<init>:(Ljava/lang/String;)V]
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:313)
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:277)
	at org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1292)
	at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:203)
	at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:437)
	at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:418)
	at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:352)
	... 17 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: me.lilac.eventtests.EventTests$ExampleEvent
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMemberReference(MixinPreProcessorStandard.java:791)
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:777)
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:743)
	at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:307)
	... 23 more
Caused by: java.lang.ClassNotFoundException: me.lilac.eventtests.EventTests$ExampleEvent
	... 27 more

Calling a vanilla event the same way does not cause an error.
Calling the event the same way elsewhere, like in a command, works as expected.

This may be something I am doing wrong or something not possible, but any help or info would be great!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions