#Delay loyalty + delete armor stand if enchanted trident is no longer there

1 messages · Page 1 of 1 (latest)

delicate quarry
#

This seems too confusing but ill send my code and it will make sense

delicate quarry
#

The main enchantment summons an armor stand upon hitting a block by running this function below

runes:enchantment/summon_armor_stand:

execute at @s run summon minecraft:armor_stand ~ ~ ~ {Invisible:true,Marker:true,equipment:{chest:{id:"minecraft:chainmail_chestplate",components:{"minecraft:enchantments":{"runes:internal/absorption":1},"minecraft:equippable":{slot:"chest",asset_id:"runes:does_not_exist"}}}}}
#

runes:internal/absorption

"effects": {
    "minecraft:tick": [
      {
        "effect": {
          "type": "minecraft:all_of",
          "effects": [
            {
              "type": "minecraft:explode",
              "block_interaction": "none",
              "knockback_multiplier": -0.25,
              "large_particle": {
                "type": "minecraft:block",
                "block_state": "minecraft:air"
              },
              "radius": 5,
              "small_particle": {
                "type": "minecraft:block",
                "block_state": "minecraft:air"
              },
              "sound": "minecraft:intentionally_empty"
            },
            {
              "type": "minecraft:run_function",
              "function": "runes:enchantment/absorption/score_add"
            }
          ]
        }
      },
      {
        "requirements": {
          "condition": "minecraft:entity_scores",
          "entity": "this",
          "scores": {
            "runes.absorption_explosion": 0
          }
        },
        "effect": {
          "type": "minecraft:all_of",
          "effects": [
            {
              "type": "minecraft:run_function",
              "function": "runes:enchantment/absorption/after_pulling"
            },
            {
              "type": "minecraft:run_function",
              "function": "runes:enchantment/absorption/kill_armor_stand"
            }
          ]
        }
      }
    ]
  }```
`score_add.mcfunction`
```hs
execute if entity @s[tag=runes.armor_stand] run return fail
tag @s add runes.armor_stand
scoreboard players add @s runes.absorption_explosion 100
#

after_pulling has some tests, this is not relevant at all because its just what happens after pulling the entities

#

oh and i forgot to mention, a tick function removes 1 from the explosion score so it works like a cooldown to the after_pulling

karmic bronze
#

the only way to delay loyalty would be to somehow modify the trident entity that is returning. Loyalty is a hardcoded enchantment.

As for the armor stand, you could simply test if there exists any trident within a distance of it and if not run kill.

execute as @e[tag=something,type=armor_stand] unless entity @e[distance=..1,type=trident] run kill @s for example

delicate quarry
#

i know how deleting loyalty would work but not how to implement

#

i need to store its level, remove it, and after/in the after_pulling return it

#

but idk when to implement the first two things

karmic bronze
#

ah okay so you want to remove the enchantment somehow so it never starts pulling back at all?

#

I would instead modify the enchantment itself

delicate quarry
#

hmmm i dont get wdym

#

but what i want is to delay the loyalty

#

to delay it i must remove and return it after

#

(delay loyalty when there is absorption in the trident)

karmic bronze
#

you can make loyalty never return the trident if your enchantment is active on it.

delicate quarry
#

i dont want it to never return

karmic bronze
#

I am not 100% if you could even add a periodic tick to "delay" it

delicate quarry
#

i want it to return after the stand is killed

karmic bronze
#

ah I see

#

You can easily modify loyalty to have an on-off switch using a score or storage

delicate quarry
#

as for the trident not being there i guess that the most accurate way would be execute as @e[tag=example,predicate=enchantment_check,type=armor_stand] unless entity @e[distance=..1,predicate=enchantment_check,type=trident] run kill

karmic bronze
#

score would be easier to tie to your player

delicate quarry
#

yea but idk how the implementation works

karmic bronze
#

of what?

delicate quarry
#

of the delay

karmic bronze
#

Add requirements?

delicate quarry
#

that would change the return acceleration, so it'd be slower but still return automatically

#

maybe i could do execute store result score @s test run data get entity @s weapon.components."minecraft:enchantments"."minecraft:loyalty" 1 to store its level

#

