private synchronized void uninstallHook(World world) { try { Field field = World.class.getField("loadedEntityList"); Object o = field.get(world); if (o instanceof LoadedEntityList) { ((LoadedTileEntityList) o).unhook(); APerf.LOG.debug("Unhooked from world {}", world.getClass()); } else { APerf.LOG.fatal( "Could not uninstall hook! Looks like another mod changed loadedEntityList in world {}!", world.getClass()); } } catch (Exception e) { APerf.LOG.fatal("Could not uninstall hook for world {}!", world.getClass()); APerf.LOG.catching(e); } }
private synchronized void installHook(World world) { try { Field field = World.class.getField("loadedEntityList"); new LoadedEntityList(world, field); APerf.LOG.debug( "Hooked into world {} (DimID: {})", world.getClass(), world.provider.dimensionId); } catch (Exception e) { APerf.LOG.fatal( "Failed to hook world {} (DimID: {})", world.getClass(), world.provider.dimensionId); APerf.LOG.catching(e); } }