Item Commander
Shiny item do stuff
A simple Serverside Fabric mod that allows you to assign commands to Item(Stacks).
It works by adding NBT data to the item, then when a player uses an item the NBT data for that item is checked, if it contains the ItemCommander tag tree it executes the specified command.
To embed a command in an item, hold it in your main hand and run /commander create "<command>" [CONSUME_ACTION] [COMMAND_SOURCE] [cooldownTicks] [CustomItemNBT]
consume actions:
| Action | Description |
|---|---|
| CONSUME | Consumes the item |
| KEEP | Keeps the item |
command sources:
| Action | Description |
|---|---|
| SERVER | Command executed by the server |
| PLAYER | Command executed by the player |
| OP | Command executed by the player with OP |
| SERVER_AS_PLAYER | Command executed by the server as the player (like OP) |
| DANGEROUSLY_OP | Command executed by the player whilst being OP ⚠️ |
defaults in **bold***
Command placeholders
when creating a command you can use the following vanilla-like placeholders:
| Placeholder | Action |
|---|---|
@itemname |
Item Name |
@pich |
Player pitch |
@yaw |
Player yaw |
@ix |
Item use X coordinate |
@iy |
Item use Y coordinate |
@iz |
Item use Z coordinate |
@x |
Player use X coordinate |
@y |
Player use Y coordinate |
@z |
Player use Z coordinate |
@p and @s |
The player using the Commander Item |
To append more commands to one item, hold a Commander Item in your main hand and run /commander append "<command>"
To save a Commander Item, hold it in your main hand and run /commander save <fileName>
To load/give a Commander Item, run /commander give <fileName> [quantity] [player(s)]
This mod supports Patbox' Text Placeholders API.
- You can use
%modid:type%or%modid:type/data%inside a Commander Item to make use of a custom placeholder - Example:
commander create
This mod supports LuckPerms' Fabric Permission API.
commander.command.createallows a player to use this mod to embed commands in itemscommander.command.appendallows a player to use this mod to append commands to Commander Itemscommander.command.giveallows a player to use this mod to give itself Commander Itemscommander.command.saveallows a player to use this mod to save Commander Items to a file on the server
Examples
Creating a Commander Item
/commander create "say Hello myself (@s), you clicked at @ix, @iy, @iz!" KEEP OP 20 paper{display:{Name:'[{"text":"Commander Test Item!","italic":false}]'}}
Appending an extra command to a Commander Item
/commander append "If you have Text Placeholder API, this will be your name: %player:name%"
Saving a Commander Item
/commander save commander_test_item
Giving/loading a saved item to a player
/commander give commander_test_item 1 @p
Bleeding edge builds
Upstream builds are available via GitHub Actions.
Setup
For setup instructions please see the fabric wiki page that relates to the IDE that you are using.
License
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
How to Install Item Commander (Mod)
Item Commander by Camper_Samu is verified for Fabric, Quilt across Minecraft versions 1.18, 1.18.1, 1.18.2, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4 (latest release: 1.7.0-pre.2+1.21.1, file size: 70 KB). Follow the steps below to install it safely from ModCraft.tv:
- Click the Download button above and select your Minecraft version (1.18, 1.18.1, 1.18.2, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4) and platform (Fabric, Quilt).
- Make sure you have the compatible loader or environment installed for Fabric, Quilt.
- Move the downloaded Item Commander file into your Minecraft
.minecraft/modsfolder and launch the game.
All Versions
+ Add Version_It was too good to be true..._</br>
This version fixes an issue where Commander data wouldn't be applied to new items (y'know, half of the mod functionality)
If you see any oddities, let me know!
_Thank god, 1.21.1 didn't impact this._
This is a simple port of the previous release.
I haven't gotten around to implement the datafixer and the new component structure, so I just decided to port this since Mojang still haven't removed the workarounds I am using to make this work.
If you see any oddities, let me know!
_Damn, 1.20.5 got hands._</br>
This is a rough port that uses the old NBT system instead of the custom component system I am planning for the stable release and doesn't feature a datafixer.</br>
If you want to update to this version, you can update old commander items by putting them in an inventory and then updating to 1.20.5.
All functionality should remain intact.
If you see any oddities, let me know!
### Changelog
- Fix [Placeholders API](https://pb4.eu/#placeholder-api) support
- Log mod integration support at mod initialization
- API: Add
CommanderSource#vanillato create a ServerCommandSource from a Commander Source
- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.6.1...1.6.2
### Changelog
- Fix [Placeholders API](https://pb4.eu/#placeholder-api) support
- Log mod integration support at mod initialization
- API: Add
CommanderSource#vanillato create a ServerCommandSource from a Commander Source
- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.6.1...1.6.2
SERVER_AS_PLAYER and DANGEROUSLY_OP, improving compatability with mods that don't use Brigadier or use altered permission checking such as WorldEdit.### Changelog
- Two new command context
SERVER_AS_PLAYER- This is the same as running a command as the server with
execute as @p, but in a way cleaner and faster way. DANGEROUSLY_OP- This context is highly discouraged, it works by briefly giving OP to the player to execute the command; this is done sequentially in a code block synchronized to the server op list, so it should generally be ok to use, but try to avoid this one if possible.
- [Updated documentation](https://github.com/CamperSamu/ItemCommander/blob/1.20.4/README.md)
### For the curious
If you are wondering how
DANGEROUSLY_OP works, here's the (Yarn) code snippet:``
java
case DANGEROUSLY_OP -> {
synchronized (server.getPlayerManager().getOpList()) {
server.getPlayerManager().addToOperators(player.getGameProfile());
server.getCommandManager().executeWithPrefix(player.getCommandSource(), parsedCommand);
server.getPlayerManager().removeFromOperators(player.getGameProfile());
}
}
``- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.6.0...1.6.1
SERVER_AS_PLAYER and DANGEROUSLY_OP, improving compatability with mods that don't use Brigadier or use altered permission checking such as WorldEdit.### Changelog
- Two new command context
SERVER_AS_PLAYER- This is the same as running a command as the server with
execute as @p, but in a way cleaner and faster way. DANGEROUSLY_OP- This context is highly discouraged, it works by briefly giving OP to the player to execute the command; this is done sequentially in a code block synchronized to the server op list, so it should generally be ok to use, but try to avoid this one if possible.
- [Updated documentation](https://github.com/CamperSamu/ItemCommander/blob/1.20.4/README.md)
### For the curious
If you are wondering how
DANGEROUSLY_OP works, here's the (Yarn) code snippet:``
java
case DANGEROUSLY_OP -> {
synchronized (server.getPlayerManager().getOpList()) {
server.getPlayerManager().addToOperators(player.getGameProfile());
server.getCommandManager().executeWithPrefix(player.getCommandSource(), parsedCommand);
server.getPlayerManager().removeFromOperators(player.getGameProfile());
}
}
``- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.6.0...1.6.1
This version also drops [Placeholders API](https://pb4.eu/#placeholder-api) as a mandatory, embedded dependency along fixing some quirks and updating documentation.
### Changelog
- Backport to 1.20.1 and 1.20.2
- OP Player command context
- This allows players to run a command as administrator (
SERVERexecute as @pbegone!) /commander givecan now give items to another player (or multiple players, like/give)- From now on, [Placeholders API](https://pb4.eu/#placeholder-api) will not be included with this mod and won't be needed for basic functionality
- If the player's hand is empty when trying to create a Commander Item (without a specified item), the command will now throw an error.
- Improved error logging
- Very minor code refactoring
- This mod now suggests [Placeholders API](https://pb4.eu/#placeholder-api) and [LuckPerms](https://luckperms.net/)
- [Updated documentation](https://github.com/CamperSamu/ItemCommander/blob/1.20.4/README.md)
- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.5.0...1.6.0
This version also drops [Placeholders API](https://pb4.eu/#placeholder-api) as a mandatory, embedded dependency along fixing some quirks and updating documentation.
### Changelog
- Backport to 1.20.1 and 1.20.2
- OP Player command context
- This allows players to run a command as administrator (
SERVERexecute as @pbegone!) /commander givecan now give items to another player (or multiple players, like/give)- From now on, [Placeholders API](https://pb4.eu/#placeholder-api) will not be included with this mod and won't be needed for basic functionality
- If the player's hand is empty when trying to create a Commander Item (without a specified item), the command will now throw an error.
- Improved error logging
- Very minor code refactoring
- This mod now suggests [Placeholders API](https://pb4.eu/#placeholder-api) and [LuckPerms](https://luckperms.net/)
- [Updated documentation](https://github.com/CamperSamu/ItemCommander/blob/1.20.4/README.md)
- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.5.0...1.6.0
This update brings the mod to 1.20.4, allows Commander Items to be saved and loaded via
/commander save & /commander give and fixes an issue with Custom Item NBTs not working inside the /commander create command!- GitHub Release**: https://github.com/CamperSamu/ItemCommander/releases/tag/1.5.0
- Full Changelog**: https://github.com/CamperSamu/ItemCommander/compare/1.4.0...1.5.0
- Full Changelog:* https://github.com/CamperSamu/ItemCommander/compare/1.1.0...1.3.0
@p and @s in commands and now items on lecterns are supported!- Full Changelog*: https://github.com/CamperSamu/ItemCommander/compare/1.0.0...1.1.0