#event in item only runs certain command in function

1 messages · Page 1 of 1 (latest)

hybrid linden
#

OK so I have made a sorta sword sheath mechanic where if I sneak it replaces the sword in my hand with a Sheathed variant

And if I attack an entity with the Sheathed variant it swaps to the unsheathed variant
And it works fine......until I actually hit an entity

When I'm in creative mode and I hit a block, it works fine
But when I hit and entity, the sword doesn't swap to the unsheathed variant

I'm using /replaceitem to make it swap
It's super frustrating as I don't get why it works When I hit a block, but not an entity

Everything in the function works, apart for the replaceitem command which by the way is fine cuz it works When I hit a block and I've tested it

scoreboard players add @s[tag=samurai] m1_katana 1

playanimation @s[tag=samurai,scores={m1_katana=1}] animation.samurai.m1.katana1
playanimation @s[tag=samurai,scores={m1_katana=2}] animation.samurai.m1.katana2
playanimation @s[tag=samurai,scores={m1_katana=3}] animation.samurai.m1.katana3
playanimation @s[tag=samurai,scores={m1_katana=4}] animation.samurai.m1.katana4
playanimation @s[tag=samurai,scores={m1_katana=5}] animation.samurai.m1.katana5

replaceitem entity @s[hasitem={location=slot.weapon.mainhand,item=ronin:katana_sheathed,quantity=1}] slot.weapon.mainhand 0 ronin:katana_unsheathed 1

camerashake add @a[tag=samurai,r=2] 0.2 0.1
playsound sword.swing @s[tag=samurai]
particle ronin:slash ^^0.8^1

tellraw @s[tag=!samurai] {"rawtext":[{"text":"§cYou have no knowledge or Understanding on how to use this weapon. \nIt is irrelevant to you§f"}]}

#blessingfire
execute as @s[tag=blessing_fire2] at @s positioned ~~~ run playsound mob.blaze.shoot @a[r=10]

execute as @s[tag=blessing_fire2] at @s positioned ^^^ run particle ronin:blessing_fire_m1 ^^0.8^
#

God its a huge pain

turbid swallow
hybrid linden
turbid swallow
# hybrid linden

You can try triggering the use event using minecraft:weapon instead of on_use

#

Like this:

"swing": {
  "sequence": [
    {
      "condition": "query.is_on_ground",
      "run_command": {
        "command": [
          "function player/samurai/katana/attack2"
        ],
        "target": "holder"
      },
      "damage": {
        "type": "none",
        "amount": 1,
        "target": "self"
      }
    },
    {
      "condition": "!query.is_on_ground",
      "run_command": {
        "command": [
          "function player/samurai/katana/attack2"
        ],
        "target": "holder"
      },
      "damage": {
        "type": "none",
        "amount": 1,
        "target": "self"
      }
    },
    {
      "trigger": "use"
    }
  ]
}
hybrid linden
#

Ok I'll give it a try

hybrid linden
hybrid linden
turbid swallow
hybrid linden
#

Yh

hybrid linden
turbid swallow
#

If the function works, it is not the problem, as it is not possible to detect hits with commands. The problem seems to be where the event is activated, I could be wrong but maybe it's because the on_use component only detects if it is used in blocks.

turbid swallow
#

So when an entity is hit it also activates the event

turbid swallow
#

no

#

trigger is a string, similar to condition

turbid swallow
hybrid linden
#

OK thanks

#

Shouldn't it be "trigger": "swing"

hybrid linden
turbid swallow
#

no

#

The swing event will trigger the use event

hybrid linden
#

Bit lost but ok

hybrid linden
turbid swallow
#

I think you should try asking this in #1067535382285135923 , with scripts it will certainly be easier to do this

hybrid linden
#

Id rather keep searching tbh

#

@turbid swallow wait.....what about if I set the condition to only when the player has the Sheathed katana?

#

That should work right?

gray rivet
#

Sadly, things like this won't be possible without scripts soon as Mojang is pretty much getting rid of hcf

gray rivet
#

The experimental toggle with item events

hybrid linden
#

Wtf????

gray rivet
#

Yeah, I don't really like it either. I made a feedback post about it in the feedback discord, but it didn't get too much attention

#

So I guess we'll just have to deal with it

hybrid linden
#

So you're basically saying that I won't be able to make and item run a function in the future?

gray rivet
#

Not without scripts. And mojang doesn't seem to want to support backcompat with it either. I think there are a sizeable amount of people frustrated with mojang over it, but either not enough for them to change their mind or they just don't want to listen on this. From my understanding it's because of bugs in the system which I guess they would rather spend time working on other things rather than fix? It doesn't make too much sense to me

hybrid linden
#

Ffs

gray rivet
#

I hope that there's still a chance for then to change it. But if they do end up removing it, there are some pretty good tutorials on scripting on the Microsoft creator docs

hybrid linden
hybrid linden