Fix AreaEffectCloudEmulator spawn logic on 1.20.5+ servers (#83)

This commit is contained in:
Dreeam 2024-07-19 15:06:35 +08:00 committed by GitHub
parent 081c9c9a6f
commit 3030d07fec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,7 @@
package com.viaversion.viarewind.legacysupport.feature;
import com.viaversion.viarewind.legacysupport.util.NMSUtil;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
@ -45,6 +46,9 @@ public class AreaEffectCloudEmulator implements Listener {
effectClouds.forEach(cloud -> {
final Location location = cloud.getLocation();
final float radius = cloud.getRadius();
final Object data = NMSUtil.NEWER_THAN_V1_20_5
? cloud.getColor()
: null;
float area = (float) Math.PI * radius * radius;
@ -67,7 +71,8 @@ public class AreaEffectCloudEmulator implements Listener {
cloud.getParticle(),
location.getX() + f3, location.getY(), location.getZ() + f6,
0,
r / 255f, g / 255f, b / 255f
r / 255f, g / 255f, b / 255f,
data
);
});
}

View File

@ -34,6 +34,8 @@ public class NMSUtil {
public static String nmsVersionPackage;
private static Field playerConnectionField;
public static final boolean NEWER_THAN_V1_20_5 = BukkitPlugin.getInstance().getServerProtocol().newerThanOrEqualTo(ProtocolVersion.v1_20_5);
static {
if (BukkitPlugin.getInstance().getServerProtocol().olderThan(ProtocolVersion.v1_17)) {
nmsVersionPackage = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];