Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add potion effect tier #4632

Merged
merged 16 commits into from
Aug 17, 2022
Merged

Add potion effect tier #4632

merged 16 commits into from
Aug 17, 2022

Conversation

Ankoki
Copy link
Contributor

@Ankoki Ankoki commented Feb 28, 2022

Description


Adds an expression to get the tier/amplifier of a potion effect type.
Currently returns 0 if the player doesn't have that type, but could return an empty Number array instead if preferred (links to the next point)?
Another thing to note, as this returns the amplifier, if a player has the effect haste at tier 1, it'll return 0. Should this stay that way or would it be preferred to add an extra 1 to it so it makes more sense? As I made the pattern tier/amplifier, it could be confusing as you use apply tier %number%, lmk any thoughts ^-^
Target Minecraft Versions: any
Requirements: n/a
Related Issues: n/a afaik

Took 2 minutes
Took 2 minutes
@TPGamesNL TPGamesNL added the feature Pull request adding a new feature. label Feb 28, 2022
@AyhamAl-Ali
Copy link
Member

I would say let it start at 1 instead of 0 otherwise zero will be confusing whether that player doesn't have the potion or has tier 1 of it

@TPGamesNL
Copy link
Member

TPGamesNL commented Feb 28, 2022

I think it'd be better to return null instead of 0.
EDIT: reason for it being: if you apply a potion effect of tier 0, it'll still apply the potion but with tier 1

@Ankoki
Copy link
Contributor Author

Ankoki commented Feb 28, 2022

added both these suggestions, I returned an empty array instead of null to be consistent with earlier in the method, would you prefer I returned new Number[0] or null? I'm not quite sure if there's a difference

@TPGamesNL
Copy link
Member

There's no difference

@AyhamAl-Ali
Copy link
Member

I think it'd be better to return null instead of 0. EDIT: reason for it being: if you apply a potion effect of tier 0, it'll still apply the potion but with tier 1

Regarding that, would if tier of haste of player < 3 work if it returns null?

@Ankoki
Copy link
Contributor Author

Ankoki commented Feb 28, 2022

I think it'd be better to return null instead of 0. EDIT: reason for it being: if you apply a potion effect of tier 0, it'll still apply the potion but with tier 1

Regarding that, would if tier of haste of player < 3 work if it returns null?

I'd like to think so, it shouldn't error however it should always return false as the value isn't set, ill give it a go

@AyhamAl-Ali just gave it a shot, outcome is as expected.
image

@AyhamAl-Ali
Copy link
Member

AyhamAl-Ali commented Feb 28, 2022

In this case it returns unexpected value, you would need to add another condition to check if entity has potion which for me this is just an extra unneeded condition

E.g. this code won't work as expected

on break:
    if tier of haste of player < 3: # this will *not* pass if tier returns null which shouldn''t happen
        send "You need higher haste level to mine here"
        cancel event

Regarding the case TP mentioned it would be better to change its behavior to not apply a potion of tier 0, what do you think @TPGamesNL ?

@Ankoki
Copy link
Contributor Author

Ankoki commented Feb 28, 2022

i see your point, i think having 0 instead of null makes more sense now that we've added 1 to the amplifier result

@APickledWalrus
Copy link
Member

This is just a note for me. #4183 will need to account for this expression :)

@AyhamAl-Ali
Copy link
Member

I forgot you're reworking potions :'D

@TPGamesNL
Copy link
Member

In this case it returns unexpected value, you would need to add another condition to check if entity has potion which for me this is just an extra unneeded condition

E.g. this code won't work as expected

on break:
    if tier of haste of player < 3: # this will pass if tier returns null which shouldn't happen
        send "You need higher haste level to mine here"
        cancel event

That wouldn't be the case if tier returns null, as shown in the screenshot:
image
The condition would return false

Regarding the case TP mentioned it would be better to change its behavior to not apply a potion of tier 0, what do you think @TPGamesNL ?

My bad, I tested with the bukkit method not the skript effect and they use amplification, not tiers. Disregard that comment

@AyhamAl-Ali
Copy link
Member

That wouldn't be the case if tier returns null, as shown in the screenshot: image The condition would return false

Oh I meant this will *not* pass my bad

@TPGamesNL
Copy link
Member

In that case it would indeed be better to return 0 instead of null

