gpt4 book ai didi

java - 如何设置横幅的颜色?

转载 作者:行者123 更新时间:2023-12-01 22:28:29 25 4
gpt4 key购买 nike

我试图放置具有特定颜色的横幅,但我总是得到黑色横幅。

Block block;
// ...
block.setType(Material.STANDING_BANNER);
Banner banner = (Banner)block.getState();
banner.setBaseColor(DyeColor.RED);

此代码是否有问题,或者是 Bukkit 错误?

最佳答案

您需要调用Banner.update() .

Attempts to update the block represented by this state, setting it to the new values as defined by this state.

Block block;
// ...
block.setType(Material.STANDING_BANNER);
Banner banner = (Banner)block.getState();
banner.setBaseColor(DyeColor.RED);
banner.update();

关于java - 如何设置横幅的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28245781/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com