Ejemplo n.º 1
0
 public void registerEntity(
     Class<? extends Entity> cls,
     String name,
     int id,
     int updateFrequency,
     boolean sendVelocityUpdates) {
   System.out.printf(
       "%s: BaseMod.registerEntity: %s, \"%s\", %s\n",
       getClass().getSimpleName(), cls.getSimpleName(), name, id);
   EntityRegistry.registerModEntity(
       cls, name, id, /*base*/ this, 256, updateFrequency, sendVelocityUpdates);
 }
Ejemplo n.º 2
0
 private String readVersionFromManifest(Class<?> api) throws IOException {
   String className = api.getSimpleName() + ".class";
   URL resource = api.getResource(className);
   log.trace("get resource for {} -> {} -> {}", new Object[] {className, pathOf(api), resource});
   if (resource == null) return null;
   String version = null;
   String classPath = resource.toString();
   if (classPath.startsWith("jar:"))
     version = version(classPath.substring(0, classPath.lastIndexOf("!") + 1));
   if (version == null && classPath.endsWith(pathOf(api) + ".class"))
     version = version(classPath.substring(0, classPath.length() - pathOf(api).length() - 7));
   if (version == null && classPath.contains("/WEB-INF/"))
     version = version(classPath.substring(0, classPath.lastIndexOf("/WEB-INF/")));
   log.debug("version {} for {} from {}.", version, api, classPath);
   return version;
 }