mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: move all packet sending to be async
This commit is contained in:
@@ -97,5 +97,10 @@ public interface NMSPackets {
|
|||||||
|
|
||||||
void sendToastPacket(Player player, ItemStack icon, Component title, Component description);
|
void sendToastPacket(Player player, ItemStack icon, Component title, Component description);
|
||||||
|
|
||||||
|
void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo);
|
||||||
|
|
||||||
|
// The mask here is for is the armorstand is on fire or not.
|
||||||
|
void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo);
|
||||||
|
|
||||||
Object createMountPacket(int entityId, int[] passengerIds);
|
Object createMountPacket(int entityId, int[] passengerIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_20_R4;
|
package me.lojosho.hibiscuscommons.nms.v1_20_R4;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -73,8 +79,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -467,4 +472,40 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_21_R1;
|
package me.lojosho.hibiscuscommons.nms.v1_21_R1;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,10 +59,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -75,8 +81,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -469,4 +474,40 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_21_R2;
|
package me.lojosho.hibiscuscommons.nms.v1_21_R2;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -76,8 +82,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -467,4 +472,40 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_21_R3;
|
package me.lojosho.hibiscuscommons.nms.v1_21_R3;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -76,8 +82,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -502,4 +507,41 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_21_R4;
|
package me.lojosho.hibiscuscommons.nms.v1_21_R4;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -76,8 +82,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -503,4 +508,40 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,33 @@
|
|||||||
package me.lojosho.hibiscuscommons.nms.v1_21_R5;
|
package me.lojosho.hibiscuscommons.nms.v1_21_R5;
|
||||||
|
|
||||||
|
import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NMSCommon {
|
public class NMSCommon {
|
||||||
|
|
||||||
public void sendPacket(Player player, Packet packet) {
|
public void sendPacket(@NotNull Player player, @NotNull Packet packet) {
|
||||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
ServerPlayerConnection connection = serverPlayer.connection;
|
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
connection.send(packet);
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPacket(@NotNull List<Player> players, @NotNull Packet packet) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow(HibiscusCommonsPlugin.getInstance(), (task) -> {
|
||||||
|
for (Player p : players) {
|
||||||
|
ServerPlayer serverPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
ServerPlayerConnection connection = serverPlayer.connection;
|
||||||
|
connection.send(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,16 @@ import java.util.stream.Collectors;
|
|||||||
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.nms.NMSPackets {
|
||||||
|
|
||||||
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
private static ServerLevel level = MinecraftServer.getServer().overworld();
|
||||||
|
private static final Map<Integer, Number> CLOUD_EFFECT_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20, 8, 0f); // For cloud effects
|
||||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
public void sendSharedEntityData(int entityId, Map<Integer, Number> dataValues, List<Player> sendTo) {
|
||||||
|
ClientboundSetEntityDataPacket packet = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
for (Player player : sendTo) sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClientboundSetEntityDataPacket getSharedEntityPacket(int entityId, Map<Integer, Number> dataValues) {
|
||||||
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
List<SynchedEntityData.DataValue<?>> nmsDataValues = dataValues.entrySet().stream().map(entry -> {
|
||||||
int index = entry.getKey();
|
int index = entry.getKey();
|
||||||
Number value = entry.getValue();
|
Number value = entry.getValue();
|
||||||
@@ -73,8 +79,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
};
|
};
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
return new ClientboundSetEntityDataPacket(entityId, nmsDataValues);
|
||||||
for (Player player : sendTo) sendPacket(player, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -500,4 +505,41 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
|||||||
fakeNmsEntity.passengers = ImmutableList.of();
|
fakeNmsEntity.passengers = ImmutableList.of();
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendInvisibleParticleCloud(int entityId, Location location, UUID uuid, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.AREA_EFFECT_CLOUD;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, CLOUD_EFFECT_INVISIBLE_DATA_VALUES);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInvisibleArmorstand(int entityId, Location location, UUID uuid, byte mask, List<Player> sendTo) {
|
||||||
|
net.minecraft.world.entity.EntityType<?> nmsEntityType = net.minecraft.world.entity.EntityType.ARMOR_STAND;
|
||||||
|
double x = location.getX();
|
||||||
|
double y = location.getY();
|
||||||
|
double z = location.getZ();
|
||||||
|
float yaw = location.getYaw();
|
||||||
|
float pitch = location.getPitch();
|
||||||
|
Vec3 velocity = Vec3.ZERO;
|
||||||
|
float headYaw = 0f;
|
||||||
|
|
||||||
|
final ClientboundAddEntityPacket spawnPacket = new ClientboundAddEntityPacket(entityId, uuid, x, y, z, yaw, pitch, nmsEntityType, 0, velocity, headYaw);
|
||||||
|
|
||||||
|
final Map<Integer, Number> dataValues = Map.of(0, mask, 15, (byte) 0x10);
|
||||||
|
final ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, dataValues);
|
||||||
|
|
||||||
|
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||||
|
sendPacket(sendTo, bundlePacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user