mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-13 22:34:11 +01:00
Merge pull request #4443 from DaComputerNerd717/mc1.18/dev
Add TrackGraph merge event to API
This commit is contained in:
commit
c86c10f1b1
2 changed files with 25 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
package com.simibubi.create.api.event;
|
||||
|
||||
import com.simibubi.create.content.logistics.trains.TrackGraph;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class TrackGraphMergeEvent extends Event{
|
||||
private TrackGraph mergedInto, mergedFrom;
|
||||
|
||||
public TrackGraphMergeEvent(TrackGraph from, TrackGraph into) {
|
||||
mergedInto = into;
|
||||
mergedFrom = from;
|
||||
}
|
||||
|
||||
public TrackGraph getGraphMergedInto() {
|
||||
return mergedInto;
|
||||
}
|
||||
|
||||
public TrackGraph getGraphMergedFrom() {
|
||||
return mergedFrom;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ 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;
|
||||
|
@ -41,6 +42,7 @@ 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 {
|
||||
|
||||
|
@ -247,6 +249,7 @@ 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);
|
||||
|
|
Loading…
Reference in a new issue