Skip to content

Entity shadows in shader packs

Lesson 14.8

With a shader pack, Celestial draws every entity into the pack’s shadow map, so mobs, dropped items, falling blocks and your mod’s models cast real shadows in the sun. (Without a pack nothing changes: entities are lit like in vanilla, and the round shadows under them are the vanilla Entity Shadows option.) Sometimes a mod wants a mob without a shadow: a ghost, a hologram, an effect entity. The details are in the guide Entity Lighting and Shadows.

A whole entity type

cl.on("lifecycle.client_setup", function()
  cl.render.set_type_casts_shadow("my_mod:ghost", false)
end)

One entity

e:set_casts_shadow(value) takes true (always casts), false (never) or nil (back to its type’s setting):

cl.on("entity.synced", function(ev)
  if ev.key == "my_mod:cloaked" then
    ev.entity:set_casts_shadow(ev.entity:synced("cloaked") and false or nil)
  end
end)

What the player chose

The player can switch entity shadows off in Video Settings > Shader Entity Shadows; then nothing casts, whatever a mod says. cl.render.entity_shadows_setting() tells you the setting, and cl.render.entity_shadows_active() whether a shader pack draws entity shadows right now (for example to skip a fake shadow decal of your own).

Try it

Your mod has a “lantern spirit” mob (my_mod:lantern_spirit) that glows. Make it never cast a shadow, but let one special spirit with the synced value my_mod:solid cast one.

Show a solution
cl.on("lifecycle.client_setup", function()
  cl.render.set_type_casts_shadow("my_mod:lantern_spirit", false)
end)

cl.on("entity.synced", function(ev)
  if ev.key == "my_mod:solid" then
    ev.entity:set_casts_shadow(ev.entity:synced("solid") and true or nil)
  end
end)

Recap: cl.render.set_type_casts_shadow(type, false) for a type, e:set_casts_shadow(true | false | nil) for one entity, cl.render.entity_shadows_setting() / entity_shadows_active() to ask.