and right after remove the enchantment, but idk what would I do to return it and also that command does not work

karmic bronze
#

you can disable the normal trident return

#

when your enchantment exists on the trident

delicate quarry
#

i want to delay it not disable

karmic bronze
#

delay = impossible without disabling it first

#

it will auto return

delicate quarry
#

delay = storing its level, removing it, wait til the explosion occours, apply loyalty back

#

i just dont know how to implement this

#

how would I even store the level?

karmic bronze
#

execute store result <some_where> run data get entity @s item.components."minecraft:enchantments"."minecraft:loyalty"

#

this is the trident entity btw

#

for the player it is SelectedItem instead of item

#

or execute store result <some_where> run data get entity @s SelectedItem.components."minecraft:enchantments"."minecraft:loyalty"

delicate quarry
#

hit block runs as the player iirc

#

so idk how to find the trident

#

prob just execute as @n[tag=example,type=trident] run execute store result <some_where> run data get entity @s item.components."minecraft:enchantments"."minecraft:loyalty"

karmic bronze
#

origin = location of hit

#

so no

#

it will be the closest trident

#

as in, the trident at distance 0 (or close to 0)

#

actually no

#

@s should be your trident

#

for hit_block

#

but you can test that

delicate quarry
#

oh, this makes sense cuz summoning the armor stand at @s summons it at the trident

#
execute store result score @s runes.store_loyalty run data get entity @s item.components."minecraft:enchantments"."minecraft:loyalty"
item modify entity @s contents runes:enchantment/remove_loyalty
#

now to return it

#

i cant think of a way that it wont lose context

#

oh and I should also store it in a storage since i need to use a macro

karmic bronze
#

just tested this and i got bad news it wont delay the return

delicate quarry
#

it just removes the enchantment for now ig

karmic bronze
#

removing the enchantment wont do anything

#

it still returns

delicate quarry
#

uh wth

#

🤔

#

i thought it had a delay before returning or something

karmic bronze
#

I am using a commandblock to remove it in-flight btw

#

that is how I tested this

delicate quarry
#

yea it really does not get removed

#

or just returns idk

karmic bronze
#

it is removed, but the return isn't affected, same with requirements that I was hoping might work

delicate quarry
#

also the armor stand kill thing does not work

#

i mean, it does but kills even when its there

naive sandal
karmic bronze
#

are you executing at the armor

naive sandal
#

No, it will not

#

I've tested this myself and is how I made my own trident vaccum enchant which is where void got the idea in the first place

karmic bronze
#

ugh item modifier shenanigans

#

the modifier did remove it but doesnt disable it

#

so data remove is the method

delicate quarry
#

how do i remove it?

#

i managed to write data modify entity @s item.components."minecraft:enchantments"."minecraft:loyalty"

karmic bronze
#

remove not modify

delicate quarry
#

oh yea

#

to return the loyalty

#

hmm im unsure yet

naive sandal
#

removing and restoring loyalty

delicate quarry
#

about the level

#

does data modify handle it or i should keep storing it?

karmic bronze
#

store it somewhere first

delicate quarry
#

i did in a storage

karmic bronze
#

would make sense to store it on the trident itself though

delicate quarry
#

how would i return it if not by macros?

#

i only know macros

naive sandal
#

Store it under the trident's data nbt and then just run data modify entity ... item.components."minecraft:enchantments"."minecraft:loyalty" set from entity ... data.<path_to_loyalty_level>

delicate quarry
#

oh?

naive sandal
#

No need for macros either

delicate quarry
#

ok stored it

#

is there a way to return it where the trident still being the context entity?

#

or i should use @n

karmic bronze
#

if you want to delay it, you need to regain context after the delay is done.

naive sandal
#

^

delicate quarry
#

does schedule run at the tridents location?

#

or even that is lost

naive sandal
#

Easy way to do this is have the enchanted armor stand ride the Trident entity and then execute on the vehicle

karmic bronze
#

no schedule is just like tick

#

runs as the server at 0,0 facing 0,0 etc.

naive sandal
delicate quarry
delicate quarry
#

wont it pull entities while flying

naive sandal
#

Summon the armor stand when the Trident hits a block

delicate quarry
#

