9
0
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:
Logan
2025-09-07 21:34:53 -05:00
parent f5a8407b9d
commit 6c2049e1f6
7 changed files with 116 additions and 4 deletions

View File

@@ -61,6 +61,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")
@@ -544,4 +545,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);
}
}