Skip to content

TrainMixin causes issues with other addons #67

@george8188625

Description

@george8188625

@Inject(
at = @At("RETURN"),
method = "write(Lcom/simibubi/create/content/trains/graph/DimensionPalette;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/nbt/CompoundTag;",
cancellable = true
)
private void cpl$write(DimensionPalette dimensions, HolderLookup.Provider registries, CallbackInfoReturnable<CompoundTag> cir) {
CompoundTag nbt = cir.getReturnValue();
nbt.put("CPLData", getLoader().write());
cir.setReturnValue(nbt);
}
@Inject(
at = @At("RETURN"),
method = "read(Lnet/minecraft/nbt/CompoundTag;Lnet/minecraft/core/HolderLookup$Provider;Ljava/util/Map;Lcom/simibubi/create/content/trains/graph/DimensionPalette;)Lcom/simibubi/create/content/trains/entity/Train;",
cancellable = true
)
private static void cpl$read(CompoundTag tag, HolderLookup.Provider registries, Map<UUID, TrackGraph> trackNetworks, DimensionPalette dimensions, CallbackInfoReturnable<Train> cir) {
Train train = cir.getReturnValue();
((CPLTrain) train).setLoader(TrainChunkLoader.read(train, tag.getCompound("CPLData")));
cir.setReturnValue(train);
}

More precisely, my mod (Create: Electro Energetics) doesn't load train data because this mod cancels the method by calling cir.setReturnValue()

You actually don't need to do that, because you're not replacing the object with a new one, you're just modifying it.

The solution:
Remove:

cir.setReturnValue(nbt);

and

cir.setReturnValue(train);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions