Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • NoSuchMethodExceptions on world load
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
SirWindfield

NoSuchMethodExceptions on world load

By SirWindfield, May 10, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

SirWindfield    0

SirWindfield

SirWindfield    0

  • Tree Puncher
  • SirWindfield
  • Members
  • 0
  • 10 posts
Posted May 10, 2017

I am pretty new to modding so please keep that in mind :D

I want to disable all vanilla swords and tried it with the following code (basically just registering a custom event handler using MinecraftForge#EVENT_BUS):

@SubscribeEvent(priority = EventPriority.HIGHEST)
    public void onDamageTaken(LivingHurtEvent event) {
        // only consider any calculations if the source is the player itself
        Entity entity = event.getSource().getEntity();
        if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            // only look for the main hand
            ItemStack stack = player.getHeldItemMainhand();
            if (!ItemStackTools.isEmpty(stack)) {
                if (stack.getItem() instanceof ItemSword) {
                    event.setCanceled(true);
                }
            }
        }
    }

But for some odd reasons, as soon as I load into a world, I get a `java.lang.NoSuchMethodError: net.minecraft.util.DamageSource.getEntity()Lnet/minecraft/entity/Entity;`. To be honest, I have no idea what is going wrong here D:

If I run the code within eclipse by using the gradle runClient command all works fine. But if I build the jar using `gradle build` and add it to the mods folder, the game crashes on world load.

Here is the full stack trace: https://pastebin.com/3TrnL5NS

I have a general idea what is happening though. Not every entitiy has a damage source I guess. And it looks like the Bat is one of them. But how would I check for that too? 

I tried it early on with `event.getSource().getDamageType()` but that through the same exception on mobs added by oder mods.

 

Any help is appreciated,

Sir

  • Quote

Share this post


Link to post
Share on other sites

Abastro    123

Abastro

Abastro    123

  • World Shaper
  • Abastro
  • Forge Modder
  • 123
  • 1075 posts
Posted May 10, 2017

It seems that the part of the code is not obfuscated. Could you post your build.gradle file and the log from the gradle build command?

  • Quote

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Share this post


Link to post
Share on other sites

SirWindfield    0

SirWindfield

SirWindfield    0

  • Tree Puncher
  • SirWindfield
  • Members
  • 0
  • 10 posts
Posted May 10, 2017
buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
    }
}
repositories {
    maven { // JEI, McJtyLib and TOP
        url "http://modmaven.k-4u.nl/"
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.


version = "1.0.1"
group= "de.zerotask.minecraft.vanillatools" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "vanillatools"

sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
    sourceCompatibility = targetCompatibility = "1.8"
}

minecraft {
    version = "1.10.2-12.18.3.2281"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

dependencies {
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"
      
    // real examples
    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html
    deobfCompile "com.github.mcjty:compatlayer:1.10-0.2.8"

}

processResources
{
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
                
        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
        
    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

And here is my log file: https://pastebin.com/TJg8vhcj

  • Quote

Share this post


Link to post
Share on other sites

jeffryfisher    183

jeffryfisher

jeffryfisher    183

  • World Shaper
  • jeffryfisher
  • Members
  • 183
  • 1283 posts
Posted May 10, 2017

Rather than "gradle build", try gradlew build (run the script that came with the Forge installation). And, I don't know what Eclipse might be doing to gradle, but be safe by opening a command window and running the gradlew script from a command prompt.

  • Quote

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 38 minutes ago

      I dont think this has anything to do with the OS, but with maybe the way I installed java? I installed Ubuntu made for the raspberry pi 4 and the same message happened. im installing java with "sudo apt-get install default-jdk", So I tried again with "sudo apt-get install default-jre" and ended up reinstalling the jdk too, same thing happened.
    • CyberNation
      Forge 1.7.10 Server Failed to write Transciever Channels

      By CyberNation · Posted 50 minutes ago

      i made a custom 1.7.10 modpack for my friends and I to play on decided to move it over to my own server host and now im getting an error when starting ive spent several hours trying to look for a solution and cant seem to find one im not sure if im in the right place for this but i hope someone can help me     17:44:27 Can't revert to frozen GameData state without freezing first. Server thread/INFO 17:44:27 Applying holder lookups Holder lookups applied Server thread/WARN 17:44:27 Failed to write Transciever Channels on exit: java.util.concurrent.ExecutionException: java.lang.NullPointerException Server thread/INFO 17:44:27 The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded. The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded.     full Crash Log Report: Paste Bin https://pastebin.com/cxgY3t6q
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 1 hour ago

      Im wondering if changing the launch options for the main server jar will fix that? I saw some threads where some peoples launch files had "-o" as a launch option, is there a way I can change the launch options for when the vanilla server is launched?
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 1 hour ago

      When I run my forge Server it goes fine, but when I try to host off my Raspberry Pi 4 Model B 8GB RAM, using the 32-bit raspbian and 64-bit raspbian, I get this error at the end of log.   jpotsimple.UnrecognizedOptionException: o is not a recognized option     The full log file: https://pastebin.com/n4GpC53Q   Edit: This also happens when running the vanilla jar in the folder. This didn't happen with a vanilla installed from minecraft.net, so Im thinking that the jar file has that extra '-o' on it somewhere that causes this. vanilla log file: https://pastebin.com/pSq76TYp   Edit: running a fresh vanilla server produces the same thing
    • KBomb
      Forge 1.12.2 Server Crashing On Start-up

      By KBomb · Posted 1 hour ago

      I have been able to run the server in vanilla, but after adding the mods the server is crashing during the start-up. I will attach the crash report. I also have screenshots of what the server console was displaying if that may be necessary. crash-2021-02-24_18.58.56-server.txt
  • Topics

    • DrCowiber
      2
      Failed To Start Minecraft Server

      By DrCowiber
      Started 1 hour ago

    • CyberNation
      0
      Forge 1.7.10 Server Failed to write Transciever Channels

      By CyberNation
      Started 50 minutes ago

    • KBomb
      0
      Forge 1.12.2 Server Crashing On Start-up

      By KBomb
      Started 1 hour ago

    • milkman69
      0
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69
      Started 3 hours ago

    • Skyriis
      0
      [1.16.5] Adding a Button to KeyBindings

      By Skyriis
      Started 3 hours ago

  • Who's Online (See full list)

    • Zeher_Monkey
    • DrCowiber
    • jbko6
    • mcnuggies
    • _HungTeen_
    • LexManos
    • CyberNation
    • Jeldrik
    • William59
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • NoSuchMethodExceptions on world load
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community