-
Notifications
You must be signed in to change notification settings - Fork 0
Creating an entity selector
This guide assumes you've already created and setup an Avoid project.
This guide uses meta-programming. Another way may either not be implemented or you may need to figure it out on your own.
§ Making an entity selector with the Avoid Framework
-
Create a java class;
You can pick any location within your project source code directory. -
Paste the following code:
package com.example.avoidtmpl; import pl.olafcio.avoid.mods.annotation_processor.AutoChar; import pl.olafcio.avoid.mods.annotation_processor.AutoSelector; import pl.olafcio.avoid.net.chat.component.BaseComponent; import pl.olafcio.avoid.net.chat.component.Components; import pl.olafcio.avoid.net.entity_selector.EntitySelector; import pl.olafcio.avoid.net.entity_selector.properties.SelectorOrder; import pl.olafcio.avoid.net.entity_selector.properties.SelectorResults; import pl.olafcio.avoid.net.entity_selector.properties.SelectorTarget; @AutoSelector @AutoChar('c') @SelectorOrder(SelectorOrder.Enum.RANDOM) @SelectorTarget(SelectorTarget.Enum.ENTITIES) @SelectorResults(1) public class RandomEntitySelector extends EntitySelector { @Override public BaseComponent<?> getTranslation() { return Components.literal("Random entity"); } }
Of course you need to replace the class name and package.
-
Customize it as you wish;
The meta API currently has only 4 annotations:- SelectorSelf: defines the selection works like
@s - SelectorOrder: defines the order for the selection
- SelectorTarget: defines the target entity type to select (currently only ENTITIES / PLAYERS)
- SelectorResults: max amount of entities for the selection
The top @AutoChar declaration defines the character used for the selector (in this case,
@c).
You can currently only change 1 inherited method of EntitySelector:- getTranslation: returns the translation for the selector name when the user hovers over it
- SelectorSelf: defines the selection works like
©️ Copyright 2026 Olafcio (on behalf of the AvoidLib org)
📝 Licensed with CC BY-NC (Attribution-NonCommercial)
Avoid Framework
🏚️ 1. Home
📽️ 2. Creating your mod
🌄 3. Adding assets to your mod
🧊 4. Creating a block
✏️ 5. Creating an item
🎯 6. Creating an entity selector
🤖 7. Creating a command