Search in sources :

Example 1 with SaveWorldEvent

use of org.spongepowered.api.event.world.SaveWorldEvent in project SpongeForge by SpongePowered.

the class SpongeForgeEventFactory method callWorldSaveEvent.

private static SaveWorldEvent callWorldSaveEvent(Event event) {
    SaveWorldEvent spongeEvent = (SaveWorldEvent) event;
    // Since Forge only uses a single save handler, we need to make sure to pass the overworld's handler.
    // This makes sure that mods dont attempt to save/read their data from the wrong location.
    ((IMixinWorld) spongeEvent.getTargetWorld()).setCallingWorldEvent(true);
    ((IMixinEventBus) MinecraftForge.EVENT_BUS).post(new WorldEvent.Save((net.minecraft.world.World) spongeEvent.getTargetWorld()), true);
    ((IMixinWorld) spongeEvent.getTargetWorld()).setCallingWorldEvent(false);
    return spongeEvent;
}
Also used : IMixinEventBus(org.spongepowered.mod.interfaces.IMixinEventBus) IMixinWorld(org.spongepowered.common.interfaces.world.IMixinWorld) LoadWorldEvent(org.spongepowered.api.event.world.LoadWorldEvent) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) UnloadWorldEvent(org.spongepowered.api.event.world.UnloadWorldEvent) WorldEvent(net.minecraftforge.event.world.WorldEvent) SaveWorldEvent(org.spongepowered.api.event.world.SaveWorldEvent) TargetWorldEvent(org.spongepowered.api.event.world.TargetWorldEvent) World(org.spongepowered.api.world.World) IMixinWorld(org.spongepowered.common.interfaces.world.IMixinWorld) SaveWorldEvent(org.spongepowered.api.event.world.SaveWorldEvent)

Aggregations

EntityJoinWorldEvent (net.minecraftforge.event.entity.EntityJoinWorldEvent)1 WorldEvent (net.minecraftforge.event.world.WorldEvent)1 LoadWorldEvent (org.spongepowered.api.event.world.LoadWorldEvent)1 SaveWorldEvent (org.spongepowered.api.event.world.SaveWorldEvent)1 TargetWorldEvent (org.spongepowered.api.event.world.TargetWorldEvent)1 UnloadWorldEvent (org.spongepowered.api.event.world.UnloadWorldEvent)1 World (org.spongepowered.api.world.World)1 IMixinWorld (org.spongepowered.common.interfaces.world.IMixinWorld)1 IMixinEventBus (org.spongepowered.mod.interfaces.IMixinEventBus)1