Skip to content

feat: add additional data support for particles on Minestom platform#561

Open
Sybsuper wants to merge 1 commit into
PolyhedralDev:dev/1.21.11from
Sybsuper:feat/particles-additional-data
Open

feat: add additional data support for particles on Minestom platform#561
Sybsuper wants to merge 1 commit into
PolyhedralDev:dev/1.21.11from
Sybsuper:feat/particles-additional-data

Conversation

@Sybsuper

Copy link
Copy Markdown

Pull Request

Description

This PR adds support for additional data for biome ambient particles on the Minestom platform.

The problem

When attempting to load particles such as:

particle: minecraft:trail{target:[0.5,85,0.5],color:[0.302, 0.192, 0.412],duration:75}

On the Minestom platform this would ignore the particle with a warning in the console:

WARN com.dfsek.terra.minestom.config.BiomeParticleConfigTemplate - Particle minecraft:trail{target:[0.5,85,0.5],color:[0.302, 0.192, 0.412],duration:75} has additional data, particle will be ignored.

Why?

This behavior is actually very understandable, since Minestom until recently didn't have a Particle Codec to decode Particles from a string. Implementing the parsing manually would have been very painful.

The solution

Recently, Minestom has added decoding capabilities to their Particle Codec Minestom/Minestom@920922c. This allows us to easily implement a parser using their decoder.

Changelog

  • I modified the BiomeParticleConfigTemplate.java file and added parsing for additional particle data

NOTE: When making this change I found that Minestom currently has a bug in their Particle Codec that doesn't correctly parse block_state values. I've made a PR Minestom/Minestom#3175 to Minestom to fix this. Until then it does correctly parse particle data that has no block states. When this PR is merged, no code changes should be required (fingers crossed) to accommodate block_state values.

I've kept the past behavior of ignoring a particle completely when it cannot be parsed correctly and send a warning in the console.
An example of such a warning:

WARN com.dfsek.terra.minestom.config.BiomeParticleConfigTemplate - Failed to decode particle from 'falling_dust{block_state:{Name:light_gray_terracotta}}', nbt: '{type:"falling_dust",block_state:{Name:"light_gray_terracotta"}}'. This particle will be ignored.
java.lang.IllegalArgumentException: block_state: Not a string: BinaryTagType[CompoundBinaryTag 10]{tags={"Name"=BinaryTagType[StringBinaryTag 8]{value="light_gray_terracotta"}}}

Checklist

Mandatory checks

  • The base branch of this PR is an unreleased version branch (that has a ver/ prefix)
    or is a branch that is intended to be merged into a version branch.

    Uhm, no not a ver/ prefix, but it's not the master branch. I did confirm with a contributor that this is the branch I should make a PR to.

  • There are no already existing PRs that provide the same changes.
  • The PR is within the scope of Terra (i.e. is something a configurable terrain generator should be doing).
  • Changes follow the code style for this project.
  • I have read the CONTRIBUTING.md
    document in the root of the git repository.
  • LLM-based tools were not used to create this PR. (ChatGPT, Claude, etc)

Types of changes

  • Bug Fix
  • Build system
  • Documentation
  • New Feature
  • Performance
  • Refactoring
  • Repository
  • Revert
  • Style
  • Tests
  • Translation

Compatibility

  • Introduces a breaking change
  • Introduces new functionality in a backwards compatible way.
  • Introduces bug fixes

Documentation

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Testing

This PR can be tested by launching a Minestom server with Terra (such as the example server in this repo). The most easy to locate place the newly supported particles can observed is in the end dimension with the end dimension's default pack.

javaw_SceTe5ExSp.mp4

Change the following code in TerraMinestomExample.java to load the end pack on Minestom.

    public void createNewInstance() {
        instance = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.THE_END);
        instance.setChunkSupplier(LightingChunk::new);
    }

    public void attachTerra() {
        world = platform.worldBuilder(instance)
            .packByDefaultMeta(DimensionType.THE_END)
            .attach();
    }

Then simply run the example server and join it.
NOTE: There will be some warnings in the console for particles with block_state. See the note above for an explanation and an example of such a warning.

  • I have added tests to cover my changes.
  • All new and existing tests passed.

Licensing

  • I am the original author of this code, and I am willing to
    release it under GPLv3.
  • I am not the original author of this code, but it is in public domain or
    released under GPLv3 or a compatible license.

@Bloeckchengrafik Bloeckchengrafik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for looking into this!

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.

2 participants