Search in sources :

Example 1 with WorldSavedData

use of net.minecraft.world.storage.WorldSavedData 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)

Example 2 with WorldSavedData

use of net.minecraft.world.storage.WorldSavedData in project Solar by Martacus.

the class WorldData method getInternal.

private static WorldData getInternal(World world) {
    if (data == null) {
        WorldSavedData savedData = world.loadData(WorldData.class, DATA_TAG);
        if (!(savedData instanceof WorldData)) {
            System.out.println("No WorldData found, creating...");
            WorldData newData = new WorldData(DATA_TAG);
            world.setData(DATA_TAG, newData);
            data = newData;
        } else {
            data = (WorldData) savedData;
            System.out.println("Successfully loaded WorldData!");
        }
    }
    return data;
}
Also used : WorldSavedData(net.minecraft.world.storage.WorldSavedData)

Example 3 with WorldSavedData

use of net.minecraft.world.storage.WorldSavedData in project ManaCraft by Yaossg.

the class MPCache method get.

public static MPCache get(World world) {
    WorldSavedData data = world.getPerWorldStorage().getOrLoadData(MPCache.class, data_id);
    if (data == null) {
        data = new MPCache(data_id);
        world.getPerWorldStorage().setData(data_id, data);
    }
    return (MPCache) data;
}
Also used : WorldSavedData(net.minecraft.world.storage.WorldSavedData)

Example 4 with WorldSavedData

use of net.minecraft.world.storage.WorldSavedData in project Random-Things by lumien231.

the class RTWorldInformation method getInstance.

public static RTWorldInformation getInstance() {
    WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(0);
    if (world != null) {
        WorldSavedData handler = world.getMapStorage().getOrLoadData(RTWorldInformation.class, ID);
        if (handler == null) {
            handler = new RTWorldInformation();
            world.getMapStorage().setData(ID, handler);
        }
        return (RTWorldInformation) handler;
    }
    return null;
}
Also used : WorldServer(net.minecraft.world.WorldServer) WorldSavedData(net.minecraft.world.storage.WorldSavedData)

Example 5 with WorldSavedData

use of net.minecraft.world.storage.WorldSavedData in project Random-Things by lumien231.

the class SpectreHandler method getInstance.

public static SpectreHandler getInstance() {
    WorldServer world = DimensionManager.getWorld(ModDimensions.SPECTRE_ID);
    if (world != null) {
        WorldSavedData handler = world.getPerWorldStorage().getOrLoadData(SpectreHandler.class, ID);
        if (handler == null) {
            handler = new SpectreHandler();
            world.getPerWorldStorage().setData(ID, handler);
        }
        return (SpectreHandler) handler;
    }
    return null;
}
Also used : WorldServer(net.minecraft.world.WorldServer) WorldSavedData(net.minecraft.world.storage.WorldSavedData)

Aggregations

WorldSavedData (net.minecraft.world.storage.WorldSavedData)7 WorldServer (net.minecraft.world.WorldServer)2 MapStorage (net.minecraft.world.storage.MapStorage)2 LinkedList (java.util.LinkedList)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1