Skip to content

Commit

Permalink
Fix AreaEffectCloudEmulator spawn logic on 1.20.5+ servers (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Jul 19, 2024
1 parent 081c9c9 commit 3030d07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,6 +46,9 @@ public AreaEffectCloudEmulator(final BukkitPlugin plugin) {
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;

Expand All @@ -67,7 +71,8 @@ public AreaEffectCloudEmulator(final BukkitPlugin plugin) {
cloud.getParticle(),
location.getX() + f3, location.getY(), location.getZ() + f6,
0,
r / 255f, g / 255f, b / 255f
r / 255f, g / 255f, b / 255f,
data
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 3030d07

Please sign in to comment.