Ayfri / Kore

A Kotlin library to generate Datapacks for Minecraft Java.
https://kore.ayfri.com
GNU General Public License v3.0
73 stars 3 forks source link

[BUG] States on block predicate cannot be null #80

Closed Aeltumn closed 2 months ago

Aeltumn commented 2 months ago

Library version

1.8.0-24w14a

What module does this bug apply to?

DSL

What happened?

Prepare for me to report a lot of these, sorry! I'm using the following code to generate a predicate to check a block's type:

block(vec3(0.relativePos, (-1).relativePos, 0.relativePos), io.github.ayfri.kore.arguments.types.resources.block("${team}_concrete"))

And this is being generated:

execute as @a[scores={intro_completed=1..}] at @s if block ~ ~-1 ~ minecraft:magenta_concrete{} run function crossfire:generated_scopes/generated_1990421361

Here because block's states value defaults to mutableMapOf() and https://github.com/Ayfri/Kore/blob/fa68146a887e7aefa2e8a4ad65ff6393fa552c68/kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/resources/BlockArgument.kt#L16 always writes it to the output, there is always a {} in the output.

Arguably vanilla should not see magenta_concrete{} and magenta_concrete as different but with the {} the condition fails and it works without the {}.

Might start making PRs out of these if I find a lot of issues.

How can we reproduce this issue?

If you want the full context:

  1. Go to https://github.com/Aeltumn/realms-maps and clone it.
  2. Run ./gradlew :crossfire:run (make sure to use Java 21)
  3. Look at the created pack in /out.

Extra information

No response

My issue is not duplicated

Ayfri commented 2 months ago

Small bug, easy fix, will be fixed in 1.20.5-pre1 !