@Ankoki
Copy link
Contributor Author

Ankoki commented Feb 28, 2022

i'll change that as soon as i get access to my laptop again

Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice little addition.

In the future I think it would be nice if this supported changers (e.g. add/remove 1 from the tier) but since that would require some trickery it's not necessary now.

@Ankoki
Copy link
Contributor Author

Ankoki commented Mar 4, 2022

A nice little addition.

In the future I think it would be nice if this supported changers (e.g. add/remove 1 from the tier) but since that would require some trickery it's not necessary now.

might be something for @APickledWalrus to think about when he does his rework of potions

@APickledWalrus
Copy link
Member

sure - I'll take a look into that when I next work on the PR

@TPGamesNL
Copy link
Member

This should probably support %potioneffect% as well, but could also be something for potions rework

@APickledWalrus
Copy link
Member

This should probably support %potioneffect% as well, but could also be something for potions rework

That might be better for a separate syntax since you wouldn't need a living entity. Maybe it could be like ExprPotionProperties and include other properties like duration

@TPGamesNL
Copy link
Member

TPGamesNL commented Mar 4, 2022

That might be better for a separate syntax since you wouldn't need a living entity. Maybe it could be like ExprPotionProperties and include other properties like duration

Yes, but then we'd also need an expression to get a PotionEffect of a certain PotionEffectType from an entity, and together with a property expression for a potioneffect's tier, this expression will be obsolete

@Ankoki
Copy link
Contributor Author

Ankoki commented Jul 15, 2022

i'll work on those changes as soon as i'm home! :)

Ankoki and others added 3 commits July 16, 2022 03:00
…java

Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
…java

Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
…java

Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Ankoki and others added 2 commits July 16, 2022 03:04
…java

Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
…java

Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Took 23 minutes
…java

Co-authored-by: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com>
…java

Co-authored-by: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com>
@TheLimeGlass
Copy link
Collaborator

Requesting new review from @APickledWalrus due to decent amount of changes since last review not by me.

@TheLimeGlass TheLimeGlass merged commit 8dc0491 into SkriptLang:master Aug 17, 2022
@bluelhf
Copy link
Contributor

bluelhf commented Aug 17, 2022

Syntactically, this looks a lot like an applied potion effect property on living entities followed by separate syntax for the tier of an applied potion effect... For example tier of player's haste effect isn't valid syntax here (even though arguably it should be).

Was it planned to replace this syntax with properly implemented support for (applied) potion effects in the future? If not, why?

@TheLimeGlass
Copy link
Collaborator

TheLimeGlass commented Aug 17, 2022

Syntactically, this looks a lot like an applied potion effect property on living entities followed by separate syntax for the tier of an applied potion effect... For example tier of player's haste effect isn't valid syntax here (even though arguably it should be).

Was it planned to replace this syntax with properly implemented support for (applied) potion effects in the future? If not, why?

I don't like how that sounds.

Potion support #4183

@bluelhf
Copy link
Contributor

bluelhf commented Aug 17, 2022

Syntactically, this looks a lot like an applied potion effect property on living entities followed by separate syntax for the tier of an applied potion effect... For example tier of player's haste effect isn't valid syntax here (even though arguably it should be).
Was it planned to replace this syntax with properly implemented support for (applied) potion effects in the future? If not, why?

I don't like how that sounds.

Potion support #4183

Ah, the potion support PR looks fairly good — I still think we should be utilising types more than we currently are: the currently proposed syntaxes emulate type-like behaviour anyways, and types would allow for more syntactical versatility and improved code readability and maintainability.

@TheLimeGlass
Copy link
Collaborator

Syntactically, this looks a lot like an applied potion effect property on living entities followed by separate syntax for the tier of an applied potion effect... For example tier of player's haste effect isn't valid syntax here (even though arguably it should be).
Was it planned to replace this syntax with properly implemented support for (applied) potion effects in the future? If not, why?

I don't like how that sounds.
Potion support #4183

Ah, the potion support PR looks fairly good — I still think we should be utilising types more than we currently are: the currently proposed syntaxes emulate type-like behaviour anyways, and types would allow for more syntactical versatility and improved code readability and maintainability.

The potions rework pull request has been stated to be completely recoded, if you have any continued suggestions for it, you can use that pull request discussion.

@Ankoki Ankoki deleted the potion-tier branch August 17, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants