User Tools

Site Tools




Items and Item Groups

Blocks and Block Entities


World Generation





Fabric Сontributors

If you'd like to contribute to Fabric, you might be interested in these links:

Extremely Strange People

Wiki Meta

  • Wiki Meta - Starting point for contributing to the wiki
  • Wiki Agenda - See what is on the current agenda, and what other contributors are currently working on.


While testing new StructureFeature additions, it's nice to be able to find it quickly without pumping up the rarity to every chunk. Thankfully, vanilla has a mechanic for doing this: /locate!

To add your feature to the locate command, you'll need

  • a StructureFeature– normal Feature additions will not work.
  • a mixin to LocateCommand
  • to add your feature to the Feature.STRUCTURES list

Mixin Time

Create a mixin to LocateCommand. You'll need to inject into register at RETURN and add in your feature:

@Inject(method = "register", at = @At(value = "RETURN"))
private static void onRegister(CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo info) {
    dispatcher.register(literal("locate").requires(source -> source.hasPermissionLevel(2))
          .then(literal("TutorialStructure").executes(ctx -> execute(ctx.getSource(), "Tutorial_Jigsaw"))));

We're tagging onto the existing /locate command here. “TutorialStructure” is the name that appears in the locate command suggestion list, as well as the name you'll need to type in to find your structure. “Tutorial_Jigsaw” is essentially the locate ID of your structure. It'll have to match another string we use next.

Note that:

  • the literal label can have no spaces
  • the execute string is converted to lowercase for comparison and can have spaces
  • the literal label does not need to be the same as the execute string

The finalized mixin class:

  1. import com.mojang.brigadier.CommandDispatcher;
  2. import net.minecraft.server.command.LocateCommand;
  3. import net.minecraft.server.command.ServerCommandSource;
  4. import org.spongepowered.asm.mixin.Mixin;
  5. import org.spongepowered.asm.mixin.Shadow;
  6. import org.spongepowered.asm.mixin.injection.At;
  7. import org.spongepowered.asm.mixin.injection.Inject;
  8. import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
  10. import static net.minecraft.server.command.CommandManager.literal;
  12. @Mixin(LocateCommand.class)
  13. public abstract class LocateCommandMixin {
  15. private LocateCommandMixin() {
  16. // NO-OP
  17. }
  19. @Shadow
  20. private static int execute(ServerCommandSource source, String name) {
  21. throw new AssertionError();
  22. }
  24. @Inject(method = "register", at = @At(value = "RETURN"))
  25. private static void onRegister(CommandDispatcher<ServerCommandSource> dispatcher, CallbackInfo info) {
  26. dispatcher.register(literal("locate").requires(source -> source.hasPermissionLevel(2))
  27. .then(literal("TutorialStructure").executes(ctx -> execute(ctx.getSource(), "Tutorial_Jigsaw"))));
  28. }
  29. }


Vanilla Minecraft has a hardcoded list of locatable Structure Features in the Feature class. Fun, right? Thankfully it's public, so we can add to it directly:

Feature.STRUCTURES.put("tutorial_jigsaw", FEATURE);

“tutorial_jigsaw” should match the lowercased version of the ID we used in the previous section. FEATURE is an instance of your StructureFeature registered from the FEATURE registry. An example would be like so:

public static final StructureFeature<DefaultFeatureConfig> FEATURE = Registry.register(
	new Identifier("tutorial", "example_feature"),
	new ExampleFeature(DefaultFeatureConfig::deserialize)


Go in game, and type /locate TutorialStructure. Assuming your structure was properly generated, you'll get a message in chat leading you to the closest one.

tutorial/locate.txt · Last modified: 2019/10/20 23:17 by draylar