net.minecraft.client.resources.IReloadableResourceManager Java Examples

The following examples show how to use net.minecraft.client.resources.IReloadableResourceManager. 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 check out the related API usage on the sidebar.
Example #1
Source File: MinecraftHook.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public static void onRefreshResources(IReloadableResourceManager resourceManager) {
    boolean usingOldPackTexture = false;
    boolean usingDefaultTexture = true;
    try {
        IResource currentResource = resourceManager.getResource(currentLocation);
        String currentHash = DigestUtils.md5Hex(currentResource.getInputStream());

        InputStream oldStream = SkyblockAddons.class.getClassLoader().getResourceAsStream("assets/skyblockaddons/imperialoldbars.png");
        if (oldStream != null) {
            String oldHash = DigestUtils.md5Hex(oldStream);
            usingOldPackTexture = currentHash.equals(oldHash);
        }

        InputStream barsStream = SkyblockAddons.class.getClassLoader().getResourceAsStream("assets/skyblockaddons/bars.png");
        if (barsStream != null) {
            String barsHash = DigestUtils.md5Hex(barsStream);
            usingDefaultTexture = currentHash.equals(barsHash);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    SkyblockAddons main = SkyblockAddons.getInstance();
    if (main != null) { // Minecraft reloads textures before and after mods are loaded. So only set the variable if sba was initialized.
        main.getUtils().setUsingOldSkyBlockTexture(usingOldPackTexture);
        main.getUtils().setUsingDefaultBarTextures(usingDefaultTexture);
    }
}
 
Example #2
Source File: ClientProxy.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@Override
public void preInit(FMLPreInitializationEvent e) {
    super.preInit(e);
    OBJLoader.INSTANCE.addDomain(ValkyrienSkiesMod.MOD_ID.toLowerCase());
    RenderingRegistry.registerEntityRenderingHandler(PhysicsWrapperEntity.class,
        new PhysicsWrapperEntityRenderFactory());
    // Register events
    MinecraftForge.EVENT_BUS.register(new EventsClient());
    MinecraftForge.EVENT_BUS.register(keyEvents);

    // Register VS Minecraft resource reload listener.
    IReloadableResourceManager mcResourceManager = (IReloadableResourceManager) Minecraft
        .getMinecraft()
        .getResourceManager();

    // When Minecraft reloads resources tell GibsModelRegistry to delete all its caches.
    mcResourceManager.registerReloadListener(GibsModelRegistry::onResourceManagerReload);

    registerAnimations();
}
 
Example #3
Source File: SexyFont.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation") //how to mod 101
public void onInit(FMLInitializationEvent event) {
	IReloadableResourceManager mgr = ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager());
	
	mgr.registerReloadListener((x) -> {
		Minecraft mc = Minecraft.getMinecraft();
		
		mc.fontRenderer = new SexyFontRenderer(
			mc.gameSettings,
			new ResourceLocation("textures/font/ascii.png"),
			mc.renderEngine,
			mc.isUnicode()
		);
	});
}
 
Example #4
Source File: OpenClientProxy.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void preInit() {
	ClientCommandHandler.instance.registerCommand(new CommandConfig("om_config_c", false));
	ClientCommandHandler.instance.registerCommand(new CommandSource("om_source_c", false, OpenMods.instance.getCollector()));
	ClientCommandHandler.instance.registerCommand(new CommandGlDebug());

	if (LibConfig.enableCalculatorCommands) {
		final ICommandComponent commandRoot = new CommandCalcFactory(new File(getMinecraftDir(), "scripts")).getRoot();
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "config"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "eval", "="));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "fun"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "let"));
		ClientCommandHandler.instance.registerCommand(new CommandCalc(commandRoot, "execute"));
	}

	RenderUtils.registerFogUpdater();

	MinecraftForge.EVENT_BUS.register(new BlockSelectionHandler());

	ModelLoaderRegistry.registerLoader(MappedModelLoader.builder()
			.put("with-dependencies", ModelWithDependencies.EMPTY)
			.put("multi-layer", MultiLayerModel.EMPTY)
			.put("variantmodel", VariantModel.EMPTY_MODEL)
			.put("textureditem", TexturedItemModel.INSTANCE)
			.put("stateitem", ItemStateModel.EMPTY)
			.put("eval", EvalModel.EMPTY)
			.put("eval-expand", EvalExpandModel.EMPTY)
			.put("perspective-aware", PerspectiveAwareModel.EMPTY)
			.build(OpenMods.MODID));

	((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(hitboxManager);

	FramebufferBlitter.setup();
}