Home›Java›Mods›[API] NBTInjector
ModsJava

[API] NBTInjector

Java mod listed for Minecraft 1.8–1.10. Download on the author's site.

⬇ Download on Spigot
This API allows you to inject custom and persistent NBT data into entities or tile-entities (blocks).

Note: This needs to be installed as a plugin, so it can inject the entity classes properly. This is also somewhat experimental and not tested with a lot of other plugins, so use this at your own risk.

Example Usage
Code (Java):
Bukkit. getPluginManager ( ). registerEvents ( new Listener ( ) {
    @EventHandler
    public void on (PlayerInteractEntityEvent event ) {
        CompoundTag tag = NBTInjector. getNbtData ( ( Entity ) event. getRightClicked ( ) ) ;
        if (tag != null ) {
            NBTTag countTag = tag. get ( "clickCount" ) ;
            if (countTag == null ) { countTag = new IntTag ( ) ; }
            tag. set ( "clickCount", countTag. getAsInt ( ) + 1 ) ;
        }
    }

    @EventHandler
    public void on (PlayerInteractEvent event ) {
        if (event. getClickedBlock ( ) != null ) {
            CompoundTag tag = NBTInjector. getNbtData (event. getClickedBlock ( ). getState ( ) ) ;
            if (tag != null ) {
                NBTTag countTag = tag. get ( "clickCount" ) ;
                if (countTag == null ) { countTag = new IntTag ( ) ; }
                tag. set ( "clickCount", countTag. getAsInt ( ) + 1 ) ;
            }
        }
    }
}, this ) ;
( https://gist.github.com/InventivetalentDev/b17cc5196afc20b19e70579c5369a85b)
Adds a persistent clickCount tag to entities which increases with every click.


You may also want to check out NBTLibrary, which is already included with this plugin.


Maven
Code (XML):
<repositories>
    <repository>
        <id>inventive-repo </id>
        <url>https://repo.inventivetalent.org/content/groups/public/ </url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.inventivetalent </groupId>
        <artifactId>nbtinjector </artifactId>
        <version>VERSION </version>
    </dependency>
</dependencies>
Links
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

[API] NBTInjector is a free Minecraft Java mod. Compatible with Minecraft 1.8, 1.9, 1.10. Downloaded 475 times (via Spigot). Download it and open it directly in the game.

Explore more