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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations