Java Code Examples for net.minecraft.world.storage.MapStorage#getOrLoadData()

The following examples show how to use net.minecraft.world.storage.MapStorage#getOrLoadData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellDataStorage.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onLoad(WorldEvent.Load event) {
	if (event.getWorld().isRemote)
		return;
	if (event.getWorld().provider.getDimensionType() != StorageDimReg.storageDimensionType)
		return;

	MapStorage storage = event.getWorld().getPerWorldStorage();
	CellSavedWorldData instance = (CellSavedWorldData) storage.getOrLoadData(CellSavedWorldData.class, DATA_NAME);
}
 
Example 2
Source File: CraftServer.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Deprecated
public CraftMapView getMap(short id) {
    MapStorage collection = console.worlds[0].mapStorage;
    MapData worldmap = (MapData) collection.getOrLoadData(MapData.class, "map_" + id);
    if (worldmap == null) {
        return null;
    }
    return worldmap.mapView;
}
 
Example 3
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
public static WorldMana get(World world) {
    MapStorage storage = world.getPerWorldStorage();
    WorldMana instance = (WorldMana) storage.getOrLoadData(WorldMana.class, NAME);

    if (instance == null) {
        instance = new WorldMana();
        storage.setData(NAME, instance);
    }
    return instance;
}
 
Example 4
Source File: CivilizationsWorldSaveData.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public static CivilizationDataAccessor get(World world) {
	MapStorage storage = world.getMapStorage();
	CivilizationsWorldSaveData instance = (CivilizationsWorldSaveData) storage.getOrLoadData(CivilizationsWorldSaveData.class, DATA_NAME);
	if (instance == null) {
		instance = new CivilizationsWorldSaveData();
		storage.setData(DATA_NAME, instance);
	}
	instance.world = world;
	return instance;
}