Search in sources :

Example 6 with MapStorage

use of net.minecraft.world.storage.MapStorage in project RuneCraftory by Flemmli97.

the class WeatherData method get.

public static WeatherData get(World world) {
    MapStorage storage = world.getMapStorage();
    WeatherData data = (WeatherData) storage.getOrLoadData(WeatherData.class, id);
    if (data == null) {
        data = new WeatherData();
        storage.setData(id, data);
    }
    return data;
}
Also used : MapStorage(net.minecraft.world.storage.MapStorage)

Example 7 with MapStorage

use of net.minecraft.world.storage.MapStorage in project Crossroads by Crossroads-Development.

the class FieldWorldSavedData method get.

public static FieldWorldSavedData get(World world) {
    MapStorage storage = world.getPerWorldStorage();
    FieldWorldSavedData data = (FieldWorldSavedData) storage.getOrLoadData(FieldWorldSavedData.class, FIELDS_ID);
    if (data == null) {
        data = new FieldWorldSavedData();
        storage.setData(FIELDS_ID, data);
    }
    data.setDirty(true);
    return data;
}
Also used : MapStorage(net.minecraft.world.storage.MapStorage)

Example 8 with MapStorage

use of net.minecraft.world.storage.MapStorage in project Crossroads by Crossroads-Development.

the class PrototypeWorldSavedData method markDirty.

/**
 * Also causes the dimension to load in order to force the data to save. Use instead of setDirty(true).
 */
@Override
public void markDirty() {
    setDirty(true);
    WorldServer world = DimensionManager.getWorld(ModDimensions.PROTOTYPE_DIM_ID);
    if (world == null) {
        DimensionManager.initDimension(ModDimensions.PROTOTYPE_DIM_ID);
        world = DimensionManager.getWorld(ModDimensions.PROTOTYPE_DIM_ID);
    }
    MapStorage storage = world.getPerWorldStorage();
    storage.setData(PROTOTYPE_ID, this);
}
Also used : WorldServer(net.minecraft.world.WorldServer) MapStorage(net.minecraft.world.storage.MapStorage)

Example 9 with MapStorage

use of net.minecraft.world.storage.MapStorage in project Crossroads by Crossroads-Development.

the class PrototypeWorldSavedData method get.

/**
 * DOES NOT call markDirty() by default unless just being created, modifiers should call it manually.
 * Do not call until after the overworld has been initialized.
 * Designed to lose all data if the prototype dimension file is deleted.
 * @param forceInitWorld If true, this will init (load) the prototype world even if this doesn't have to.
 * @return The PrototypeWorldSavedData instance.
 */
public static PrototypeWorldSavedData get(boolean forceInitWorld) {
    if (instance != null) {
        if (forceInitWorld && DimensionManager.getWorld(ModDimensions.PROTOTYPE_DIM_ID) == null) {
            DimensionManager.initDimension(ModDimensions.PROTOTYPE_DIM_ID);
        }
        return instance;
    }
    WorldServer world = DimensionManager.getWorld(ModDimensions.PROTOTYPE_DIM_ID);
    if (world == null) {
        DimensionManager.initDimension(ModDimensions.PROTOTYPE_DIM_ID);
        world = DimensionManager.getWorld(ModDimensions.PROTOTYPE_DIM_ID);
    }
    MapStorage storage = world.getPerWorldStorage();
    PrototypeWorldSavedData data = (PrototypeWorldSavedData) storage.getOrLoadData(PrototypeWorldSavedData.class, PROTOTYPE_ID);
    if (data == null) {
        data = new PrototypeWorldSavedData();
        storage.setData(PROTOTYPE_ID, data);
        data.setDirty(true);
    }
    instance = data;
    return data;
}
Also used : WorldServer(net.minecraft.world.WorldServer) MapStorage(net.minecraft.world.storage.MapStorage)

Example 10 with MapStorage

use of net.minecraft.world.storage.MapStorage in project ElementalSorcery by Yuzunyannn.

the class ElfPostOffice method getPostOffice.

/**
 * 获取邮局对象
 */
public static ElfPostOffice getPostOffice(World world) {
    MapStorage storage = world.getMapStorage();
    WorldSavedData worldSave = storage.getOrLoadData(ElfPostOffice.class, "ESPostOffice");
    if (worldSave == null) {
        worldSave = new ElfPostOffice("ESPostOffice");
        storage.setData("ESPostOffice", worldSave);
    }
    return (ElfPostOffice) worldSave;
}
Also used : WorldSavedData(net.minecraft.world.storage.WorldSavedData) MapStorage(net.minecraft.world.storage.MapStorage)

Aggregations

MapStorage (net.minecraft.world.storage.MapStorage)45 ScoreboardSaveData (net.minecraft.scoreboard.ScoreboardSaveData)5 ServerScoreboard (net.minecraft.scoreboard.ServerScoreboard)5 VillageCollection (net.minecraft.village.VillageCollection)5 AdvancementManager (net.minecraft.advancements.AdvancementManager)2 FunctionManager (net.minecraft.advancements.FunctionManager)2 WorldServer (net.minecraft.world.WorldServer)2 MapData (net.minecraft.world.storage.MapData)2 WorldSavedData (net.minecraft.world.storage.WorldSavedData)2 LootTableManager (net.minecraft.world.storage.loot.LootTableManager)2 DummyWorld (com.cleanroommc.multiblocked.util.world.DummyWorld)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 Nonnull (javax.annotation.Nonnull)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 WorldSavedDataCallableSave (net.minecraft.world.storage.WorldSavedDataCallableSave)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 NetworkData (sonar.flux.network.NetworkData)1