From 3c239e8af0f52571786b7d6edc0f1d02bc1d9951 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 16 Feb 2026 13:22:32 -0500 Subject: [PATCH] Defer even firing until after unit is added --- core/src/mindustry/world/blocks/units/UnitAssembler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/world/blocks/units/UnitAssembler.java b/core/src/mindustry/world/blocks/units/UnitAssembler.java index ac3c054c25..ab6488e84b 100644 --- a/core/src/mindustry/world/blocks/units/UnitAssembler.java +++ b/core/src/mindustry/world/blocks/units/UnitAssembler.java @@ -10,7 +10,7 @@ import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; import arc.util.io.*; -import mindustry.Vars; +import mindustry.*; import mindustry.ai.types.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; @@ -534,7 +534,6 @@ public class UnitAssembler extends PayloadBlock{ unit.set(spawn.x + Mathf.range(0.001f), spawn.y + Mathf.range(0.001f)); unit.rotation = rotdeg(); var targetBuild = unit.buildOn(); - Events.fire(new UnitCreateEvent(unit, this)); //'source' is the target build instead of this building; this is because some blocks only accept things from certain angles, and this is a non-standard payload var payload = new UnitPayload(unit); if(targetBuild != null && targetBuild.team == team && targetBuild.acceptPayload(targetBuild, payload)){ @@ -549,6 +548,8 @@ public class UnitAssembler extends PayloadBlock{ progress = 0f; Fx.unitAssemble.at(spawn.x, spawn.y, rotdeg() - 90f, plan.unit); blocks.clear(); + + Events.fire(new UnitCreateEvent(unit, this)); } @Override