mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: add generic invisible entity bundled packet
(cherry picked from commit 90f6a2a3f2)
This commit is contained in:
@@ -58,6 +58,7 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
|
||||
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 final Map<Integer, Number> GENERIC_INVISIBLE_DATA_VALUES = Map.of(0, (byte) 0x20); // For most entities if you just need genericaly invisible
|
||||
private static Entity fakeNmsEntity = new ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, level);
|
||||
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
@@ -542,4 +543,22 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||
for (Player p : sendTo) sendPacket(p, bundlePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendInvisibleEntity(int entityId, EntityType type, Location location, UUID uuid, List<Player> sendTo) {
|
||||
net.minecraft.world.entity.EntityType<?> nmsEntityType = CraftEntityType.bukkitToMinecraft(type);
|
||||
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 ClientboundSetEntityDataPacket dataPacket = getSharedEntityPacket(entityId, GENERIC_INVISIBLE_DATA_VALUES);
|
||||
|
||||
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(List.of(spawnPacket, dataPacket));
|
||||
sendPacket(sendTo, bundlePacket);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user