# Pastebin J0IrYbEz def forWorld[T <: WorldData : ClassTag](world: World)(implicit ctag: ClassTag[T]): T = { val dataClass = ctag.runtimeClass.asInstanceOf[Class[T]] val key = this.classesAndKeys(dataClass) if (key == null) throw new NoSuchElementException( "Data class " + dataClass + " was not registered.") val greyList = this.dimensionGreyList(dataClass) if (greyList == null) throw new NoSuchElementException( "Data class " + dataClass.getCanonicalName + " was not registered.") val dim = world.provider.getDimensionId if (greyList._1.nonEmpty && !greyList._1.contains(dim))return dataClass.cast(null) if (greyList._2.nonEmpty && greyList._2.contains(dim)) return dataClass.cast(null) val storage: MapStorage = world.getPerWorldStorage var data = storage.loadData(dataClass, key) if (data == null) try { data = dataClass.getConstructor(classOf[String]).newInstance(key) dataClass.cast(data).setWorld(world) storage.setData(key, data) } catch { case e: Exception => e.printStackTrace() throw new IllegalStateException( "Could not instantiate " + dataClass.getCanonicalName) } dataClass.cast(data) }