Skip to content

EntityData Overhaul #7985

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

Open
wants to merge 26 commits into
base: dev/feature
Choose a base branch
from

Conversation

Absolutionism
Copy link
Contributor

@Absolutionism Absolutionism commented Jul 1, 2025

Problem

  • Patterns for entities in the default.lang file became increasingly hard to read
    • The matchedPattern for abstract EntityData#init(...) is actually matchedCodeName
  • Some EntityData classes are outdated from current conventions
  • Some EntityData classes don't handle setting the EntityData#matchedPattern which is used for EntityData#toString
  • EntityData#matchedPattern gives the wrong impression of what exactly it is used for

Solution

  • Modifies EntityDataInfo for custom handling of multi lined patterns in the default.lang for code names.
    • Abstract EntityData#init(...) now passes the matchedCodeName (which is the same behavior as the previous matchedPattern)
      • matchedPattern has been refactored to pass along the actual matched pattern correlating to patterns of each code name
  • EntityData#matchedPattern has been renamed to codeNameIndex to be more specific and match these new changes
  • Multiple code names in the default.lang utilize the multi lined patterns section for improved readability
  • Updates 'Patterns"
    • Allows passing null values for general purposes rather than a specific type
    • Allows getting an array of matched patterns using the given typed object
    • Allows getting the matched pattern from the array with an arrayIndex
  • Updates conventions of EntityData classes
    • Remove existence checks for classes/methods that are available on all supported Minecraft versions of Skript
    • Classes using matchedPattern in their #init use matchedCodeName now
    • Classes that had extraneous checks for expressions have been reduced utilizing both the new matchedCodeName and matchedPattern
    • Classes use Patterns<T> for code names for EntityData#register
      • Allows setting a T data field using EntityPatterns#getInfo within #init using matchedCodeName
      • Allows getting matchedCodeName from T object using Patterns#getMatchedPattern
        • Allows setting EntityData#codeNameIndex within #init(Class, Entity) and constructors with parameters
    • Removes deprecated #deserialized
    • getSuperType now correctly get a data object with no special data
    • Renames SimpleEntityData#info -> simpleInfo to remove any confusion of EntityData#info
      • Also allows access to both without having to do super.info for EntityData#info

Misc Changes

  • Removes OcelotData as no supported versions of Minecraft still had Ocelot as Tameable thus not needing any special data and being moved to SimpleEntityData
  • Reordered entities section in default.lang to have the nodes be categorized by which EntityData class handles it
  • Added CondIsSpawnable to be able to check if an EntityData can be spawned
  • Overrode #canSpawn in DisplayData ensuring it wasn't DisplayType.ANY
  • Registers classes that EntityData classes use as fields and constructor parameters allowing to be stored in global variables

Misc Fixes

  • Some patterns for entities was incorrect, such as only having fox (kid|child[plural:ren]) for both red fox and snow fox but didn't have the leading red or snow, same was seen for Mooshrooms

Testing Completed

built-in tests
EntityData.sk

Supporting Information

N/A


Completes: none
Related: none

…taMultiLinedPatterns

# Conflicts:
#	src/main/resources/lang/default.lang
…taMultiLinedPatterns

# Conflicts:
#	src/main/java/ch/njol/skript/entity/BeeData.java
#	src/main/java/ch/njol/skript/entity/BoatChestData.java
#	src/main/java/ch/njol/skript/entity/BoatData.java
#	src/main/java/ch/njol/skript/entity/DroppedItemData.java
#	src/main/java/ch/njol/skript/entity/EntityData.java
#	src/main/java/ch/njol/skript/entity/LlamaData.java
#	src/main/java/ch/njol/skript/entity/ParrotData.java
#	src/main/java/ch/njol/skript/entity/PigData.java
#	src/main/java/ch/njol/skript/entity/SheepData.java
#	src/main/java/ch/njol/skript/entity/ThrownPotionData.java
#	src/main/java/ch/njol/skript/entity/TropicalFishData.java
#	src/main/resources/lang/default.lang
@Absolutionism
Copy link
Contributor Author

Reviews are still welcome while in draft

@APickledWalrus APickledWalrus self-requested a review July 1, 2025 01:58
…taMultiLinedPatterns

# Conflicts:
#	.github/CODEOWNERS
#	src/main/java/ch/njol/skript/lang/SkriptParser.java
@Absolutionism Absolutionism added enhancement Feature request, an issue about something that could be improved, or a PR improving something. breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) labels Jul 3, 2025
@Absolutionism Absolutionism marked this pull request as ready for review July 3, 2025 11:20
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jul 3, 2025
@Absolutionism
Copy link
Contributor Author

Absolutionism commented Jul 3, 2025

Marking as ready for review.

@Absolutionism Absolutionism requested a review from Efnilite July 4, 2025 12:34
@Absolutionism Absolutionism requested a review from Efnilite July 4, 2025 17:04
@Absolutionism Absolutionism moved this to In Review in 2.13 Release Jul 5, 2025
@skriptlang-automation skriptlang-automation bot added needs reviews A PR that needs additional reviews and removed needs reviews A PR that needs additional reviews labels Jul 6, 2025
Move EntityPatterns into Patterns
Add getMatchedPattern to Patterns
Add kleeneanMatch to EntityData
add dataMatch to EntityData
…taMultiLinedPatterns

# Conflicts:
#	src/main/java/ch/njol/skript/entity/PigData.java
@Absolutionism Absolutionism requested a review from sovdeeth July 9, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) enhancement Feature request, an issue about something that could be improved, or a PR improving something. needs reviews A PR that needs additional reviews
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants