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

Added non-conflicting methods delegating tests to Holder.is #957

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

Prunoideae
Copy link
Contributor

Description

Holder<T> is often used in the game coding, however it contains 5 overrides of is method each with different parameter type, which will cause Rhino to just not work for most of the time, since many of these types are overlapping in type wrapping (e.g. TagKey, ResourceKey and ResourceLocation.

This PR leaves only is(ResourceLocation) to test if the resource location is the one holder holds, and renamed is(Predicate<ResourceKey>) to test(Predicate<ResourceKey>), and added isTag(ResourceLocation) to test if the holder has a key represented by the resource location.

Example Script

PlayerEvents.tick(event => {
    let player = event.player
    if (player.tickCount % 80 == 0) {
        let level = event.level
        let biome = level.getBiome(player.block.pos)
        console.info(biome.is("minecraft:snowy_taiga"))
        console.info(biome.isTag("c:is_cold"))
    }
})

Other details

  • Other is overrides are all tagged @HideFromJS
  • A separate isTag is needed instead of remapping names due to Rhino is unable to wrap the tag from type TagKey<T>.

@ChiefArug
Copy link
Contributor

While we are here, can we get some @Info annotations on those? Including the one left untouched (it will also be nice to include it shadowed into there, so if it changes it will error).

@LatvianModder LatvianModder merged commit d96e1de into KubeJS-Mods:main Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants