Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase issues with <gradient> and more than 2 colors #1052

Open
Diego6k9 opened this issue Mar 17, 2024 · 4 comments
Open

Phase issues with <gradient> and more than 2 colors #1052

Diego6k9 opened this issue Mar 17, 2024 · 4 comments

Comments

@Diego6k9
Copy link

Diego6k9 commented Mar 17, 2024

Not possible to animate a seamless gradient animation when using more than 2 colors, gets out of phase after a bit, tried for several hours now. Works perfectly fine when using only 2 colors, but anything more and there seem to be some phase issues when going from -1 to 1 and from 1 to -1.

View post on imgur.com
<script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
public void start() {

        StringBuilder sb = new StringBuilder("<gradient:");

        for (String color : colors) {
            sb.append(color).append(":");
        }
        sb.append(PHASE_PLACEHOLDER).append(">").append(getPlainDisplayName());

        BukkitTask task = Bukkit.getScheduler().runTaskTimer(getPlugin(), () -> {

            ItemMeta meta = getItemStack().getItemMeta();
            meta.displayName(getMiniMessageBuilder().deserialize(sb.toString().replaceAll(PHASE_PLACEHOLDER, String.valueOf(phase))));
            getPlayer().sendMessage("§a" + phase);

            getItemStack().setItemMeta(meta);
            getInventory().setItem(getSlot(), getItemStack());

            if (animationDirection == AnimationDirection.LEFT_TO_RIGHT) {
                phase = (phase - getAnimationSpeed() < -1) ? 1 : phase - getAnimationSpeed();
            } else {
                phase = (phase + getAnimationSpeed() > 1) ? -1 : phase + getAnimationSpeed();
            }

        }, 1L, 2L);

        getRunningAnimations().put(getPlayer().getUniqueId(), task);

    }
@zml2008
Copy link
Member

zml2008 commented Mar 17, 2024

Which version of adventure?

@Diego6k9
Copy link
Author

Which version of adventure?

Using the one included in the latest paper 1.20.4 version

@zml2008
Copy link
Member

zml2008 commented Mar 17, 2024

That's not a version number

@Diego6k9
Copy link
Author

That's not a version number

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants