Search in sources :

Example 1 with TextureMap

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

the class ModelLoader method setupModelRegistry.

@Override
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry() {
    isLoading = true;
    loadBlocks();
    loadVariantItemModels();
    missingModel = ModelLoaderRegistry.getMissingModel();
    stateModels.put(MODEL_MISSING, missingModel);
    final Set<ResourceLocation> textures = Sets.newHashSet(ModelLoaderRegistry.getTextures());
    textures.remove(TextureMap.LOCATION_MISSING_TEXTURE);
    textures.addAll(LOCATIONS_BUILTIN_TEXTURES);
    textureMap.loadSprites(resourceManager, new ITextureMapPopulator() {

        public void registerSprites(TextureMap map) {
            for (ResourceLocation t : textures) {
                map.registerSprite(t);
            }
        }
    });
    IBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
    Map<IModel, IBakedModel> bakedModels = Maps.newHashMap();
    HashMultimap<IModel, ModelResourceLocation> models = HashMultimap.create();
    Multimaps.invertFrom(Multimaps.forMap(stateModels), models);
    if (firstLoad) {
        firstLoad = false;
        for (ModelResourceLocation mrl : stateModels.keySet()) {
            bakedRegistry.putObject(mrl, missingBaked);
        }
        return bakedRegistry;
    }
    ProgressBar bakeBar = ProgressManager.push("ModelLoader: baking", models.keySet().size());
    for (IModel model : models.keySet()) {
        bakeBar.step("[" + Joiner.on(", ").join(models.get(model)) + "]");
        if (model == getMissingModel()) {
            bakedModels.put(model, missingBaked);
        } else {
            bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE));
        }
    }
    ProgressManager.pop(bakeBar);
    for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet()) {
        bakedRegistry.putObject(e.getKey(), bakedModels.get(e.getValue()));
    }
    return bakedRegistry;
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ITextureMapPopulator(net.minecraft.client.renderer.texture.ITextureMapPopulator) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ProgressBar(net.minecraftforge.fml.common.ProgressManager.ProgressBar)

Example 2 with TextureMap

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

the class CustomSpriteTest method textureStitch.

@SubscribeEvent
public void textureStitch(TextureStitchEvent.Pre event) {
    DelegateSprite bottom = DelegateSprite.make("bottom", new ResourceLocation("textures/blocks/diamond_block.png"));
    DelegateSprite top = DelegateSprite.make("top", new ResourceLocation("textures/blocks/tnt_side.png"));
    TextureMap textureMap = event.getMap();
    textureMap.setTextureEntry(bottom);
    textureMap.setTextureEntry(top);
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with TextureMap

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

the class IconSupplier method onTextureStitch.

@SubscribeEvent
public void onTextureStitch(TextureStitchEvent.Pre event) {
    TextureMap reg = event.map;
    if (reg.getTextureType() == 0) {
        pneumaticTubeSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side");
        pneumaticTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass");
        pneumaticTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass2");
        pneumaticTubeOpaqueSide = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_side_opaque");
        pneumaticTubeOpaqueNode = reg.registerIcon(Refs.MODID + ":tubes/pneumatic_tube_end_opaque");
        restrictionTubeSide = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side");
        restrictionTubeNodeOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_end_opaque");
        restrictionTubeSideOpaque = reg.registerIcon(Refs.MODID + ":tubes/restriction_tube_side_opaque");
        magTubeSide = reg.registerIcon(Refs.MODID + ":tubes/mag_side");
        magCoilSide = reg.registerIcon(Refs.MODID + ":tubes/mag_casing");
        magCoilFront = reg.registerIcon(Refs.MODID + ":tubes/mag_casing_end");
        magTubeGlass = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced");
        magTubeGlass2 = reg.registerIcon(Refs.MODID + ":tubes/glass_reinforced2");
        acceleratorFront = reg.registerIcon(Refs.MODID + ":machines/accelerator_front");
        acceleratorFrontPowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_front_powered");
        acceleratorSide = reg.registerIcon(Refs.MODID + ":machines/accelerator_side");
        acceleratorSidePowered = reg.registerIcon(Refs.MODID + ":machines/accelerator_side_powered");
        acceleratorInside = reg.registerIcon(Refs.MODID + ":machines/accelerator_inside");
        pneumaticTubeColoring = reg.registerIcon(Refs.MODID + ":tubes/coloring");
        cagedLampFootSide = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_side");
        cagedLampFootTop = reg.registerIcon(Refs.MODID + ":lamps/cage_foot_top");
        cagedLampCageSide = reg.registerIcon(Refs.MODID + ":lamps/cage");
        cagedLampCageTop = reg.registerIcon(Refs.MODID + ":lamps/cage_top");
        cagedLampLampActive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on");
        cagedLampLampInactive = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off");
        cagedLampLampActiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_on_top");
        cagedLampLampInactiveTop = reg.registerIcon(Refs.MODID + ":lamps/cage_lamp_off_top");
        fixtureFootSide = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_side");
        fixtureFootTop = reg.registerIcon(Refs.MODID + ":lamps/fixture_foot_top");
        fixtureLampSideOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on");
        fixtureLampTopOn = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_on_top");
        fixtureLampSideOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off");
        fixtureLampTopOff = reg.registerIcon(Refs.MODID + ":lamps/fixture_lamp_off_top");
        lampOn = reg.registerIcon(Refs.MODID + ":lamps/lamp_off");
        lampOff = reg.registerIcon(Refs.MODID + ":lamps/lamp_on");
        bluestoneTorchOff = reg.registerIcon(Refs.MODID + ":bluestone_torch_off");
        bluestoneTorchOn = reg.registerIcon(Refs.MODID + ":bluestone_torch_on");
        wire = reg.registerIcon(Refs.MODID + ":wire/wire");
        wireInsulation1 = reg.registerIcon(Refs.MODID + ":wire/insulation1");
        wireInsulation2 = reg.registerIcon(Refs.MODID + ":wire/insulation2");
        wireBundledConnection = reg.registerIcon(Refs.MODID + ":wire/bundled_connection");
        wireBundledCross = reg.registerIcon(Refs.MODID + ":wire/bundled_cross");
        wireBundledStraight1 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_1");
        wireBundledStraight2 = reg.registerIcon(Refs.MODID + ":wire/bundled_straight_2");
        wireBundledSide1 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_1");
        wireBundledSide2 = reg.registerIcon(Refs.MODID + ":wire/bundled_side_2");
        gateButton = reg.registerIcon(Refs.MODID + ":gates/components/button");
        siliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_off");
        siliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/silicon_chip_on");
        taintedSiliconChipOff = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_off");
        taintedSiliconChipOn = reg.registerIcon(Refs.MODID + ":gates/components/tainted_silicon_chip_on");
        quartzResonator = reg.registerIcon(Refs.MODID + ":gates/components/resonator");
        gateSolarPanel = reg.registerIcon(Refs.MODID + ":gates/components/solarpanel");
        for (PartInfo i : PartManager.getRegisteredParts()) i.getExample().registerIcons(reg);
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) PartInfo(com.bluepowermod.part.PartInfo) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with TextureMap

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

the class ClientEventHandler method onRenderLiving.

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent.Post event) {
    EntityLivingBase living = event.getEntity();
    if (ClientEventHandler.entityId.contains(String.valueOf(living.getEntityId())) || living.isPotionActive(MPPotions.INFECTED_CRYSTALLIZE)) {
        GlStateManager.disableLighting();
        TextureMap texturemap = this.mc.getTextureMapBlocks();
        TextureAtlasSprite textureatlassprite = texturemap.getAtlasSprite("moreplanets:blocks/infected_crystallize");
        GlStateManager.pushMatrix();
        GlStateManager.translate((float) event.getX(), (float) event.getY(), (float) event.getZ());
        float f = living.width * 1.4F;
        GlStateManager.scale(f, f, f);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder worldrenderer = tessellator.getBuffer();
        float f1 = 0.5F;
        float f2 = 0.0F;
        float f3 = living.height / f;
        float f4 = (float) (living.posY - living.getEntityBoundingBox().minY);
        GlStateManager.rotate(-event.getRenderer().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, 0.0F, -0.3F + (int) f3 * 0.02F);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float f5 = 0.0F;
        int i = 0;
        worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
        while (f3 > 0.0F) {
            event.getRenderer().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            float f6 = textureatlassprite.getMinU();
            float f7 = textureatlassprite.getMinV();
            float f8 = textureatlassprite.getMaxU();
            float f9 = textureatlassprite.getMaxV();
            if (i / 2 % 2 == 0) {
                float f10 = f8;
                f8 = f6;
                f6 = f10;
            }
            worldrenderer.pos(f1 - f2, 0.0F - f4, f5).tex(f8, f9).endVertex();
            worldrenderer.pos(-f1 - f2, 0.0F - f4, f5).tex(f6, f9).endVertex();
            worldrenderer.pos(-f1 - f2, 1.4F - f4, f5).tex(f6, f7).endVertex();
            worldrenderer.pos(f1 - f2, 1.4F - f4, f5).tex(f8, f7).endVertex();
            f3 -= 0.45F;
            f4 -= 0.45F;
            f1 *= 0.9F;
            f5 += 0.03F;
            ++i;
        }
        tessellator.draw();
        GlStateManager.popMatrix();
        GlStateManager.enableLighting();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with TextureMap

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

the class CharsetTweakUnifyColors method recolorTextures.

private void recolorTextures(TextureMap map, String prefix) {
    ResourceLocation source = new ResourceLocation(prefix + "white");
    for (int i = 0; i < 16; i++) {
        String s = ColorUtils.getUnderscoredSuffix(EnumDyeColor.byMetadata(i));
        ResourceLocation target = new ResourceLocation(prefix + s);
        if (prefix.contains("hardened_clay")) {
            BufferedImage image = RenderUtils.getTextureImage(new ResourceLocation("minecraft:blocks/hardened_clay"));
            BufferedImage imageGrayscale = toGrayscale(image);
            int[] imageData = computeMinMaxData(image);
            int[] imageGrayData = computeMinMaxData(imageGrayscale);
            int delta = imageGrayData[3] - imageGrayData[7];
            final float divisor = delta > 5 ? (float) delta / 5.0f : 1.0f;
            final int value2 = colorMultiplier(prefix, EnumDyeColor.byMetadata(i));
            map.setTextureEntry(new PixelOperationSprite(target.toString(), source, (getter, x, y, value) -> {
                int out = 0xFF000000;
                for (int coff = 0; coff < 24; coff += 8) {
                    int v1 = (((imageGrayscale.getRGB(x, y) >> coff) & 0xFF) * 255 / imageGrayData[coff >> 3]) - 0xFF;
                    v1 /= divisor;
                    int v2 = ((value2 >> coff) & 0xFF) + v1;
                    if (v2 < 0)
                        v2 = 0;
                    if (v2 > 255)
                        v2 = 255;
                    int nonTintedOut = (v2 & 0xFF);
                    int tintedOut = nonTintedOut * imageData[8 + (coff >> 3)] / imageData[0 + 3];
                    out |= Math.round((nonTintedOut + tintedOut + (tintedOut / 2)) / 2.5f) << coff;
                }
                return out;
            }));
        } else if (i > 0) {
            // skip white for non-clay
            map.setTextureEntry(new PixelOperationSprite(target.toString(), source, PixelOperationSprite.multiply(colorMultiplier(prefix, EnumDyeColor.byMetadata(i)))));
        }
    }
}
Also used : Arrays(java.util.Arrays) BufferedImage(java.awt.image.BufferedImage) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ModuleProfile(pl.asie.charset.lib.loader.ModuleProfile) ColorUtils(pl.asie.charset.lib.utils.ColorUtils) RenderUtils(pl.asie.charset.lib.utils.RenderUtils) PixelOperationSprite(pl.asie.charset.lib.render.sprite.PixelOperationSprite) EnumDyeColor(net.minecraft.item.EnumDyeColor) Side(net.minecraftforge.fml.relauncher.Side) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) ColorPaletteParser(pl.asie.charset.lib.resources.ColorPaletteParser) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) CharsetModule(pl.asie.charset.lib.loader.CharsetModule) PixelOperationSprite(pl.asie.charset.lib.render.sprite.PixelOperationSprite) ResourceLocation(net.minecraft.util.ResourceLocation) BufferedImage(java.awt.image.BufferedImage)

Aggregations

TextureMap (net.minecraft.client.renderer.texture.TextureMap)53 ResourceLocation (net.minecraft.util.ResourceLocation)29 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)20 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)5 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)5 ITreeGenome (forestry.api.arboriculture.ITreeGenome)5 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)5 Fluid (net.minecraftforge.fluids.Fluid)5 FluidStack (net.minecraftforge.fluids.FluidStack)5 IBlockState (net.minecraft.block.state.IBlockState)4 Minecraft (net.minecraft.client.Minecraft)4 BlockPos (net.minecraft.util.math.BlockPos)4 IBlockAccess (net.minecraft.world.IBlockAccess)4 Map (java.util.Map)3 EnumFacing (net.minecraft.util.EnumFacing)3 World (net.minecraft.world.World)3 TileLeaves (forestry.arboriculture.tiles.TileLeaves)2 BufferedImage (java.awt.image.BufferedImage)2