/summon reports the entities that take their id when first tracked

Primed TNT (and falling blocks, projectiles) spawned from /summon get
their entity id only when first tracked, so the summon found no new id
and answered "Unable to summon entity" though the entity was there and
went off. The summon now also counts those lists, and names the type:
"Summoned new Primed TNT", as vanilla.

Test: a TNT summon in the command execution corpus (world group:
125/126 match vanilla; the one left, /waypoint list, was there before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit dd733684bc8a2efca2b2fa76fc54d6eb48608103)
This commit is contained in:
Ludovic Marie
2026-10-21 04:21:48 +02:00
parent b31cb42242
commit 02ba66b721
2 changed files with 30 additions and 7 deletions
+27 -7
View File
@@ -1612,11 +1612,16 @@ impl Game<'_> {
{
return Err(err("commands.summon.failed.peaceful", &[]));
}
let Some(target) = self.summon_with_nbt(&format!("minecraft:{short}"), pos, &nbt)?
else {
return Err(err("commands.summon.failed", &[]));
let before = self.spawned_mark();
let name = match self.summon_with_nbt(&format!("minecraft:{short}"), pos, &nbt)? {
Some(target) => self.target_name(target),
// Spawned as a kind no command target stands for (primed
// TNT, falling blocks, projectiles): its type's name.
None if self.spawned_mark() != before => {
Text::translate(&format!("entity.minecraft.{short}"), &[])
}
None => return Err(err("commands.summon.failed", &[])),
};
let name = self.target_name(target);
self.feedback(Text::translate("commands.summon.success", &[name]));
return Ok(1);
}
@@ -1669,16 +1674,31 @@ impl Game<'_> {
}
// SummonCommand.createEntity: any other type from an empty compound.
_ => {
let Some(target) = self.summon_with_nbt(&kind, pos, "{}")? else {
return Err(err("commands.summon.failed", &[]));
let before = self.spawned_mark();
name = match self.summon_with_nbt(&kind, pos, "{}")? {
Some(target) => self.target_name(target),
// Spawned as a kind no command target stands for
// (primed TNT, falling blocks, projectiles).
None if self.spawned_mark() != before => {
Text::translate(&format!("entity.minecraft.{short}"), &[])
}
None => return Err(err("commands.summon.failed", &[])),
};
name = self.target_name(target);
}
}
}
self.feedback(Text::translate("commands.summon.success", &[name]));
Ok(1)
}
/// What changes when an entity spawns, kinds that take their id only
/// when first tracked (primed TNT, falling blocks, projectiles)
/// included: a summon compares it before and after.
fn spawned_mark(&self) -> (u32, usize) {
(
self.next_entity,
self.tnts.len() + self.falling.len() + self.creatures.projectiles.len(),
)
}
/// BlockStateArgument -> registry state.
pub(super) fn block_state(&self, b: &BlockInput) -> R<BlockStateId> {
let state = horizon_world::chunk::BlockState {
+3
View File
@@ -568,6 +568,9 @@ def world_misc():
cmd('/summon minecraft:armor_stand 4.5 210 4.5 {NoGravity:1b,Tags:["w"],CustomName:{text:"Stand",color:"blue"}}'),
cmd('/swing @e[tag=w]'),
cmd('/summon minecraft:lightning_bolt 4.5 300 4.5'),
# Primed TNT is no command target in Horizon: still "Summoned new
# Primed TNT" (it explodes high in the air, far from the rest).
cmd('/summon minecraft:tnt 60.5 300 60.5 {fuse:1s}'),
cmd('/summon minecraft:pig 4.5 210 4.5 {NoAI:1b,Invulnerable:1b,Tags:["w"],Passengers:[{id:"minecraft:chicken",NoAI:1b,Tags:["w"]}]}'),
cmd('/summon minecraft:pig 4.5 400 4.5'),
cmd('/summon minecraft:pig 30000000 210 4.5'),