uh

#

oh you mean making it ride the trident after being summoned

naive sandal
#

Yes

delicate quarry
#

the entity that goes after ride is the one riding the one after mount right?

naive sandal
#

yes

delicate quarry
#

i tried to return it in the same function that i kill the armor stabd

#

but didnt work

naive sandal
#

show your work

delicate quarry
#
execute store result entity @s data.stored_loyalty_level int 1 run data get entity @s item.components."minecraft:enchantments"."minecraft:loyalty"
data remove entity @s item.components."minecraft:enchantments"."minecraft:loyalty"
<summons armor stand>
ride @n[tag=runes.armor_stand_perm,type=minecraft:armor_stand] mount @s
#

execute on vehicle run data modify entity @s item.components."minecraft:enchantments"."minecraft:loyalty" set from entity @s data.stored_loyalty_level

#

By didnt work i mean it didnt return

#

So the enchsntment wasnt there

naive sandal
#

That's strange, it's not the behavior I'm getting when testing these commands

delicate quarry
#

What happens when you test it?

naive sandal
#

It returns as expected

delicate quarry
#

🤔

delicate quarry
#

oh it works

#

i prob forgot to reload or something

#

to remove the armor stand if theres no trident i can check if the armor stand no longer has a vehicle right?

naive sandal
#

Yes or just kill it when the Trident returns

delicate quarry
#

oh and also if i get the trident back it does not have loyalty

naive sandal
#

Odd

delicate quarry
#

well it returns before the armor stand is killed so if i do not wait it wont return what isnt what im lf

#

i want to return the enchantment if the player picks the trident up again

naive sandal
#

Atp just make the enchants exclusive then

#

Why bother with loyalty if it won't work with your enchantment

#

Unless I'm confusing something here

#

(I probably am)

delicate quarry
#

what have you understand

naive sandal
#

Oh yeah no idk what I was thinkinh

#

Anyways it should just have loyalty on it when it begins to return, if you're getting the return behavior without actually having loyalty on the Trident then idk what would be going on for that to happen

delicate quarry
#

no no i didnt mean that

#

if i get very close to the trident it returns to me

#

when this happens the enchantment just vanishes

naive sandal
#

Ah

#

You need to change the trident's pickup nbt and revert it when you want it to return

#

You can do the same thing you did with the enchantment restoration

delicate quarry
#

i set it to a very high value?

#

oh actually its 1 2 or 0

#

i assume 1 is true and 0 false? what is 2

naive sandal
#

I don't remember exactly but they do different things

#

Pretty sure 2 disables pickup entirely, 1 enables it only for creative mode, and 0 enables it for all modes

#

Though it's worth checking the wiki for this

delicate quarry
#

im trying but the data page is confusing asf

#

i think it should be here but idk

naive sandal
#

NVM I was wrong it's the other way around

delicate quarry
#

oh so it must be 0 when it hits a block and 1 when the enchantment returns

#

i should also add a loyalty check but idk how exaclty

#

so it does not modify when theres no loyalty

naive sandal
#

execute if items ... should also work I think

delicate quarry
#

i grouped some of the lines into a function but i dont think the ride needs to be grouped since it does not matter riding it or no (when there's no loyalty)

#

grouped these:```hs
execute store result entity @s data.stored_loyalty_level int 1 run data get entity @s item.components."minecraft:enchantments"."minecraft:loyalty"
data modify entity @s pickup set value 0
data remove entity @s item.components."minecraft:enchantments"."minecraft:loyalty"

and changed this:
```hs
execute on vehicle if data entity @s item.components."minecraft:enchantments"."minecraft:loyalty" run data modify entity @s item.components."minecraft:enchantments"."minecraft:loyalty" set from entity @s data.stored_loyalty_level
#

i guess these are enough, im unsure but yea it might be

#

it stopped working

#

when it has loyalty

#

oh lmao

#

ok everything's (hopefully) fixed now im just wondering how to kill the armor stand if the trident is not its vehicle anymore

#

maybe execute as @e[tag=runes.armor_stand,predicate=example,type=armor_stand] run kill and in the predicate ```json
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"vehicle": {
"type": "minecraft:trident"
}
}
}
}