Search in sources :

Example 11 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class FluidRenderer method getFluidDisplayListForSide.

/**
 * Note that this does NOT implement caching.
 */
public static int[] getFluidDisplayListForSide(FluidStack fluidStack, FluidType type, Vec3d size, EnumFacing side) {
    if (fluidStack == null) {
        return null;
    }
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return null;
    }
    int[] lists = new int[DISPLAY_STAGES];
    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        lists[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(lists[s], GL11.GL_COMPILE);
        EntityResizableCuboid ent = new EntityResizableCuboid(null);
        ent.xSize = size.xCoord;
        ent.ySize = (Math.max(s, 1) / (float) DISPLAY_STAGES) * size.yCoord;
        ent.zSize = size.zCoord;
        ent.texture = getFluidTexture(fluidStack, type);
        ent.makeClient();
        Arrays.fill(ent.textures, null);
        ent.textures[side.ordinal()] = ent.texture;
        RenderResizableCuboid.INSTANCE.renderCube(ent);
        GL11.glEndList();
    }
    return lists;
}
Also used : Fluid(net.minecraftforge.fluids.Fluid) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid)

Example 12 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class PipeItemModel method create.

public static PipeItemModel create(ItemPipe item, int colorIndex) {
    TextureAtlasSprite sprite = item.getSprite();
    if (sprite == null) {
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    Vec3d center = Utils.VEC_HALF;
    Vec3d radius = new Vec3d(0.25, 0.5, 0.25);
    EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
    cuboid.texture = sprite;
    cuboid.setTextureOffset(new Vec3d(4, 0, 4));
    cuboid.setPosition(center.subtract(radius));
    cuboid.setSize(Utils.multiply(radius, 2));
    List<MutableQuad> unprocessed = Lists.newArrayList();
    List<BakedQuad> quads = Lists.newArrayList();
    RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
    for (MutableQuad quad : unprocessed) {
        quad.normalf(0, 1, 0);
        ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
    }
    unprocessed.clear();
    // Set up the colour
    if (colorIndex != 0) {
        // Very sligthly smaller
        radius = new Vec3d(0.249, 0.499, 0.249);
        cuboid = new EntityResizableCuboid(null);
        cuboid.setTextureOffset(new Vec3d(4, 0, 4));
        cuboid.texture = PipeIconProvider.TYPE.PipeStainedOverlay.getIcon();
        cuboid.setPosition(center.subtract(radius));
        cuboid.setSize(Utils.multiply(radius, 2));
        // Render it into a different list
        RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
        EnumDyeColor dye = EnumDyeColor.byDyeDamage(colorIndex - 1);
        int quadColor = ColorUtils.getLightHex(dye);
        // Add all of the quads we just rendered to the main list
        for (MutableQuad quad : unprocessed) {
            quad.normalf(0, 1, 0);
            quad.setTint(quadColor);
            ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
        }
        unprocessed.clear();
    }
    return new PipeItemModel(ImmutableList.copyOf(quads), sprite);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) EnumDyeColor(net.minecraft.item.EnumDyeColor) Vec3d(net.minecraft.util.math.Vec3d) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 13 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class PipeTransportRendererItems method doRenderItem.

public static void doRenderItem(TravelingItem travellingItem, double x, double y, double z, float light, EnumDyeColor color) {
    if (travellingItem == null || travellingItem.getItemStack() == null) {
        return;
    }
    float renderScale = 0.9f;
    ItemStack itemstack = travellingItem.getItemStack();
    int val = (travellingItem.id * 191) ^ 0x8d35;
    x += 0.004f * (4 - ((val % 9)));
    y += 0.004f * (4 - ((val / 9) % 9));
    z += 0.004f * (4 - ((val / 81) % 9));
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y + 0.05f, (float) z);
    GL11.glPushMatrix();
    GlStateManager.color(1, 1, 1, 1);
    if (!travellingItem.hasDisplayList) {
        travellingItem.displayList = GLAllocation.generateDisplayLists(1);
        travellingItem.hasDisplayList = true;
        GL11.glNewList(travellingItem.displayList, GL11.GL_COMPILE);
        if (itemstack.getItem() instanceof IItemCustomPipeRender) {
            IItemCustomPipeRender render = (IItemCustomPipeRender) itemstack.getItem();
            float itemScale = render.getPipeRenderScale(itemstack);
            GL11.glScalef(renderScale * itemScale, renderScale * itemScale, renderScale * itemScale);
            itemScale = 1 / itemScale;
            if (!render.renderItemInPipe(itemstack, x, y, z)) {
                dummyEntityItem.setEntityItemStack(itemstack);
                customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
            }
            GL11.glScalef(itemScale, itemScale, itemScale);
        } else {
            GL11.glScalef(renderScale, renderScale, renderScale);
            dummyEntityItem.setEntityItemStack(itemstack);
            customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
        }
        GL11.glEndList();
    }
    GL11.glCallList(travellingItem.displayList);
    // Some items don't reset their colour properly, so lets just kick both the state manager AND OpenGL to the same
    // state
    GL11.glColor4f(1, 1, 1, 1);
    GlStateManager.color(1, 1, 1, 1);
    GL11.glPopMatrix();
    if (color != null) {
        // The box around an item that decides what colour lenses it can go through
        Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        EntityResizableCuboid erc = new EntityResizableCuboid(null);
        erc.texture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.ItemBox.ordinal());
        erc.xSize = 1;
        erc.ySize = 1;
        erc.zSize = 1;
        GL11.glPushMatrix();
        renderScale /= 2f;
        GL11.glTranslatef(0, 0.2f, 0);
        GL11.glScalef(renderScale, renderScale, renderScale);
        GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
        RenderUtil.setGLColorFromInt(ColorUtils.getLightHex(color));
        RenderResizableCuboid.INSTANCE.renderCube(erc);
        GlStateManager.color(1, 1, 1, 1);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}
Also used : IItemCustomPipeRender(buildcraft.api.items.IItemCustomPipeRender) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityResizableCuboid (buildcraft.core.lib.EntityResizableCuboid)13 Vec3d (net.minecraft.util.math.Vec3d)8 EnumFacing (net.minecraft.util.EnumFacing)3 Fluid (net.minecraftforge.fluids.Fluid)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 IItemCustomPipeRender (buildcraft.api.items.IItemCustomPipeRender)1 IBlockLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.IBlockLocation)1 IFacingLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.IFacingLocation)1 RotatedFacingLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.RotatedFacingLocation)1 MutableQuad (buildcraft.lib.client.model.MutableQuad)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 TextureMap (net.minecraft.client.renderer.texture.TextureMap)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1