Move event invocation in case transferAll gets re-used

This commit is contained in:
simibubi 2023-05-10 16:09:03 +02:00
parent c86c10f1b1
commit ee33858ddc
2 changed files with 3 additions and 3 deletions

View file

@ -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);

View file

@ -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);