Update Leash Syntax To Entity#8413
Conversation
|
Duplicate of #8241 |
There was a problem hiding this comment.
Tests contain lines attempting to leash entities to blocks, while the syntax does not offer support for this. Also never checks whether syntax even succeeded See sovde's comments
Instanceof checks do not need to have the entire path of the class, can just check for Leashable instead of io.papermc.paper.entity.Leashable.
Perhaps add a new version to @Since to indicate changes to what entities can be leashed.
The rest looks good to me!
Absolutionism
left a comment
There was a problem hiding this comment.
Since this is a feature PR, it will be added in Skript 2.15, which the minimum MC version will be 1.21.1 (only a singular bump in the minor version). 1.21.1 contains Leashable, so there is no need for the SUPPORTS_LEASHABLE
There was a problem hiding this comment.
Description of EffLeash is not accurate, as Ender Dragon, Wither, and Bat are all subinterfaces of Leashable, thus should be leashable (?)
New version in @Since should be INSERT VERSION, not 2.10, which has been out for a long time. (AI does not know this.) Its description (currently entities) could also be slightly more descriptive, as it doesn't really say anything about what changed after the new version.
|
I still don't really love the since, the differences between LivingEntity and Leashable are not just non-living entities. |
There was a problem hiding this comment.
For Since, any entity type is not accurate either, as not every entity type is Leashable (Think Player, Armor Stand).
Additionally, asserting whether a zombie is not leashed with "... non-leashable entity ..." makes no sense, as zombies are leashable.
|
@tibisabau have you played Minecraft before? It seems like a lot of these changes are just blind guesses in the dark. I suggest you reference Paper's javadocs for Leashable or at least the minecraft wiki. Tests failing due to leashing entity to self working in 1.21.3/1.21.1. |
|
Skript users probably will not know what
|
| # Check if self-leashing is supported by the Leashable API | ||
| if {_self} is leashed: | ||
| assert leash holder of {_self} is {_self} with "if self-leashing works, holder should be itself" |
There was a problem hiding this comment.
this is a bit iffy, we should really be checking exact versions it should work on.
But whatever, it's probably ok.
Problem
Leash-related syntax (leash holder expression, leash/unleash effects, and is leashed condition) only accepted LivingEntity types, preventing users from leashing boats and other non-living leashable entities. Users had to resort to reflection workarounds to leash boats.
Solution
Updated all three leash-related syntax files to accept any Entity type and utilize Paper's
Leashableinterface (available in Paper 1.21+) with runtime version checking viaSkript.classExists(). The implementation falls back to the legacyLivingEntity.getLeashHolder()approach for older server versions, maintaining full backward compatibility.Modified Files:
ExprLeashHolder.java- Changed fromSimplePropertyExpression<LivingEntity, Entity>toSimplePropertyExpression<Entity, Entity>EffLeash.java- Updated to acceptExpression<Entity>instead ofExpression<LivingEntity>for both leash and unleash operationsCondLeashed.java- Changed fromPropertyCondition<LivingEntity>toPropertyCondition<Entity>Testing Completed
ExprLeashHolder.sk- Tests leash holder expression with wolves and non-leashable entities (snowballs)EffLeash.sk- Tests leash/unleash effects with living entities, non-living entities, and multiple entitiesCondLeashed.sk- Tests is leashed condition with various entity types./gradlew clean build- SUCCESS (0 errors)./gradlew clean quickTest- SUCCESS (all tests passed including "leash effect", "leash holder expression", and "is leashed condition")Supporting Information
The implementation uses Paper's
io.papermc.paper.entity.Leashableinterface which provides consistent leashing behavior across all entity types. Non-leashable entities return null/false without throwing exceptions, ensuring graceful handling of edge cases.Completes: #8239
Related: none
AI assistance: GitHub Copilot with Claude Sonnet 4.5 model
The code in this pull request was generated by GitHub Copilot with the Claude Sonnet 4.5 model.