通过 id 或 namespace:id 获取任何类型的自定义物品 (block, item, hat, food..)
CustomStack stack = CustomStack.getInstance("your_item")
if(stack != null)
{
ItemStack itemStack = stack.getItemStack();
}
else
{
//未找到具有该 ID 的自定义物品
}
boolean exists = CustomStack.getInstance("your_item") != null;
ItemsAdder.isCustomItem("your_item");
从游戏中的 ItemStack 获取自定义物品数据
CustomStack stack = CustomStack.byItemStack(myItemStack);
if(stack != null)
{
stack.setUsages(5)//比如设置 剩余使用次数
}
else
{
//不为自定义物品
}
CustomBlock customBlock = CustomBlock.byAlreadyPlaced(block);
if(customBlock != null)
{
//自定义方块
}
else
{
//不为自定义方块
}
CustomBlock customBlock = CustomBlock.getInstance("ruby_ore");
if(customBlock != null) //not needed if you're sure the blocks exists.
{
//自定义方块
customBlock.place(location);
}
else
{
//不为自定义方块
}
通过 id 或 namespace:id 生成自定义生物
CustomMob customMob = CustomMob.spawn("your_item", location)
if(customMob != null)
{
//生成自定义生物
//例如,在控制台显示实体名字
System.out.println(customMob.getName());
}
else
{
//未找到具有该 ID 的自定义生物
}
CustomMob customMob = CustomMob.byAlreadySpawned(entity)
if(customMob != null)
{
//这是一个自定义怪物
//例如,在控制台显示实体名字
System.out.println(customMob.getName());
}
else
{
//不为自定义生物
}
@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()));
}
}
PlayerHudsHolderWrapper playerHudsHolderWrapper = new PlayerHudsHolderWrapper(playerObject);
PlayerQuantityHudWrapper hud = new PlayerQuantityHudWrapper(playerHudsHolderWrapper, "namespace_name:hud_name");
hud.setFloatValue(1f);
PlayerHudsHolderWrapper playerHudsHolderWrapper = new PlayerHudsHolderWrapper(playerObject);
PlayerQuantityHudWrapper hud = new PlayerQuantityHudWrapper(playerHudsHolderWrapper, "namespace_name:hud_name");
hud.setVisible(true);