Search in sources :

Example 11 with IIcon

use of net.minecraft.util.IIcon in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method addDestroyEffects.

/**
	 * Spawn particles for when the block is destroyed. Due to the nature of how
	 * this is invoked, the x/y/z locations are not always guaranteed to host
	 * your block. So be sure to do proper sanity checks before assuming that
	 * the location is this block.
	 *
	 * @param worldObj
	 *            The current world
	 * @param x
	 *            X position to spawn the particle
	 * @param y
	 *            Y position to spawn the particle
	 * @param z
	 *            Z position to spawn the particle
	 * @param meta
	 *            The metadata for the block before it was destroyed.
	 * @param effectRenderer
	 *            A reference to the current effect renderer.
	 * @return True to prevent vanilla break particles from spawning.
	 */
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(worldObj, x, y, z);
    if (pipe == null) {
        return false;
    }
    PlayerConfig config = LogisticsPipes.getClientPlayerConfig();
    if (config.isUseNewRenderer()) {
        LogisticsNewRenderPipe.renderDestruction(pipe, worldObj, x, y, z, effectRenderer);
    } else {
        IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());
        byte its = 4;
        for (int i = 0; i < its; ++i) {
            for (int j = 0; j < its; ++j) {
                for (int k = 0; k < its; ++k) {
                    if (pipe.isMultiBlock()) {
                        LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> set = ((CoreMultiBlockPipe) pipe).getRotatedSubBlocks();
                        set.add(new DoubleCoordinatesType<>(0, 0, 0, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                        for (DoubleCoordinates pos : set) {
                            int localx = x + pos.getXInt();
                            int localy = y + pos.getYInt();
                            int localz = z + pos.getZInt();
                            double px = localx + (i + 0.5D) / its;
                            double py = localy + (j + 0.5D) / its;
                            double pz = localz + (k + 0.5D) / its;
                            int random = rand.nextInt(6);
                            EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - localx - 0.5D, py - localy - 0.5D, pz - localz - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
                            fx.setParticleIcon(icon);
                            effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                        }
                    } else {
                        double px = x + (i + 0.5D) / its;
                        double py = y + (j + 0.5D) / its;
                        double pz = z + (k + 0.5D) / its;
                        int random = rand.nextInt(6);
                        EntityDiggingFX fx = new EntityDiggingFX(worldObj, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, LogisticsPipes.LogisticsPipeBlock, random, meta);
                        fx.setParticleIcon(icon);
                        effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
                    }
                }
            }
        }
    }
    return true;
}
Also used : EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) IIcon(net.minecraft.util.IIcon) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) PlayerConfig(logisticspipes.config.PlayerConfig) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 12 with IIcon

use of net.minecraft.util.IIcon in project LogisticsPipes by RS485.

the class FluidContainerRenderer method doRenderFluid.

