Search in sources :

Example 26 with TextureMap

use of net.minecraft.client.renderer.texture.TextureMap in project pnc-repressurized by TeamPneumatic.

the class GuiUtils method drawFluid.

public static void drawFluid(final Rectangle bounds, @Nullable FluidStack fluidStack, @Nullable IFluidTank tank) {
    if (fluidStack == null || fluidStack.getFluid() == null) {
        return;
    }
    Fluid fluid = fluidStack.getFluid();
    TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks();
    ResourceLocation fluidStill = fluid.getStill();
    TextureAtlasSprite fluidStillSprite = null;
    if (fluidStill != null) {
        fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
    }
    if (fluidStillSprite == null) {
        fluidStillSprite = textureMapBlocks.getMissingSprite();
    }
    int fluidColor = fluid.getColor(fluidStack);
    int scaledAmount = tank == null ? bounds.height : fluidStack.amount * bounds.height / tank.getCapacity();
    if (fluidStack.amount > 0 && scaledAmount < 1) {
        scaledAmount = 1;
    }
    scaledAmount = Math.min(scaledAmount, bounds.height);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderUtils.glColorHex(fluidColor, 255);
    final int xTileCount = bounds.width / TEX_WIDTH;
    final int xRemainder = bounds.width - xTileCount * TEX_WIDTH;
    final int yTileCount = scaledAmount / TEX_HEIGHT;
    final int yRemainder = scaledAmount - yTileCount * TEX_HEIGHT;
    int yStart = bounds.y + bounds.height;
    if (fluid.getDensity() < 0)
        yStart -= (bounds.height - scaledAmount);
    for (int xTile = 0; xTile <= xTileCount; xTile++) {
        for (int yTile = 0; yTile <= yTileCount; yTile++) {
            int w = xTile == xTileCount ? xRemainder : TEX_WIDTH;
            int h = yTile == yTileCount ? yRemainder : TEX_HEIGHT;
            int x = bounds.x + xTile * TEX_WIDTH;
            int y = yStart - (yTile + 1) * TEX_HEIGHT;
            if (bounds.width > 0 && h > 0) {
                int maskTop = TEX_HEIGHT - h;
                int maskRight = TEX_WIDTH - w;
                drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 100);
            }
        }
    }
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Fluid(net.minecraftforge.fluids.Fluid) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 27 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 28 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 29 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 30 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)

Aggregations

TextureMap (net.minecraft.client.renderer.texture.TextureMap)107 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)54 ResourceLocation (net.minecraft.util.ResourceLocation)49 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)20 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)19 BlockPos (net.minecraft.util.math.BlockPos)13 Fluid (net.minecraftforge.fluids.Fluid)10 FluidStack (net.minecraftforge.fluids.FluidStack)9 Tessellator (net.minecraft.client.renderer.Tessellator)8 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)6 ILeafSpriteProvider (forestry.api.arboriculture.ILeafSpriteProvider)6 ITreeGenome (forestry.api.arboriculture.ITreeGenome)6 EnumFacing (net.minecraft.util.EnumFacing)6 File (java.io.File)5 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)5 TextureManager (net.minecraft.client.renderer.texture.TextureManager)5 World (net.minecraft.world.World)5 SideOnly (cpw.mods.fml.relauncher.SideOnly)4 IBlockState (net.minecraft.block.state.IBlockState)4 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)4