Examples

Custom items

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

CustomStack class docs
1
CustomStack stack = CustomStack.getInstance("your_item")
2
if(stack != null)
3
{
4
ItemStack itemStack = stack.getItemStack();
5
}
6
else
7
{
8
//no custom item found with that id
9
}
Copied!

Checking if a custom item exists

CustomStack class docs
1
boolean exists = CustomStack.getInstance("your_item") != null;
Copied!
or you can also use the old method
1
ItemsAdder.isCustomItem("your_item");
Copied!

Getting the custom item data from an ingame ItemStack

1
CustomStack stack = CustomStack.byItemStack(myItemStack);
2
if(stack != null)
3
{
4
stack.setUsages(5)//for example set usages
5
}
6
else
7
{
8
//not a custom item
9
}
Copied!

Custom Blocks

Check if world block is a custom blocks

1
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
2
if(customBlock != null)
3
{
4
//custom block
5
6
}
7
else
8
{
9
//not a custom block
10
}
Copied!

Place custom block

1
CustomBlock customBlock = CustomBlock.getInstance("ruby_ore");
2
if(customBlock != null) //not needed if you're sure the blocks exists.
3
{
4
//custom block
5
customBlock.place(location);
6
}
7
else
8
{
9
//not a custom block
10
}
Copied!

Custom mobs

Spawn a custom mob by id or namespace:id

CustomMob class docs
1
CustomMob customMob = CustomMob.spawn("your_item", location)
2
if(customMob != null)
3
{
4
//spawned the custom mob
5
6
//example, print the display name in console
7
System.out.println(customMob.getName());
8
}
9
else
10
{
11
//no custom mob found with that id
12
}
Copied!

Get custom mob by mob already spawned in the world

CustomMob class docs
1
CustomMob customMob = CustomMob.byAlreadySpawned(entity)
2
if(customMob != null)
3
{
4
//it's a custom mob
5
6
//example, print the display name in console
7
System.out.println(customMob.getName());
8
}
9
else
10
{
11
//this mob is not a custom mob
12
}
Copied!

Liquids API

Please also install IALiquids addon to have some test liquids
1
@EventHandler
2
void interact(PlayerInteractEvent e)
3
{
4
if(e.getAction() == Action.LEFT_CLICK_BLOCK)
5
{
6
ItemsAdder.setLiquid("ialiquids:red_water", e.getClickedBlock().getLocation());
7
}
8
else if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
9
{
10
System.out.println(ItemsAdder.getLiquidName(e.getClickedBlock().getRelative(e.getBlockFace()).getLocation()));
11
}
12
}
Copied!
Last modified 6mo ago