public void doRenderFluid(FluidStack liquid, Minecraft mc, ItemRenderType type, Object[] data) {
    GL11.glPushMatrix();
    if (type == ItemRenderType.ENTITY) {
        GL11.glRotatef(((((EntityItem) data[1]).age) / 20.0F + ((EntityItem) data[1]).hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
        GL11.glScaled(0.063, 0.065, 1);
        GL11.glTranslated(-8, -4, -0.02);
    }
    GL11.glDisable(GL11.GL_LIGHTING);
    ResourceLocation resourcelocation = mc.renderEngine.getResourceLocation(liquid.getFluid().getSpriteNumber());
    mc.renderEngine.bindTexture(resourcelocation);
    int i1 = liquid.getFluid().getColor();
    float f = (i1 >> 16 & 255) / 255.0F;
    float f1 = (i1 >> 8 & 255) / 255.0F;
    float f2 = (i1 & 255) / 255.0F;
    GL11.glColor4f(f, f1, f2, 1.0F);
    IIcon icon = liquid.getFluid().getIcon();
    if (icon != null) {
        renderIcon(5, 2, icon, 6, 12, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glRotatef(((((EntityItem) data[1]).age) / 20.0F + ((EntityItem) data[1]).hoverStart) * (180F / (float) Math.PI) + 180, 0.0F, 1.0F, 0.0F);
            GL11.glScaled(0.063, 0.065, 1);
            GL11.glTranslated(-8, -4, -0.042);
            renderIcon(5, 2, icon, 6, 12, 0);
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}
Also used : IIcon(net.minecraft.util.IIcon) ResourceLocation(net.minecraft.util.ResourceLocation) EntityItem(net.minecraft.entity.item.EntityItem)

Example 13 with IIcon

use of net.minecraft.util.IIcon in project LogisticsPipes by RS485.

the class LogisticsPipeItemRenderer method renderPipeItem.

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    //don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;
    Block block = LogisticsPipes.LogisticsPipeBlock;
    IIcon icon = item.getItem().getIconFromDamage(0);
    if (icon == null) {
        icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
    }
    block.setBlockBounds(LogisticsPipeItemRenderer.PIPE_MIN_POS, 0.0F, LogisticsPipeItemRenderer.PIPE_MIN_POS, LogisticsPipeItemRenderer.PIPE_MAX_POS, 1.0F, LogisticsPipeItemRenderer.PIPE_MAX_POS);
    //block.setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);
    GL11.glTranslatef(translateX, translateY, translateZ);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    // nicely leave the rendering how it was
    GL11.glPopAttrib();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon) Block(net.minecraft.block.Block)

Example 14 with IIcon

use of net.minecraft.util.IIcon in project Engine by VoltzEngine-Project.

the class ExplosiveRegistryClient method getCornerIconFor.

/**
     * Gets the corner icon for the explosive item. Defaults
     * to using {@link ITexturedExplosiveHandler} if the explosive
     * handler implements the interface. If it doesn't then
     * the map will be searched for the item.
     *
     * @param stack
     * @return item or missing icon
     */
public static IIcon getCornerIconFor(final ItemStack stack, int pass) {
    ItemStack item = stack;
    if (item.getItem() instanceof IExplosiveContainerItem) {
        item = ((IExplosiveContainerItem) item.getItem()).getExplosiveStack(stack);
    }
    if (item != null) {
        IExplosiveHandler handler = ExplosiveRegistry.get(item);
        if (handler instanceof ITexturedExplosiveHandler) {
            IIcon icon = ((ITexturedExplosiveHandler) handler).getBottomLeftCornerIcon(item, pass);
            if (icon != null) {
                return icon;
            }
        }
        ItemStackWrapper wrapper = new ItemStackWrapper(item);
        if (EX_CORNER_ICONS.containsKey(wrapper)) {
            return EX_CORNER_ICONS.get(wrapper);
        }
    }
    return missing_corner_icon;
}
Also used : IIcon(net.minecraft.util.IIcon) IExplosiveContainerItem(com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem) ItemStack(net.minecraft.item.ItemStack) IExplosiveHandler(com.builtbroken.mc.api.explosive.IExplosiveHandler) ItemStackWrapper(com.builtbroken.mc.prefab.items.ItemStackWrapper) ITexturedExplosiveHandler(com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)

Example 15 with IIcon

use of net.minecraft.util.IIcon in project Engine by VoltzEngine-Project.

the class ItemBase method getIconFromState.

/**
     * Called to get the icon from the state
     *
     * @param data - render data
     * @param meta - metadata or damage of the item
     * @param pass - render pass, 0 by default
     * @return icon, can not be null or will crash
     */
protected IIcon getIconFromState(RenderData data, int meta, int pass) {
    if (data != null) {
        //Attempt to get meta
        IRenderState state = data.getState(RenderData.INVENTORY_RENDER_KEY + "." + meta);
        if (state != null) {
            state = data.getState(RenderData.INVENTORY_RENDER_KEY);
            if (state != null) {
                IIcon icon = state.getIcon(pass);
                if (icon != null) {
                    return icon;
                }
            }
        }
        //Attempt to do non-meta
        state = data.getState(RenderData.INVENTORY_RENDER_KEY);
        if (state != null) {
            IIcon icon = state.getIcon(0);
            if (icon != null) {
                return icon;
            }
        }
    }
    return getFallBackIcon();
}
Also used : IIcon(net.minecraft.util.IIcon) IRenderState(com.builtbroken.mc.client.json.imp.IRenderState)

Aggregations

IIcon (net.minecraft.util.IIcon)79 Tessellator (net.minecraft.client.renderer.Tessellator)19 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)11 ItemStack (net.minecraft.item.ItemStack)6 EntityItem (net.minecraft.entity.item.EntityItem)5 Fluid (net.minecraftforge.fluids.Fluid)5 Rotation (uk.co.qmunity.lib.transform.Rotation)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 AMVector2 (am2.api.math.AMVector2)3 Block (net.minecraft.block.Block)3 EntityDiggingFX (net.minecraft.client.particle.EntityDiggingFX)3 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)2 IExplosiveHandler (com.builtbroken.mc.api.explosive.IExplosiveHandler)2 ITexturedExplosiveHandler (com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)2 IExplosiveContainerItem (com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem)2 ItemStackWrapper (com.builtbroken.mc.prefab.items.ItemStackWrapper)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)2