DragonsPlusMinecraft / origins-classes-forge

A unofficial Forge port for Origin: Classes
MIT License
7 stars 8 forks source link

Action on hit/ action when hit Power type Crash #13

Closed aziel13 closed 2 years ago

aziel13 commented 2 years ago

When creating a custom class datapack I found that minecraft crashes if you have a class with a power that uses the origins:action_when_hit or origins:action_when_hit power type when origins-classes-forge is installed.

When you attack or are attacked the game locks up and soon after crashes with the attached report.

This crash does not seem to occur if you put the before mentioned power types in an origin datapack for the origin forge port without the origins classes mod installed It also does appear to be specific to the forge port, as when I tested the same datapack in the 1.18.2 fabric version, it did not crash.

versions minecraft 1.18.2 Forge 40.1.11
Origins-Forge Origins-1.18.2-1.5.0.0-unified.jar origins-classes-forge origins-classes-forge-1.1.4.2.jar Caelus API (Forge) caelus-forge-1.18.1-3.0.0.2.jar

crash-2022-07-24_06.44.50-server.txt

RaymondBlaze commented 2 years ago

I didn't manage to recreate the crash with the following power:

{
        "type": "origins:action_when_hit",
        "bientity_action": {
        "type": "origins:add_velocity",
        "z": -2
    }
}

versions MC 1.18.2 Forge 40.1.14 Origins-Forge 1.18.2-1.5.0.0 Origins: Classes-Forge 1.18.2-1.1.5.1

Could you provide some more specific example for your power json?

RaymondBlaze commented 2 years ago

The crash report didn't provide any useful information, I suggest providing latest.log instead.

aziel13 commented 2 years ago

Since I removed the offending power I had to try your code, I am not sure why but that code does not cause the crash me anymore, even though I think it did earlier.

I however was able to subsequently restore the following code for the two power types I mentioned that still cause's the crash for me and isolate them into their own origin to ensure it was not an bad interaction with another of that class's powers:

`{ "type": "origins:multiple", "actiononhitcrash": { "type": "origins:action_on_hit", "bientity_action": { "type": "origins:damage", "amount": 4, "bypasses_armor":true, "magic": true, "unblockable": true, "source": { "name": "lightningBolt.player" } } }, "actionwhenhitcrash":{

       "type": "origins:action_when_hit",
    "bientity_action": {
        "type": "origins:damage",
        "amount": 2,
        "source": {
            "name": "thorns"
        }
    }

}

}`

I included the latest log directly after each action crashed bellow::

latest log from when hit crash

latest.log

latest log from on hit crash

latest.log

RaymondBlaze commented 2 years ago

Obviously your code is making infinite recursions :( Power origins:action_on_hit and origins:action_when_hit are only triggered by any damage that has an attacker, and origins:damage bientity action produces a damage that has an attacker, meaning that the damage from the action can trigger the power. In both of your power cases, you're attacking the attacked entity a second time, so it will trigger the power a second time and thus goes into infinite recursions. You should add some damage condition to prevent such recursion if you really need to write the power with such logic, but due to the presence of damage immune cooldown ticks, I don't think "extra attack on attack" is a good design as it can't actually duplicate the damage. Btw I don't know exactly why your stack trace is throwing java.lang.BootstrapMethodError instead of java.lang.StackOverFlowError just like mines.

aziel13 commented 2 years ago

I see but I was not aware that was even possible with the way origin provides its power types and action types to cause an infinite recursion that easily,

The code for the origins:action_when_hit code is actually the example they give for that action in the fabric wiki, but I think the reason they have that is this does not happen in the fabric version of origins.

I only really neede when_hit because it has the ability to take a non-damage condition, because origins:attacker_action_when_hit does not.. But I have since switched to that and use revoke and grant to prevent it from activating when I don't want it to be enabled. (i don't use toggle because I can't be specific as to if I am turning it on or off in one statement)

I am not sure why my stack trace is throwing that, but its possible odd errors are occurring because to test origins and origins classes by themselves I just disabled the rest of the mods in the pack I am using to build the class, rather than starting a manually modded copy of minecraft.

I think I was wrong in my earlier isolation to the class mod, as the the infinite recursion crash now seems to occur without it,

Should I close this and make a report with the Origin Forge mod instead?

RaymondBlaze commented 2 years ago

The code for the origins:action_when_hit code is actually the example they give for that action in the fabric wiki, but I think the reason they have that is this does not happen in the fabric version of origins.

No, I don't think so. I'm pretty sure the same code will crash on Fabric too, the examples in the docs aren't always tested and could be wrong. In that case you should go to Origins Docs' issue or directly suggest change in Origins' discord channel "wiki suggestions". I'm closing this as all problems are explained.