-
Notifications
You must be signed in to change notification settings - Fork 2
Extending FM: New ActionTypes
Guns perform Actions, as specified in their .json definition
Note: "Doing something" with a gun has two stages; first the Action (such as Raycast) and then the Effect (such as DamageEntity). If you want to do something different when a bullet hits something, you should instead look at Effects and use it with the "flansmod:shoot" Action
You can add new Actions, as follows:
Create an ActionInstance class, such as ExampleAction.java
public class ExampleAction extends ActionInstance
{
public ExampleAction(@NotNull ActionGroupInstance group, @NotNull ActionDefinition def)
{
super(group, def);
}
@Override
public void OnTriggerClient(int triggerIndex)
{
}
@Override
public void OnTriggerServer(int triggerIndex)
{
FlansMod.LOGGER.info("Hello Action!");
}
}
Create a DeferredRegister in your mod for ActionTypes, similar to how you would create a DeferredRegister for Blocks or Items
public static final DeferredRegister<ActionType<?>> ACTION_TYPES = DeferredRegister.create(FlansRegistries.ACTION_TYPES, "examplemod");
Register a new ActionType (this is the object that tells Flan's Mod how to create one of your ExampleAction instances when the action is triggered by a gun)
public static final RegistryObject<ActionType<?>> ACTION_TYPE_EXAMPLE = ACTION_TYPES.register("example", () -> new ActionType<>(ExampleAction::new));
Make sure to add your DeferredRegister to the mod event bus (you probably already do this for BLOCKS and ITEMS registers)
public ExampleMod()
{
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// Other init ...
ACTION_TYPES.register(modEventBus);
}
Now you can put "examplemod:example" in a Gun definition .json and it will use your ExampleAction class. For more examples, check out the included ActionInstances in the base mod: https://github.com/FlansMods/FlansModReloaded/tree/1.20/src/main/java/com/flansmod/common/actions/nodes
| Flan's Mod: Reloaded | Basic Parts Pack | Vender's Game | Create: Love & War |
|---|---|---|---|
| Getting Started Wiki | Content Wiki | Content Wiki | Content Wiki |
| On CurseForge | On CurseForge | On CurseForge | On CurseForge |
![]() |
![]() |
![]() |
![]() |
Basics - Setup | Import 1.12.2 | New Pack | New Definition
Definitions - Attachments | Bullets | Guns | Magazines | Materials | NPCs | Parts | Traits
Appendix - Modifiers | Recipes
Getting Started
Basic Parts Content
Vender's Game Content
Create: Love & War Content
Content Tool Home
Content Tool Setup
Import 1.12.2 (FM: Legacy) Pack
Create New Pack
Create New Definition
Basics
Attachments
Bullets
Guns
Magazines
Materials
NPCs
Parts
Recipes
Traits
Workbenches



