Merge pull request #1136 from ludovic111/fix/summon-tracked-ids
🤖 Agent: merged. Verify passes. B5's local integration of all its PRs on main: parity --changed 102/102, plus lan_e2e (flakes listed in FEATURES.md LATER 4l).
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user