TheGreyGhost / MinecraftByExample

Working sample code for the basic concepts in Minecraft and Forge.
Other
1.24k stars 187 forks source link

MBE runs in gradle runClient but not as standalone mod #37

Closed anielsen001 closed 6 years ago

anielsen001 commented 6 years ago

I'm new to modding, so this may be something stupid. I can clone and build MBE such that it will run using gradlew runClient just fine. If I copy the build/libs/minecraftbyexample-1.12.2a.jar and put it into my minecraft/mods directory then minecraft crashes with this error:


---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

Time: 3/26/18 5:19 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Minecraft By Example (minecraftbyexample)
Caused by: java.lang.NoSuchFieldError: ROCK
    at minecraftbyexample.mbe01_block_simple.BlockSimple.<init>(BlockSimple.java:28)
    at minecraftbyexample.mbe01_block_simple.StartupCommon.preInitCommon(StartupCommon.java:46)
    at minecraftbyexample.CommonProxy.preInit(CommonProxy.java:20)
    at minecraftbyexample.ClientOnlyProxy.preInit(ClientOnlyProxy.java:21)
    at minecraftbyexample.MinecraftByExample.preInit(MinecraftByExample.java:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:606)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:278)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:256)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:148)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:602)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:270)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:466)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:377)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
    Minecraft Version: 1.12.2
    Operating System: Linux (amd64) version 4.4.0-116-generic
    Java Version: 1.8.0_161, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 128660176 bytes (122 MB) / 281636864 bytes (268 MB) up to 1060372480 bytes (1011 MB)
    JVM Flags: 5 total; -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.42 Powered by Forge 14.23.2.2611 6 mods loaded, 6 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    | State | ID                 | Version      | Source                         | Signature                                |
    |:----- |:------------------ |:------------ |:------------------------------ |:---------------------------------------- |
    | UCH   | minecraft          | 1.12.2       | minecraft.jar                  | None                                     |
    | UCH   | mcp                | 9.42         | minecraft.jar                  | None                                     |
    | UCH   | FML                | 8.0.99.99    | forge-1.12.2-14.23.2.2611.jar  | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCH   | forge              | 14.23.2.2611 | forge-1.12.2-14.23.2.2611.jar  | e3c3d50c7c986df74c645c0ac54639741c90a557 |
    | UCH   | mercurius_updater  | 1.0          | MercuriusUpdater-1.12.2.jar    | None                                     |
    | UCE   | minecraftbyexample | 1.12.2a      | minecraftbyexample-1.12.2a.jar | None                                     |

    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'Intel Open Source Technology Center' Version: '3.0 Mesa 17.2.8' Renderer: 'Mesa DRI Intel(R) Haswell Mobile '

For reference, I verified the versions of the minecraft when I run using gradle:

Details:
        Minecraft Version: 1.12.2
        Operating System: Linux (amd64) version 4.4.0-116-generic
        Java Version: 1.8.0_161, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 235144128 bytes (224 MB) / 549453824 bytes (524 MB) up to 1808269312 bytes (1724 MB)
        JVM Flags: 0 total; 
        IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
        FML: 
        Loaded coremods (and transformers): 
        GL info: ' Vendor: 'Intel Open Source Technology Center' Version: '3.0 Mesa 17.2.8' Renderer: 'Mesa DRI Intel(R) Haswell Mobile '
[06:03:18] [main/INFO] [FML]: MinecraftForge v14.23.0.2491 Initialized
09jlardinois commented 6 years ago

Just had this issue with another mod.

Three things -

  1. Use './gradlew build' or './gradlew jar'.

They create compiled, obfuscated jar executables. Minecraft requires that it be obfuscated (is what I heard) and only those two commands do that.

  1. It looks like this mod requires another? Mercurius Updater?

Make sure that's included in your eclipse build path in,

Right click project > build path > configure build path > libraries > add external jar > choose the file.

  1. Make sure gradle knows to look for that file when building. You can configure it as a dependency or included file in build.gradle

I don't know how, but I know that bit.

anielsen001 commented 6 years ago

Thanks for your comments, the pointed me in the correct direction and I did solve the issue. After running ./gradlew build a jar file will be created in ./build/libs but this is not sufficient to run in a production Minecraft. You also have to run ./gradlew reobf before copying the jar file to the production minecraft/mods directory.

I don't use Eclipse or a traditional IDE, I just edit with emacs and build from the CLI, so the IDE configurations may take care of this transparently.

TheGreyGhost commented 6 years ago

Thanks guys :)