Examples

Custom items

Getting a custom item of any type (block, item, hat, food..) by id or namespace:id

โ€‹CustomStack class docs
CustomStack stack = CustomStack.getInstance("your_item")
if(stack != null)
{
ItemStack itemStack = stack.getItemStack();
}
else
{
//no custom item found with that id
}

Checking if a custom item exists

โ€‹CustomStack class docs
boolean exists = CustomStack.getInstance("your_item") != null;
or you can also use the old method which is not allocating anything.
ItemsAdder.isCustomItem("your_item");

Getting the custom item data from an ingame ItemStack

CustomStack stack = CustomStack.byItemStack(myItemStack);
if(stack != null)
{
stack.setUsages(5)//for example set usages
}
else
{
//not a custom item
}

Custom Blocks

Check if world block is a custom blocks

CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
if(customBlock != null)
{
//custom block
}
else
{
//not a custom block
}

Place custom block

CustomBlock customBlock = CustomBlock.getInstance("ruby_ore");
if(customBlock != null) //not needed if you're sure the blocks exists.
{
//custom block
customBlock.place(location);
}
else
{
//not a custom block
}

Custom mobs

Spawn a custom mob by id or namespace:id

โ€‹CustomMob class docs
CustomMob customMob = CustomMob.spawn("your_item", location)
if(customMob != null)
{
//spawned the custom mob
//example, print the display name in console
System.out.println(customMob.getName());
}
else
{
//no custom mob found with that id
}

Get custom mob by mob already spawned in the world

โ€‹CustomMob class docs
CustomMob customMob = CustomMob.byAlreadySpawned(entity)
if(customMob != null)
{
//it's a custom mob
//example, print the display name in console
System.out.println(customMob.getName());
}
else
{
//this mob is not a custom mob
}

Liquids API

Please also install IALiquids addon to have some test liquids
@EventHandler
void interact(PlayerInteractEvent e)
{
if(e.getAction() == Action.LEFT_CLICK_BLOCK)
{
ItemsAdder.setLiquid("ialiquids:red_water", e.getClickedBlock().getLocation());
}
else if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
{
System.out.println(ItemsAdder.getLiquidName(e.getClickedBlock().getRelative(e.getBlockFace()).getLocation()));
}
}

Changing HUD values with API

Setting a float value in a Frames Hud

PlayerHudsHolderWrapper playerHudsHolderWrapper = new PlayerHudsHolderWrapper(playerObject);
PlayerQuantityHudWrapper hud = new PlayerQuantityHudWrapper(playerHudsHolderWrapper, "namespace_name:hud_name");
hud.setFloatValue(1f);

Making a HUD visible.

PlayerHudsHolderWrapper playerHudsHolderWrapper = new PlayerHudsHolderWrapper(playerObject);
PlayerQuantityHudWrapper hud = new PlayerQuantityHudWrapper(playerHudsHolderWrapper, "namespace_name:hud_name");
hud.setVisible(true);
Copy link
Edit on GitHub
On this page
Custom items
Getting a custom item of any type (block, item, hat, food..) by id or namespace:id
Checking if a custom item exists
Getting the custom item data from an ingame ItemStack
Custom Blocks
Custom mobs
Spawn a custom mob by id or namespace:id
Get custom mob by mob already spawned in the world
Liquids API
Changing HUD values with API
Setting a float value in a Frames Hud
Making a HUD visible.