Skip to content

CMI Hologram API changed #64

Description

@ChimpGamer

Hello, I've been trying to figure out for a while now how to migrate to the new CMI Hologram API.

This is the code I've been using before version 9.8.6.0:

        val hologram = CMIHologram(UUID.randomUUID().toString(), CMILocation(displayLocation))
        val enchanted = itemStack.enchantments.isNotEmpty()

        hologram.addLine("ICON:${itemStack.type}" + if (enchanted) "%enchanted%" else "")
        hologram.updateIntervalSec = -1.0 // Disable updating of the hologram
        hologram.showRange = 20
        hologram.update()

        locationToHologram[containerLocation] = hologram
        CMI.getInstance().hologramManager.addHologram(hologram)

        val page = hologram.getPage(1) ?: return
        val line = page.lines[0] ?: return
        line.item = CMIItemStack(itemStack)

But this unfortunately no longer works after version 9.8.6.0 and there is NO migration guide available.

I've managed to get "something" working with this code:

        val hologram = CMIHologram(UUID.randomUUID().toString(), displayLocation)
        hologram.type = CMIHologramType.ArmorStand
        hologram.isSaveToFile = false // <- deprecated

        val enchanted = itemStack.enchantments.isNotEmpty()

        val lineIcon = CMIHologramLineIcon("ICON:${itemStack.type}" + if (enchanted) "%enchanted%" else "")
        lineIcon.setIcon(itemStack)
        hologram.pages.addLine(lineIcon.iconText)
        hologram.settings.apply {
            visibilityRange = 20
            updateIntervalTicks = 0
        }
        hologram.update()

        destroyDuplicates(displayLocation)
        locationToHologram[containerLocation] = hologram
        CMI.getInstance().hologramManager.add(hologram)

But I'm unsure if this code is the proper way of using the api since isSaveToFile is deprecated.

Is anyone able to provide support with this?

Thanks in advance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions