Search in sources :

Example 1 with HalfBakedList

use of crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList in project EnderIO by SleepyTrousers.

the class TankRenderHelper method mkTank.

/**
 * Generate a cube of liquid for a SmartTank.
 *
 * @param tank
 *          The tank that contains the liquid.
 * @param xzBorder
 *          How many pixels of space to leave around the y and z sides. (0-7.99)
 * @param miny
 *          Height to start the tank. (0-15.99)
 * @param maxy
 *          Height to end the tank (0.01-16)
 * @param renderBottom
 *          Render the bottom face?
 * @return A HalfBakedList with the tank content or null if the tank is empty
 */
public static HalfBakedList mkTank(SmartTank tank, double xzBorder, double miny, double maxy, boolean renderBottom) {
    if (tank != null) {
        float ratio = tank.getFilledRatio();
        final FluidStack fluid = tank.getFluid();
        if (fluid != null && ratio > 0) {
            float height = 1 - ratio;
            ResourceLocation still = fluid.getFluid().getStill(fluid);
            int color = fluid.getFluid().getColor(fluid);
            Vector4f vecC = new Vector4f((color >> 16 & 0xFF) / 255d, (color >> 8 & 0xFF) / 255d, (color & 0xFF) / 255d, 1);
            TextureAtlasSprite sprite = still == null ? null : Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(still.toString());
            if (sprite == null) {
                sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
                vecC = null;
            }
            boolean gas = fluid.getFluid().isGaseous(fluid);
            BoundingBox bb = gas ? new BoundingBox(xzBorder * px, (maxy - (maxy - miny) * ratio) * px, xzBorder * px, (16 - xzBorder) * px, maxy * px, (16 - xzBorder) * px) : new BoundingBox(xzBorder * px, miny * px, xzBorder * px, (16 - xzBorder) * px, ((maxy - miny) * ratio + miny) * px, (16 - xzBorder) * px);
            HalfBakedList buffer = new HalfBakedList();
            buffer.add(bb, EnumFacing.NORTH, 0f, 1f, height, 1f, sprite, vecC, gas);
            buffer.add(bb, EnumFacing.EAST, 0f, 1f, height, 1f, sprite, vecC, gas);
            buffer.add(bb, EnumFacing.SOUTH, 0f, 1f, height, 1f, sprite, vecC, gas);
            buffer.add(bb, EnumFacing.WEST, 0f, 1f, height, 1f, sprite, vecC, gas);
            if (!gas || renderBottom) {
                buffer.add(bb, EnumFacing.UP, 0f, 1f, 0f, 1f, sprite, vecC);
            }
            if (gas || renderBottom) {
                buffer.add(bb, EnumFacing.DOWN, 0f, 1f, 0f, 1f, sprite, vecC);
            }
            return buffer;
        }
    }
    return null;
}
Also used : Vector4f(com.enderio.core.common.vecmath.Vector4f) FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) BoundingBox(com.enderio.core.client.render.BoundingBox) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)

Example 2 with HalfBakedList

use of crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList in project EnderIO by SleepyTrousers.

the class FusedQuartzItemRenderMapper method mapItemDynamicOverlayRender.

@Override
@SideOnly(Side.CLIENT)
public ItemQuadCollector mapItemDynamicOverlayRender(@Nonnull Block block, @Nonnull ItemStack stack) {
    if (NbtValue.FAKE.hasTag(stack)) {
        // this is for the TOP overlay, kind of a hack putting it here, but the alternative would be adding a new item just for this...
        SmartTank tank = ItemTankHelper.getTank(stack);
        HalfBakedList buffer = TankRenderHelper.mkTank(tank, 0, 0, 16, true);
        if (buffer != null) {
            ItemQuadCollector result = new ItemQuadCollector();
            List<BakedQuad> quads = new ArrayList<BakedQuad>();
            buffer.bake(quads);
            result.addQuads(null, quads);
            return result;
        }
    }
    return null;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ArrayList(java.util.ArrayList) SmartTank(com.enderio.core.common.fluid.SmartTank) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList) ItemQuadCollector(crazypants.enderio.base.render.util.ItemQuadCollector) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with HalfBakedList

use of crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList in project EnderIO by SleepyTrousers.

the class TankItemRenderMapper method mapItemDynamicOverlayRender.

@Override
@SideOnly(Side.CLIENT)
public ItemQuadCollector mapItemDynamicOverlayRender(@Nonnull Block block, @Nonnull ItemStack stack) {
    ItemQuadCollector result = new ItemQuadCollector();
    if (stack.hasTagCompound()) {
        SmartTank tank = ItemTankHelper.getTank(stack);
        HalfBakedList buffer = TankRenderHelper.mkTank(tank, 0.5, 0.5, 15.5, false);
        if (buffer != null) {
            List<BakedQuad> quads = new ArrayList<BakedQuad>();
            buffer.bake(quads);
            result.addQuads(null, quads);
        }
    }
    if (!NbtValue.FAKE.hasTag(stack)) {
        result.addBlockState(block.getStateFromMeta(stack.getMetadata()).withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT_ON), stack, true);
    }
    return result;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ArrayList(java.util.ArrayList) SmartTank(com.enderio.core.common.fluid.SmartTank) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList) ItemQuadCollector(crazypants.enderio.base.render.util.ItemQuadCollector) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with HalfBakedList

use of crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList in project EnderIO by SleepyTrousers.

the class KillerJoeRenderMapper method renderFuel.

private List<BakedQuad> renderFuel(ItemStack stack) {
    if (stack.hasTagCompound()) {
        SmartTank tank = ItemTankHelper.getTank(stack);
        HalfBakedList buffer = TankRenderHelper.mkTank(tank, 2.51, 1, 14, false);
        if (buffer != null) {
            List<BakedQuad> quads = new ArrayList<BakedQuad>();
            buffer.bake(quads);
            return quads;
        }
    }
    return null;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ArrayList(java.util.ArrayList) SmartTank(com.enderio.core.common.fluid.SmartTank) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)

Example 5 with HalfBakedList

use of crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList in project EnderIO by SleepyTrousers.

the class FillGaugeBakery method mkQuads.

private void mkQuads() {
    VertexRotationFacing rot = new VertexRotationFacing(face);
    rot.setCenter(CENTER);
    rot.setRotation(EnumFacing.NORTH);
    buffer = new HalfBakedList();
    final double upperBound = (connectUp ? 16 : 13) * px, lowerBound = (connectDown ? 0 : 3) * px;
    final double full_out = -.5 * px, half_out = full_out / 2, quarter_out = full_out / 4, bit_in = .01 * px;
    BoundingBox border1 = new BoundingBox(6 * px, lowerBound, full_out, 7 * px, upperBound, bit_in);
    buffer.add(border1, EnumFacing.NORTH, 15.01 * px, 15.99 * px, lowerBound, upperBound, tex, null);
    buffer.add(border1, EnumFacing.EAST, 15.01 * px, 15.49 * px, lowerBound, upperBound, tex, null);
    buffer.add(border1, EnumFacing.WEST, 15.99 * px, 15.51 * px, lowerBound, upperBound, tex, null);
    BoundingBox border2 = new BoundingBox(9 * px, lowerBound, full_out, 10 * px, upperBound, bit_in);
    buffer.add(border2, EnumFacing.NORTH, 12.01 * px, 12.99 * px, lowerBound, upperBound, tex, null);
    buffer.add(border2, EnumFacing.EAST, 12.01 * px, 12.49 * px, lowerBound, upperBound, tex, null);
    buffer.add(border2, EnumFacing.WEST, 12.99 * px, 12.51 * px, lowerBound, upperBound, tex, null);
    BoundingBox back = new BoundingBox(6 * px, (connectDown ? 0 : 2) * px, full_out, 10 * px, (connectUp ? 16 : 14) * px, bit_in);
    buffer.add(back, EnumFacing.SOUTH, 4.01 * px, 7.99 * px, (connectDown ? 0 : 2) * px, (connectUp ? 16 : 14) * px, tex, null);
    if (!connectDown) {
        BoundingBox border3 = new BoundingBox(6 * px, lowerBound - 1 * px, full_out, 10 * px, 3 * px, bit_in);
        buffer.add(border3, EnumFacing.NORTH, 0.005 * px, 3.995 * px, 13.01 * px, 13.99 * px, tex, null);
        buffer.add(border3, EnumFacing.UP, 0.005 * px, 3.995 * px, 13.5 * px, 13.99 * px, tex, null);
        buffer.add(border3, EnumFacing.DOWN, 0.005 * px, 3.995 * px, 13.5 * px, 13.99 * px, tex, null);
        buffer.add(border3, EnumFacing.WEST, 3.01 * px, 3.49 * px, 13.01 * px, 13.99 * px, tex, null);
        buffer.add(border3, EnumFacing.EAST, 0.99 * px, 0.51 * px, 13.01 * px, 13.99 * px, tex, null);
    }
    if (!connectUp) {
        BoundingBox border4 = new BoundingBox(6 * px, 13 * px, full_out, 10 * px, upperBound + 1 * px, bit_in);
        buffer.add(border4, EnumFacing.NORTH, 0.005 * px, 3.995 * px, 2.01 * px, 2.99 * px, tex, null);
        buffer.add(border4, EnumFacing.UP, 0.005 * px, 3.995 * px, 2.01 * px, 2.5 * px, tex, null);
        buffer.add(border4, EnumFacing.DOWN, 0.005 * px, 3.995 * px, 2.01 * px, 2.5 * px, tex, null);
        buffer.add(border4, EnumFacing.WEST, 3.01 * px, 3.49 * px, 2.01 * px, 2.99 * px, tex, null);
        buffer.add(border4, EnumFacing.EAST, 0.99 * px, 0.51 * px, 2.01 * px, 2.99 * px, tex, null);
    }
    BoundingBox bg = new BoundingBox(6.5 * px, (connectDown ? 0 : 2.5) * px, quarter_out, 9.5 * px, (connectUp ? 16 : 13.5) * px, bit_in);
    buffer.add(bg, EnumFacing.NORTH, 12.5 * px, 15.5 * px, (connectDown ? 0 : 2.5) * px, (connectUp ? 16 : 13.5) * px, tex, null);
    buffer.transform(rot);
    if (localFillLevel > 0.001) {
        BoundingBox fg = new BoundingBox(6.5 * px, (connectDown ? 0 : 2.99) * px, half_out, 9.5 * px, localFillLevel * px, bit_in);
        litBuffer = new HalfBakedList();
        litBuffer.add(fg, EnumFacing.NORTH, 8.55 * px, 11.45 * px, (connectDown ? 0 : 2.99) * px, localFillLevel * px, tex, null);
        litBuffer.transform(rot);
    }
}
Also used : VertexRotationFacing(com.enderio.core.client.render.VertexRotationFacing) BoundingBox(com.enderio.core.client.render.BoundingBox) HalfBakedList(crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)

Aggregations

HalfBakedList (crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)7 ArrayList (java.util.ArrayList)5 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 BoundingBox (com.enderio.core.client.render.BoundingBox)3 SmartTank (com.enderio.core.common.fluid.SmartTank)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)2 ItemQuadCollector (crazypants.enderio.base.render.util.ItemQuadCollector)2 EnumFacing (net.minecraft.util.EnumFacing)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 VertexTransform (com.enderio.core.api.client.render.VertexTransform)1 VertexRotation (com.enderio.core.client.render.VertexRotation)1 VertexScale (com.enderio.core.client.render.VertexScale)1 VertexTranslation (com.enderio.core.client.render.VertexTranslation)1 Vector3d (com.enderio.core.common.vecmath.Vector3d)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 AbstractMachineEntity (crazypants.enderio.base.machine.base.te.AbstractMachineEntity)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 FluidStack (net.minecraftforge.fluids.FluidStack)1