mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 13:03:48 +01:00
Add track merge event
Can't test it due to java shenanigans, but I think this will work. It's worth noting that this will only be specific to merging as long as transferAll is. If anything else ends up using transferAll, all that needs to happen is adding an intermediate method that posts the event instead of transferAll doing it, then calls transferAll
This commit is contained in:
parent
40f96b0038
commit
6b0af48e99
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