Search in sources :

Example 6 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project ImmersiveEngineering by BluSunrize.

the class ClientEventHandler method onResourceManagerReload.

@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
    TextureMap texturemap = Minecraft.getMinecraft().getTextureMapBlocks();
    for (int i = 0; i < ClientUtils.destroyBlockIcons.length; i++) ClientUtils.destroyBlockIcons[i] = texturemap.getAtlasSprite("minecraft:blocks/destroy_stage_" + i);
    ImmersiveEngineering.proxy.clearRenderCaches();
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap)

Example 7 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project AgriCraft by AgriCraft.

the class IconHelper method findMatches.

/**
     * Pure hack to find icons...
     *
     * @param name
     * @return
     */
public static Deque<String> findMatches(String name) {
    name = name.toLowerCase();
    if (findCache.containsKey(name)) {
        return findCache.get(name);
    }
    Deque<String> matches = new ArrayDeque<>();
    try {
        Field f = TextureMap.class.getDeclaredField("mapRegisteredSprites");
        f.setAccessible(true);
        Map<String, TextureAtlasSprite> textureMap = (Map<String, TextureAtlasSprite>) f.get(Minecraft.getMinecraft().getTextureMapBlocks());
        for (String e : textureMap.keySet()) {
            if (e.contains(name)) {
                matches.add(e);
            }
        }
        if (!findCache.isEmpty()) {
            findCache.put(name, matches);
        } else {
            matches.add("missingno");
        }
    } catch (NoSuchFieldException | IllegalAccessException e) {
        // Shoot
        AgriCore.getLogger("agricraft").debug("Something strange is going on with the Minecraft TextureMap!");
    } catch (SecurityException e) {
        AgriCore.getLogger("agricraft").debug("Locked out of TextureMap...");
    }
    return matches;
}
Also used : Field(java.lang.reflect.Field) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) TextureMap(net.minecraft.client.renderer.texture.TextureMap) HashMap(java.util.HashMap) Map(java.util.Map) ArrayDeque(java.util.ArrayDeque)

Example 8 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project Railcraft by Railcraft.

the class FluidModelRenderer method loadTextures.

@SubscribeEvent
public void loadTextures(TextureStitchEvent.Pre event) {
    final TextureMap map = event.getMap();
    FluidRegistry.getRegisteredFluids().values().forEach(f -> {
        map.registerSprite(f.getFlowing());
        map.registerSprite(f.getStill());
    });
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 9 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project Railcraft by Railcraft.

the class JSONModelRenderer method bakeModels.

@SubscribeEvent
public void bakeModels(TextureStitchEvent.Post event) {
    final TextureMap map = event.getMap();
    for (Map.Entry<ResourceLocation, IModel> model : models.entrySet()) {
        IBakedModel bakedModel = model.getValue().bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, l -> l == null ? RenderTools.getMissingTexture() : map.getAtlasSprite(l.toString()));
        bakedModels.put(model.getKey(), bakedModel);
    }
}
Also used : IModel(net.minecraftforge.client.model.IModel) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) TextureMap(net.minecraft.client.renderer.texture.TextureMap) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

TextureMap (net.minecraft.client.renderer.texture.TextureMap)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 ResourceLocation (net.minecraft.util.ResourceLocation)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 IModel (net.minecraftforge.client.model.IModel)2 PartInfo (com.bluepowermod.part.PartInfo)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Field (java.lang.reflect.Field)1 ArrayDeque (java.util.ArrayDeque)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ITextureMapPopulator (net.minecraft.client.renderer.texture.ITextureMapPopulator)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 ProgressBar (net.minecraftforge.fml.common.ProgressManager.ProgressBar)1