mojira.dev
MC-252369

Feature Cycle detected where no cycle exists

To Reproduce

  • Try and create a world with the attached datapack.

  • Notice that Minecraft crashes, saying the datapack contains a feature cycle.

  • The datapack doesn't contain a feature cycle.

The datapack:

The datapack in question contains two biomes, of which the only notable part is two features:

 

// biomes/plains.json
"features": [
  ["minecraft:feature_1", "minecraft:feature_2"]
]

// biomes/forest.json
"features": [
  ["minecraft:feature_2", "minecraft:feature_3"]
]

// Each of placed_feature/feature_1.json, placed_feature/feature_2.json, and placed_feature/feature_3.json are identical (this is important)
{
  "feature": {
    "type": "minecraft:no_op",
    "config": {}
  },
  "placement": []
}

As you can see, this does not contain a feature cycle.

 

 

Explanation

In 1.18.2, many world generation related objects became Java records, and this change meant that they now have an override of equals() and hashCode() which operates on their fields. What this means is that two separate placed features can return true, when queried through equals():

 

  • PlacedFeature is a record, so it uses equality of components,

    • The `feature` component is a Holder.Direct<>, which is a record,

      • The `value` component is a ConfiguredFeature which is a record,

        • And the `feature` and `config` are both equal, since the features' have the same type, and `NoneFeatureConfiguration` has a single instance.

    • The `placements` component is a list, which is empty, and therefor equal.

 

As a result of this, `buildFeaturesPerStep`, which in many places uses `java.util.TreeMap`, `java.util.TreeSet`, and `it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap`, all of which use equals() semantics to determine if two objects are equal, not identity equality. So in trying to detect a cycle, it treats different features as identical, and thus detects a cycle where no cycle is present.

 

Attachments

Comments 8

WHY IS THIS LOW PRIORITY??? FIX IT PLEASE ITS SO ANNOYING I DONT KNOW WHAT TO DO

Affects all versions from 22w17a to 1.19-rc2

Probably because this only happens with identical files, in which case you canjust re-use one of the files and delete the other.

PLEASE PLEASE JUST FIX THIS BUG ALREADY

Calm down, you can prevent this yourself by just re-using the file, rather than making exact duplicates. Because of that this has low priority and may take months before they fix it (if not longer); you shouting is not making any difference whatsoever.

I think the other user's issue (MC-252436) was incorrectly linked as a duplicate of this issue. That issue, without any further information, appears to me to just be an instance of a feature cycle caused by invalid datapack configuration.

> you can prevent this yourself by just re-using the file, rather than making exact duplicates.

It is also worth mentioning that no, you can't re-use the file, as that would lead to a correctly identified cycle, which would still crash. However, it is still possible to avoid this entirely, for instance using features that don't have object equality which is something quite easy to avoid. For example, since `Holder.Reference` is not a `record`, all we have to do to fix the above example is to change the inline configured feature in each one of those placed features, to a single reference to a new configured feature.

@unknown please do not swear. This tracker is meant for all ages. Also please only comment if you have new information to add.

Maybe you could get in contact with the mod developer of cyanide to see if you could possibly borrow the cold? thet mod fixeds this issue and a bunch of thother annoying datpakca issues

Alex O'Neill

(Unassigned)

Confirmed

Platform

Low

Custom Worlds

1.18.2, 1.19 Pre-release 4, 1.19 Release Candidate 2, 1.19

Retrieved