mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
chore: move destroy entity packet and spawn entity packet to NMS
This commit is contained in:
@@ -4,6 +4,7 @@ import com.comphenix.protocol.PacketType;
|
|||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||||
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -28,16 +29,7 @@ public class PacketManager {
|
|||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
|
NMSHandlers.getHandler().getPacketHandler().sendSpawnEntityPacket(entityId, uuid, entityType, location, sendTo);
|
||||||
packet.getModifier().writeDefaults();
|
|
||||||
packet.getUUIDs().write(0, uuid);
|
|
||||||
packet.getIntegers().write(0, entityId);
|
|
||||||
packet.getEntityTypeModifier().write(0, entityType);
|
|
||||||
packet.getDoubles().
|
|
||||||
write(0, location.getX()).
|
|
||||||
write(1, location.getY()).
|
|
||||||
write(2, location.getZ());
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void gamemodeChangePacket(
|
public static void gamemodeChangePacket(
|
||||||
@@ -124,9 +116,7 @@ public class PacketManager {
|
|||||||
* @param sendTo The players the packet should be sent to
|
* @param sendTo The players the packet should be sent to
|
||||||
*/
|
*/
|
||||||
public static void sendEntityDestroyPacket(final int entityId, @NotNull List<Player> sendTo) {
|
public static void sendEntityDestroyPacket(final int entityId, @NotNull List<Player> sendTo) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
NMSHandlers.getHandler().getPacketHandler().sendEntityDestroyPacket(IntList.of(entityId), sendTo);
|
||||||
packet.getModifier().write(0, new IntArrayList(new int[]{entityId}));
|
|
||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,11 +124,7 @@ public class PacketManager {
|
|||||||
* @param sendTo The players the packet should be sent to
|
* @param sendTo The players the packet should be sent to
|
||||||
*/
|
*/
|
||||||
public static void sendEntityDestroyPacket(final List<Integer> ids, @NotNull List<Player> sendTo) {
|
public static void sendEntityDestroyPacket(final List<Integer> ids, @NotNull List<Player> sendTo) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
NMSHandlers.getHandler().getPacketHandler().sendEntityDestroyPacket(new IntArrayList(ids), sendTo);
|
||||||
IntArrayList entities = new IntArrayList(new int[]{});
|
|
||||||
for (int id : ids) entities.add(id);
|
|
||||||
packet.getModifier().write(0, entities);
|
|
||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user