#Detecting hit or punch on entity

44 messages · Page 1 of 1 (latest)

silent remnant
#

"minecraft:interact": {
"interactions": {
"on_interact": {
"event": "clicked"

Dumb question. What's the way to do it for hit/punch? Aka left click.

crisp lake
#

Your title being "extremely generic" is probably not going to help explain your issue.

quaint ruin
#

Also ditto on the question title and tags being bad. I will redo them for you

#

Detecting hit or punch on entity

silent remnant
#
            "minecraft:damage_sensor": {
                "interactions": {
                    "on_interact": {
                        "event": "rightclick"
                    }
                }
            }```
#

?

deft mango
#

Mm, that is to say you need to use a different component entirely, rather than just rename it. Thankfully the layouts are near identical, just with some keys renamed

silent remnant
#

Wait wdum

deft mango
#
"minecraft:damage_sensor": {
  "triggers": {
    "on_damage": {
      "event": "leftclick"
    }
  }
}
silent remnant
#

Did I mess up the commas?

deft mango
#

From what I can see, no

silent remnant
#

It's not working

#
{
    "format_version": "1.13.0",
    "minecraft:entity": {
        "description": {
            "identifier": "smp:npc3",
            "is_spawnable": false,
            "is_summonable": true,
            "is_experimental": false
        },
        "components": {
            "minecraft:type_family": {
                "family": [
                    "npc3"
                ]
            },
            "minecraft:collision_box": {
                "width": 0.6,
                "height": 1.9
            },
            "minecraft:health": {
                "value": 999999999,
                "max": 999999999
            },
            "minecraft:damage_sensor": {
                "triggers": [
                    {
                        "on_damage": {
                            "filters": {
                                "test": "is_family",
                                "subject": "other",
                                "value": "player"
                            },
                            "event": "leftclick"
                        },
                        "deals_damage": false
                    }
                ]
           },
            "minecraft:physics": {},
            "minecraft:nameable": {
                "always_show": true
            },
            "minecraft:pushable": {
                "is_pushable": false,
                "is_pushable_by_piston": false
            },
            "minecraft:knockback_resistance": {
                "value": 100,
                "max": 100
            },
            "minecraft:interact": {
                "interactions": {
                    "on_interact": {
                        "event": "rightclick"
                    }
                }
            },
            "minecraft:damage_sensor": {
                "triggers": {
                    "on_damage": {
                        "event": "leftclick"
                    }
                }
            }              
        },
        "events": {
            "leftclick": {
                "run_command": {
                    "target": "other",
                    "command": [
                        "tag @s add antittp29982848757823978487348385678929893479378",
                        "tp @s 0 92 0"
                    ]
                }
            },
            "rightclick": {
                "run_command": {
                    "target": "other",
                    "command": [
                        "tag @s add antittp29982848757823978487348385678929893479378",
                        "tp @s 0 92 0"
                    ]
                }
            }
        }
    }
}```
deft mango
#

Try updating the format version, it looks a bit old.

silent remnant
#

Right click works but not left.

deft mango
#

I'd do "1.19.0"

silent remnant
#

What's wrong with 1.13?

deft mango
#

It could be expecting some old syntax for damage sensors. What's wrong with updating it?

silent remnant
#

No I was just curious.

#

With the difference.

#

I'll try

silent remnant
#

Not registering the left click

deft mango
#

Maybe it needs a target explicitly set. Add "target": "self" to on_damage

silent remnant
#

Like this?

deft mango
#

Yeah, although with the typo removed

silent remnant
#

damn

#

my spelling 💀

silent remnant
silent remnant
#

wait!

#

What if I create a trigger?

#
            "minecraft:damage_sensor": {
                "triggers": [
                    {
                        "on_damage": {
                            "filters": {
                                "test": "is_family",
                                "subject": "other",
                                "value": "player"
                            },
                            "event": "leftclick"
                        },
                        "deals_damage": false
                    }
                ]
           },```
#

Something like this.

#

Nope didn't work either

#

So is left clicking not possible anymore?

#

nope that worked

#

weird lmfao