Java Code Examples for net.minecraft.world.World#getCapability()

The following examples show how to use net.minecraft.world.World#getCapability() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
public static WizardryWorld get(World world) {
	WizardryWorld cap = world.getCapability(capability(), null);
	if (cap == null) {
		throw new IllegalStateException("Missing capability: " + world.getWorldInfo().getWorldName() + "/" + world.provider.getDimensionType().getName());
	}
	return cap;
}
 
Example 2
Source Project: Valkyrien-Skies   File: ValkyrienUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This method basically grabs the {@link IValkyrienSkiesWorldData} capability from the world
 * and then returns the QueryableShipData associated with it
 *
 * @param world The world we are getting the QueryableShipData from
 * @return The QueryableShipData corresponding to the given world
 */
public static QueryableShipData getQueryableData(World world) {
    IValkyrienSkiesWorldData worldData = world
        .getCapability(ValkyrienSkiesMod.VS_WORLD_DATA, null);
    if (worldData == null) {
        // I hate it when other mods add their custom worlds without calling the forge world
        // load events, so I don't feel bad crashing the game here. Although we could also get
        // away with just adding the capability to world instead of crashing.
        throw new IllegalStateException(
            "World " + world + " doesn't have an IVSWorldDataCapability. This is wrong!");
    }
    return worldData.getQueryableShipData();
}