我正在尝试使用 ProtocolLib 通过数据包向玩家发送彩色红石粒子。我在谷歌上搜索到要使它们着色,我需要使用 offset
参数作为 RGB 系统。但是,它没有按预期工作;粒子仍然是红色或具有随机颜色(见下文),并且 offset
仍然用作来自给定位置的每个粒子的随机化器。
我的代码:
PacketContainer packet = new PacketContainer(PacketType.Play.Server.WORLD_PARTICLES);
packet.getModifier().writeDefaults();
packet.getParticles().write(0, Particle.REDSTONE);
float x = (float) loc.getX();
float y = (float) loc.getY() + 3;
float z = (float) loc.getZ();
float red = 0;
float green = 0;
float blue = 1;
packet.getFloat().write(0, x).write(1, y).write(2, z); // Location
packet.getFloat().write(3, red).write(4, green).write(5, blue); // Offset
packet.getFloat().write(6, 0F); // Particle data ?
packet.getIntegers().write(0, 1); // Amount
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
try {
for (Player player : getters) manager.sendServerPacket(player, packet);
} catch (Exception ex) {ex.printStackTrace();}
我尝试更改数量
和粒子数据
。如果粒子 data
为 0
,则粒子为红色,在其他情况下,最多 1
粒子为随机着色。
我正在使用 ProtocolLib 4.3.0 和 Spigot 1.12.2
最佳答案
我解决了我的问题,要生成彩色真正的红石粒子必须有 3 件事:
数量
必须是0
数据
必须是1
- 红色分量(x 偏移量)必须是
x - 1
(因为这个分量在插入数据包之前自动增加 1)
关于java - 红石粒子不会改变它们的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47969668/