🛠️ HammerHelper
If you're on IntelliJ IDEA, consider using HammerHelper to assist with some common code checks and inspections!
Installation
Adding plugin
Press And head back to IntelliJ IDEA.
If this does not work for some reason, add the plugin manually from JetBrains Marketplace HERE!
You might see a similar warning popup:
Click "Yes" to allow running.
If that doesn't work, try searching for HammerHelper on Marketplace manually.
Feature Set
Code inspection
These are your analyzers that highlight potential problems. You can disable them at any point.
HammerLib inspection:
@SimplyRegister(prefix = "")prefix is checked against resource location path characters. (error)@SimplyRegister-annotated classes should be interfaces instead. (weak warning)@SimplyRegister-annotated classes should not contain anonymous classes. (error)@RegistryName("value")values are checked against resource location path characters. (error)@RegistryName("value")names are checked inside the same class for potential duplicate registry names. (error)Resources.location()methods are eligible for resource path validation for [a-z0-9/._-] characters. (error)@RegistryName-d Item constant missing model json file. (weak warning)@RegistryName-d Block constant missing block state json file. (weak warning)@Refannotations are checked for invalid targets.BaseCompatMod compatibility checking with@LoadCompatto ensurecompatTypematches the supertype.IPacketclasses are checked against a set of rules:- Missing empty (no-data) packet constructor. (error)
- Anonymous packet class is not allowed. (error)
- Packet class does nothing. (warning)
- Some of the packet's fields are not serialized. (warning)
- Flowgui XML inspection:
- Detection of missing properties for components.
- Invalid values passed into component properties.
- JS when attributes allow for JS execution with lambda prefix, shows as JS language on Ultimate edition.
Code completion
When hitting Ctrl+Space, IDEA shows a code completion popup.
This section is all about new entries in this popup.
HammerAnimations completion:
@RegistryName-d IAnimationContainer, IGeometryContainer and IParticleContainer are code-completed from files in/assets/modid/bedrock/paths. This takes into account thecreateNoSuffixmethod calls, as well as prefixes provided but@SimplyRegisteron the class. The code completion occurs inside the string literal of the annotation.@LoadCompat- modid is autocompleted from all mod ids found in class path.
FlowGui completion:
@XmlFlowgui'value' completion from resource assets dir (/assets/modid/flowgui/) with option to create a file if its missing;- Flowgui XML completion:
<com>'sclass=attribute is completed from allGuiReaders found in classpath, allowing for seamless integration of any mod adding any custom reader;- Any component with defined class will complete with attributes declared in the
GuiReaderclass with any restrictions applicable by annotations;- Fields must be a static final String with
KEY_as their prefix. Applicable annotations:@AllowedValues(regex[]),@Default("value")/@Required("example"),@AllowJS,@FileReference(regex=regex[N], value=path[N])(example inFlowguiImageReader)
- Fields must be a static final String with
Code references
While holding Ctrl and hovering over elements of a class, you might see them as hyper-links, when clicking on which you see a file said elements are referenced from.
HammerLib references:
@RegistryName-d Item constants have the registry name string literal a reference to item model json file (if it exists)@RegistryName-d Block constants have the registry name string literal a reference to block state map json file (if it exists)@LoadCompatmodid string literal can be a reference to mod class owning the modid (if it exists)
HammerAnimations references:
@RegistryName-d IAnimationContainer, IGeometryContainer and IParticleContainer constants have the registry name string literal a reference to their container json file (if it exists)
Minecraft references:
- Block states can reference model files and texture files.
- Item and block models can reference parent model and texture files.
Inspector suppression
- When using
@SimplyRegisteron a class which has at least one@RegistryNamefield, theunusedinspection on class element will be suppressed, preventing the class and all@RegistryNamefields from being marked as 'unused' (since they are registered into the game!) - When adding
@LoadCompaton a class, theunusedinspection on the class element will be suppressed.
Layered Icons
- Classes annotated with
@SimplyRegisterwill have squares around the class/interface class icon. - Classes implementing
IPacketwill have a plug drawn ontop of the class. - Classes annotated with
@LoadCompatwill have a plug drawn ontop of the class.