Origins: Powerful Powers
» Entity actions » Spawn fake entity

Spawn fake entity

origins-powerful-powers:spawn_fake_entityentity action

Spawns a fake entity: a mob that only exists on the screens of the players allowed to see it. The server never adds it to the world, so it takes no real damage, collides with nothing, and can't change the world. Use it for hallucinations, private spirits, or jump scares.

FieldTypeDefaultDescription
entity_typeIdentifierrequiredWhat it looks like, like minecraft:zombie. Any type works. minecraft:player makes a fake player. nbt can change its look.
x, y, zDouble0Where it spawns.
relative_toString"self"self: x/y/z are an offset from the entity running the action, like ~ ~ ~. world: they're world coordinates.
behaviorString"neutral", "stationary" for fake playersHow it moves. See below.
lifetimeIntegerrequiredTicks until it disappears.
viewer_conditionBi-entity conditionnoneWho can see it. The actor is the viewing player and the target is the entity that spawned it. Left out: every player nearby.
recheckBooleantruetrue: viewer_condition is checked again every half second, so players can start or stop seeing it. false: each player's result is kept from the first check.
idIntegerassignedA number, 1 or more, to remove this fake entity by later with despawn_fake_entity. Left out: the next free id is assigned, and a pack can't read it back. Ids are unique across the server. Spawning with a live id replaces that fake entity.
playerStringnoneOnly with entity_type: "minecraft:player": the username of the player the fake player looks like.
nbtStringnoneRaw SNBT merged onto the fake entity when it spawns, like /summon's: armor, held items, a custom name, a baby zombie. See Fake entity NBT.

Behavior. Mobs walk with their vanilla pathfinding and physics, with their normal AI switched off. Fake players move the same way. behavior sets what they do:

behaviorWhat it does
hostileChases the nearest player who can see it, within the mob's follow range.
neutralWanders around and glances at nearby viewers.
passiveWanders like neutral until a viewer hits it, then chases that player.
stationaryStays put and turns its head to look at nearby viewers.
  • A chasing fake entity stops at melee reach and stands facing its target. It follows again if they move away.
  • Hitting a fake entity does no damage, knockback or sound. It makes a passive fake entity chase you and runs its spawner's action_on_fake_entity_hit powers.
  • Non-mob types, such as armor stands, stay where they spawned. Walking mobs move best. Flying or hopping mobs (bats, slimes) may move poorly.
  • A fake entity is silent for everyone.
  • It can't attack, shoot, explode, drop items, trample crops, press pressure plates, push entities or set off sculk sensors.
  • It disappears when its lifetime runs out or the server stops. It only moves while its chunk is loaded.
  • With a viewer_condition, once its spawner logs out or unloads, no new viewers can see it.

Example: "Stalker". Every 30 seconds, a zombie only you can see appears 12 blocks behind you and chases you for up to 10 seconds.

json
{
  "type": "origins:action_over_time",
  "interval": 600,
  "entity_action": {
    "type": "origins-powerful-powers:spawn_fake_entity",
    "entity_type": "minecraft:zombie",
    "x": 0,
    "y": 0,
    "z": -12,
    "behavior": "hostile",
    "lifetime": 200,
    "viewer_condition": {
      "type": "origins:equal"
    }
  }
}

origins:equal is true when the actor and target are the same entity, so only the spawner sees it. The offset is in world directions.

Fake players

Set entity_type to minecraft:player and a fake entity looks like a player.

json
{
  "type": "origins-powerful-powers:spawn_fake_entity",
  "entity_type": "minecraft:player",
  "player": "Notch",
  "id": 50,
  "x": 0,
  "y": 0,
  "z": 2,
  "lifetime": 200
}
  • The skin is looked up by username, from the server's cache, then Mojang. The lookup runs in the background, so the first time a name is used the fake entity may show the default skin for a moment. A server with no internet keeps the default skin.
  • It's hidden from the tab list and has no name tag.
  • It's stationary by default. Any other behavior makes it walk, chase and wander like a mob.
  • How it walks: an unseen husk does the pathfinding and the fake player copies it. It moves at a husk's speed, climbs what a husk climbs, and can't open doors. Viewers see the normal player walk animation.
  • Its username and UUID are made up, so it never clashes with the real account.

From a command: /opp fakeentity spawn, or /opp fakeentity player for a fake player.

Fake entity NBT

nbt is a string of SNBT, the format /summon and /data merge take. OPP merges it onto the new entity exactly as written, unchecked. The keys are vanilla's for that entity type. A tag that fails to load is logged and the fake entity spawns without it. A wrong key or type is usually ignored silently, as in /summon.

A skeleton in a gold helmet holding a bow:

json
{
  "type": "origins-powerful-powers:spawn_fake_entity",
  "entity_type": "minecraft:skeleton",
  "lifetime": 200,
  "nbt": "{ArmorItems:[{},{},{},{id:\"minecraft:golden_helmet\",Count:1b}],HandItems:[{id:\"minecraft:bow\",Count:1b},{}]}"
}

ArmorItems runs feet, legs, chest, head. HandItems is main hand, then offhand.

A fake player's items go in its inventory, by slot number: 0 to 8 hotbar (SelectedItemSlot picks the held one, default 0), 100 to 103 feet to head, -106 offhand:

json
"nbt": "{Inventory:[{Slot:0b,id:\"minecraft:diamond_sword\",Count:1b},{Slot:103b,id:\"minecraft:carved_pumpkin\",Count:1b},{Slot:-106b,id:\"minecraft:shield\",Count:1b}]}"
  • x/y/z place it. Pos in the NBT is ignored. Rotation is used if given. Otherwise it faces the way the spawner faces.
  • Some keys are always overridden: UUID, Invulnerable, Silent, PersistenceRequired and CanPickUpLoot.
  • Movement keys take effect and can fight its behavior. NoAI:1b stops a mob walking, and NoGravity:1b leaves it floating.
  • Equipment changes after spawning show. Each tick OPP sends viewers any changed armor or held item, so origins:equipped_item_action in a fake_entity_action, or /opp fakeentity run <id> item replace entity @s armor.head with …, re-equips a live fake entity. /data merge refuses players, so use item replace for fake players.

Reaching fake entities

A fake entity isn't in the world, so selectors like @e, area_of_effect, raycasts and mob targeting miss it. These OPP types reach it directly.

TypeKindWhat it does
fake_entity_actionentity actionruns actions on your fake entities, or one by id
fake_entityentity conditioncounts your fake entities, or checks one by id
action_on_fake_entity_hitpowerruns when a viewer hits one of your fake entities
/opp fakeentity runcommandruns a command as a fake entity (@s)

What works on a fake entity:

  • Looks reach its viewers on the next tick: glowing, invisibility, being on fire, a custom name, pose, other entity data, and armor and held items.
  • Movement: velocity (origins:add_velocity), facing, and teleporting in a command (tp @s). A walking fake entity may walk off again right away.
  • Effects apply and show. They wear off on mobs. On fake players they last forever, because a fake player doesn't tick. Remove them with origins:clear_effect.
  • It can't be hurt or killed, even by /kill, because dying would drop real loot. Remove it with despawn_fake_entity.
  • It can't hold powers. Powers only run on entities that tick in the world, so a fake entity is only ever the target.
  • Particles, sounds and summons are real. An action that spawns particles, plays a sound or summons an entity at the fake entity does it for everyone.
  • An action that fails on a fake entity is skipped and logged.