From ee33858ddcf9ff91026c0fff6a6e4c829c7a8211 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 10 May 2023 16:09:03 +0200 Subject: [PATCH] Move event invocation in case transferAll gets re-used --- .../simibubi/create/content/logistics/trains/TrackGraph.java | 3 --- .../create/content/logistics/trains/TrackPropagator.java | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraph.java b/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraph.java index cda0e5f2f..897713e94 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraph.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraph.java @@ -19,7 +19,6 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import com.simibubi.create.Create; -import com.simibubi.create.api.event.TrackGraphMergeEvent; import com.simibubi.create.content.logistics.trains.TrackNodeLocation.DiscoveredLocation; import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgeData; @@ -42,7 +41,6 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.common.MinecraftForge; public class TrackGraph { @@ -249,7 +247,6 @@ public class TrackGraph { } public void transferAll(TrackGraph toOther) { - MinecraftForge.EVENT_BUS.post(new TrackGraphMergeEvent(this, toOther)); nodes.forEach((loc, node) -> { if (toOther.addNodeIfAbsent(node)) Create.RAILWAYS.sync.nodeAdded(toOther, node); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/TrackPropagator.java b/src/main/java/com/simibubi/create/content/logistics/trains/TrackPropagator.java index 611787364..75ca5e9eb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/TrackPropagator.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/TrackPropagator.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Set; import com.simibubi.create.Create; +import com.simibubi.create.api.event.TrackGraphMergeEvent; import com.simibubi.create.content.logistics.trains.TrackNodeLocation.DiscoveredLocation; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalPropagator; @@ -16,6 +17,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.MinecraftForge; public class TrackPropagator { @@ -135,6 +137,7 @@ public class TrackPropagator { if (graph == null) graph = other; else { + MinecraftForge.EVENT_BUS.post(new TrackGraphMergeEvent(other, graph)); other.transferAll(graph); manager.removeGraphAndGroup(other); sync.graphRemoved(other);