Skip to content

stewbasic/CommandItem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Item

About

This mod adds transportable, single use command blocks.

Motivation

The vanilla command block allows map makers a lot of flexibility by triggering arbitrary commands in response to redstone signals. However in some cases it would be more natural to give the player a usable item to execute the command. Some possible uses:

  • A teleport scroll.
  • An instant buff item.
  • A customized mob spawning egg.

I hoped such an item could be added to vanilla. Indeed this has been suggested before, and also requested as a mod.

This mod can act as a proof of concept to support a suggested addition to vanilla. It also should support basic functionality when running on a server with vanilla clients connected (doesn't work yet).

Command slate

A blank command slate can be configured with commands and options, and used to produce command runes.

/give @p command_item:command_slate

Right click the slate to open a GUI. Enter the commands, title and description.

Entering commands

Entering title and description

Customize options such as whether the item is consumed on use. Note: In creative mode the rune is never consumed.

Selecting options

Shift-click an item to set the appearance of the rune.

Choosing the rune appearance

Finally take runes from the output slot.

Producing the rune

Right click to use the rune.

Using the rune

Creating runes with NBT tags

Instead of using the GUI, you can also use /give to make runes. Examples:

/give @p command_item:command_rune 1 0 {cmd:{cmd:["tp @p ~ ~3 ~","tell @p Up!"]}}
/give @p command_item:command_rune 1 0 {cmd:{cmd:["time set 1000"],keep:1,duration:20},mimicItem:{id:"minecraft:clock"}}
/give @p command_item:command_rune 1 0 {cmd:{cmd:["particle heart ~ ~2 ~ .4 .4 .4 1 3"],keep:1,Name:"{text:Love,color:red,bold:true}"}}
/give @p command_item:command_rune 9 0 {cmd:{cmd:["give @p minecraft:diamond_sword"],stacksize:9},mimicItem:{id:"minecraft:diamond"}}

Crafting recipes

A configured command slate can be crafted directly into a rune.

Crafting a configured slate

A blank slate can be crafted with a book (containing commands, description and options) and another item (to determine the appearance).

Example book

Crafting recipe

Credits

Many resources were useful when writing this mod; some of them are

Future improvements

This section is essentially notes for myself...

  • Add interrupt option (on damage taken)
  • Allow vanilla client (ideas)
    • Option 1: Intercept packets to client and translate mod items to vanilla items (with custom NBT)
    • Option 2: Add "vanilla mode" mod configuration option, use vanilla items with NBT on client and server Shift-click doesn't combine stacks correctly (NBT mismatch on SP server)

About

Minecraft forge mod adding items with customizable commands.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages