promotional bannermobile promotional banner

Entity Culling MCBE

A multiplayer/realms friendly addon for MCBE that despawns mobs no player can currently see (out of FOV *and* behind a block) and restores them once a player can see that spot again. This is the same idea as client-side "Entity Culling" mods

A addon for MCBE that despawns mobs no player can currently see (out
of FOV *and* behind a block) and restores them - position, rotation, health,
name tag - once a player can see that spot again. This is the same idea as
client-side "Entity Culling" mods, reimplemented server-side with the
`@minecraft/server` scripting API, since Bedrock add-ons can't hook the
renderer directly.

Built against **Minecraft Bedrock 1.26.40**, using `@minecraft/server` v2.9.0
(stable - no experimental/cheats toggles required).

πŸ“How it works:

1. Every few ticks, each player's nearby entities are scanned
2. Entities are filtered down to ones that are safe to touch: no players,
   no bosses, no villagers/traders, no leashed/ridden/inventoried mobs, and
   (by default) no custom-named entities.
3. For each remaining candidate, we check whether *any* player can see it
   ('fov.js' for the view-cone test, `raycast.js` for the block-occlusion
   test). An entity only counts as hidden if nobody can see it - this is
   deliberately multiplayer-safe.
4. If an entity stays hidden for `cullDelayTicks` in a row (default 15
   ticks, ~0.75s), its state is captured (`entityState.js`) into a small
   persistent database (`database.js`, stored in world dynamic properties)
   and the real entity is removed (`culling.js`).
5. On a second timer, every culled record is checked against current
   player visibility. The moment a player could see that spot again, a
   fresh entity is `/summon`-ed there and the saved state is reapplied
   (`restore.js`).
6. `main.js` just wires all of the above together and registers the
   `/cull:*` commands (`commands.js`).

Architecture:

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     Player(s)       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                         every 2–5 ticks
                               β”‚
                               β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚   Entity Scanner        β”‚
                  β”‚ nearby entities         β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚     FOV Check      β”‚
                    β”‚ Is entity inside   β”‚
                    β”‚ player's FOV?      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                            β”‚YES  β”‚NO
                            β”‚     β”‚
                     keep it     β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Block Raycast β”‚
                         β”‚ Is wall in    β”‚
                         β”‚ front of mob? β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚                β”‚
                       NO wall          WALL
                         β”‚                β”‚
                      keep mob       SAVE STATE
                                          β”‚
                                          β–Ό
                                    DESPAWN MOB
                                          β”‚
                                          β–Ό
                                  Culling Database
                                          β”‚
                            player looks toward area
                                          β”‚
                                          β–Ό
                                   RESTORE ENTITY
                                          β”‚
                                          β–Ό
                                      /summon

πŸ“Commands (optional):

All of these require operator permission and cheats enabled:

| Command | Effect |
|---|---|
| `/cull:on` | Enable the system |
| `/cull:off` | Disable it and immediately restore everything currently culled |
| `/cull:debug` | Toggle chat messages on every cull/restore |
| `/cull:stats` | Show how many entities are currently culled |
| `/cull:distance <blocks>` | Set scan/restore range (8-128) |
| `/cull:fov <degrees>` | Set the view-cone angle (30-180) |
| `/cull:reload` | Reset all settings to defaults |
| `/cull:help` | List these commands in-game |

This was inspired by tr7zw's Entity Culling mod <3.

The Entity Culling MCBE Team

profile avatar
Owner
  • 2
    Projects
  • 1.5K
    Downloads

More from Ixq98o