Jump to content

Forge Events, Client side only


TheIncgi

Recommended Posts

This post is about version 1.12.2

I have a mod which is client side only, and I'm attempting to detect when certain things occur:

  • An item is picked up by the player
  • The inventory of a chest which was just opened
  • An item was tossed by the player
  • The player broke their tool/item
     

Currently I have forge events for:

  • PlayerEvent.ItemPickupEvent
  • PlayerDestroyItemEvent
  • ItemTossEvent
  • GuiOpenEvent


The first 3 all share the same issue.
They only fire for the server side.
The only I found exception being PlayerDestroyItemEvent when a flint and steel breaks from usage

It doesn't trigger when:

  • a shovel breaks
  • armor is destroyed
  • sheild is destroyed
  • a bow is broken
  • etc...

 

ItemTossed's only exception being when you open an inventory and drop the item by clicking outside the gui

It does not fire when the 'Drop Selected Item' key is fired (Default 'Q')

In the GuiOpenEvent I check if the gui is an instanceof GuiContainer and attempt to get its inventory.
The issue here is that the inventory isn't loaded at the time of the event.
I'm looking for a way to detect when it's done loading the data from the server packet (looks like SPacketWindowItems)

So it doesn't return an empty inventory.
Waiting an arbitrary amount of time works more or less depending on how long you wait. Trying to avoid that if possible.

Any help is appreciated
  Thanks in advanced
 -TheIncgi

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Use your IDE for this. For example, if you are using "IntelliJ IDEA" and you correctly setup your project (jdk, forge mdk, gradle, parchment, etc.), then you can just use Ctrl + B with Block type selected. It will navigate you to class declaration.
    • I need help, my forge server crashes and i don't know where is the problem.    [25sep2023 14:24:30.772] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.4, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:30.777] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_202 by Oracle Corporation [25sep2023 14:24:31.055] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [25sep2023 14:24:31.098] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/home/luka/.local/share/atlauncher/servers/Darksouls/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [25sep2023 14:24:32.824] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [com.performant.coremod.mixin.Connector] [25sep2023 14:24:32.835] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, ., /home/luka/.local/share/atlauncher/runtimes/minecraft/jre-legacy/linux/jre-legacy/bin/java nogui] [25sep2023 14:24:32.898] [main/INFO] [com.performant.coremod.Performant/]: Performant configs loaded [25sep2023 14:24:32.996] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER [25sep2023 14:24:32.997] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/GameRenderer (java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/GameRenderer for invalid dist DEDICATED_SERVER) [25sep2023 14:24:32.999] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.GameRenderer was not found shouldersurfing.mixins.json:MixinGameRenderer [25sep2023 14:24:33.011] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.011] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/GameSettings (java.lang.RuntimeException: Attempted to load class net/minecraft/client/GameSettings for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.012] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.GameSettings was not found shouldersurfing.mixins.json:MixinGameSettings [25sep2023 14:24:33.034] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER [25sep2023 14:24:33.035] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/gui/IngameGui (java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/IngameGui for invalid dist DEDICATED_SERVER) [25sep2023 14:24:33.035] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.gui.IngameGui was not found shouldersurfing.mixins.json:MixinIngameGui [25sep2023 14:24:33.128] [main/WARN] [mixin/]: Error loading class: net/optifine/shaders/ShadersRender (java.lang.ClassNotFoundException: null) [25sep2023 14:24:33.130] [main/WARN] [mixin/]: @Mixin target net.optifine.shaders.ShadersRender was not found shouldersurfing.mixins.json:MixinShadersRender [25sep2023 14:24:33.678] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.forge.BasicEventHooksMixin as config disables it. [25sep2023 14:24:33.706] [main/INFO] [com.performant.coremod.Performant/]: Not enabling mixin forcom.performant.coremod.mixin.entity.LivingEntityUpdateEventMixin as config disables it. [25sep2023 14:24:33.796] [main/WARN] [mixin/]: @Mixin target net/minecraft/world/server/ChunkManager$EntityTracker is public in performant.mixins.json:world.chunk.ChunkManagerEntityTrackMixin and should be specified in value [25sep2023 14:24:34.092] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER [25sep2023 14:24:34.092] [main/WARN] [mixin/]: Error loading class: com/teamderpy/shouldersurfing/config/Config$ClientConfig (java.lang.RuntimeException: Attempted to load class com/teamderpy/shouldersurfing/config/Config$ClientConfig for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.634] [main/FATAL] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER [25sep2023 14:24:35.634] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/Minecraft (java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid dist DEDICATED_SERVER) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [25sep2023 14:24:35.636] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [25sep2023 14:24:35.637] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [25sep2023 14:24:35.638] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [25sep2023 14:24:35.639] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 7 more [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]: Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) [25sep2023 14:24:35.640] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:223) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.mixin.transformer.MixinTransformationHandler.processClass(MixinTransformationHandler.java:121) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at org.spongepowered.asm.launch.MixinLaunchPlugin.processClass(MixinLaunchPlugin.java:131) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:154) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:85) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:265) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [25sep2023 14:24:35.641] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.block.Blocks.<clinit>(Blocks.java:30) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.SurfaceBuilder.<clinit>(SurfaceBuilder.java:12) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilders.<clinit>(SourceFile:11) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243674_g(WorldGenRegistries.java:33) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.func_243668_a(WorldGenRegistries.java:89) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) [25sep2023 14:24:35.642] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.WorldGenRegistries.<clinit>(WorldGenRegistries.java:88) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Registry.<clinit>(Registry.java:464) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.util.registry.Bootstrap.func_151354_b(Bootstrap.java:38) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     at net.minecraft.server.Main.main(Main.java:92) [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:643]:     ... 13 more [25sep2023 14:24:35.643] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]: Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: net.minecraft.client.Minecraft [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:741) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:726) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:297) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:267) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1271) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:287) [25sep2023 14:24:35.644] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:345) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:569) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:351) [25sep2023 14:24:35.645] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:667]:     ... 33 more
    • How can I see the Minecraft Blocks source code?
    • I have installed a minecraft 1.12.2 server and java 8, but the forge-blahblahblah.jar file isnt doing anything, the minecraft server file is opening the server but as expacted, it just launches a vanilla server
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.