Origins (Forge)

Origins (Forge)

7M Downloads

Crash when using action_when_hit or action_on_hit with damage action type

aziel13 opened this issue ยท 2 comments

commented

When creating a custom class datapack for the class origin mod, 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 using the "origins:damage" event type.

I originally through this was an issue with the origin classes mod but after making a report with them found it was still occurring without that mod installed.

The author of origin class's mod says that this is causing an infinite recursion and it would do the same in the fabric version.

But I have tested the same interaction a few times in the fabric version of origins, using code the fabric wiki provides(the when hit power is a wiki example) and it does not cause it to crash when you run the same origin in the fabric version.

So I thought I should bring up this issue with you directly,, as I think this specifically a forge port version issue.

The following to power examples cause an crash in the forge version of origins when are attacked by or you attack an entity.

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

The expected behavior for the preceding two powers as compared to fabrics version is

either you both die if the entity hits you or they die if you hit them first.

what happens in the forge version is the game hangs and then you crash.

Forge 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

Fabric version

minecraft 1.18.2
Fabric - 0.14.8
Origins-1.18.2-1.4.1.jar
Origins-Classes-1.18.2-1.3.0.jar

I have attached a recent crash log and the latest log for each power after testing the crash in forge.

I also included the latest logs for the same interactions in fabric , to show that I did not crash using the same crash testing Datapack .

Forge

when hit crash

crash log
crash-2022-07-25_12.22.31-server.txt

latest log
latest.log

on hit crash

crash log
crash-2022-07-25_12.16.48-server.txt

latest log
latest.log

Fabric
latest.log

commented

LimonBlaze is right that this is to be expected as that was my expectation too.
As a rule of thumb, designing powers this way is bad practice.

What you're effectively doing is "When I get hit, hit me again". Fabric uses a slightly different mechanic to handle that kind of powers which prevents any powers from triggering after the first pass, which means powers cannot trigger other powers.

While that is technically the behavior I'd need to replicate (and I'll probably add a config option somewhere to toggle between modes at some point), and while that behavior is obviously safer that the one I've implemented, I still find that counter intuitive. Also do note that, on fabric at least, dealing additional damage basically either negates the initial damage source, or part of the damage that was just dealt. This is a limitation of the vanilla game that cannot be bypassed.

The better way to do this is simply to modify damage taken by adding +100 using the modify_damage_taken power, or, if you need to deal additional damage after a hit, to have a condition that excludes the specific damage type you are dealing.

Also: I edited your comment to format json code with a ```json``` block, makes it easier to read.

commented

I only really wanted to make sure you were aware of this crash as I figured it would be better if the power and action combination didn't work at all then that it crashes the client.

And that is helpful, but I was actually trying to use something like the when hit code to make a custom thorns like power,

I just found when testing that the same crash occurred with on hit while I was trying to replace it with something similar.

(yeah, I struggled with getting that to work correctly )

Il leave it to you as to whether you keep this open for future reference or close it because you don't plan to act on it immediately.