Skip to content

Commit

Permalink
Fix FeatureFlagGenerator.java to generate in the correct format (#28)
Browse files Browse the repository at this point in the history
* Add generation of feature flag namespaces.

* Rewrite FeatureFlagGenerator.java to use a JsonObject instead of a JsonArray.

---------

Co-authored-by: iam <[email protected]>
  • Loading branch information
Flopgop and iam4722202468 authored Jun 17, 2024
1 parent 1d86220 commit bbd916c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.minestom.generators;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.flag.FeatureFlags;
import net.minestom.datagen.DataGenerator;
Expand All @@ -9,12 +10,15 @@

public final class FeatureFlagGenerator extends DataGenerator {
@Override
public JsonArray generate() throws Exception {
JsonArray flags = new JsonArray();
public JsonObject generate() throws Exception {
JsonObject flags = new JsonObject();

Set<ResourceLocation> featureFlags = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags());
int idCounter = 0;
for (ResourceLocation namespace : featureFlags) {
flags.add(namespace.toString());
JsonObject flag = new JsonObject();
flag.addProperty("id", idCounter++);
flags.add(namespace.toString(), flag);
}

return flags;
Expand Down

0 comments on commit bbd916c

Please sign in to comment.