Search in sources :

Example 11 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.

the class FluidModelRenderer method renderFluid.

/**
     * @param level Ranges from 1 to 16 inclusively, 0 will crash
     */
public void renderFluid(FluidStack fluidStack, int level) {
    IBakedModel bakedModel = new FluidModel(fluidStack, false).bake(TRSRTransformation.identity(), DefaultVertexFormats.BLOCK, RenderTools::getTexture);
    Minecraft mc = Minecraft.getMinecraft();
    mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    Tessellator tess = Tessellator.getInstance();
    VertexBuffer buffer = tess.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    IExtendedBlockState state = (IExtendedBlockState) new ExtendedBlockState(Blocks.WATER, new IProperty[] { BlockFluidBase.LEVEL }, BlockFluidBase.FLUID_RENDER_PROPS.toArray(new IUnlistedProperty<?>[0])).getBaseState();
    for (int i = 0; i < 4; i++) state = state.withProperty(BlockFluidBase.LEVEL_CORNERS[i], level / 16F);
    state = (IExtendedBlockState) state.withProperty(BlockFluidBase.LEVEL, level - 1);
    state = state.withProperty(BlockFluidBase.FLOW_DIRECTION, -1000F);
    putQuads(buffer, bakedModel.getQuads(state, null, 1234));
    for (EnumFacing side : EnumFacing.VALUES) {
        putQuads(buffer, bakedModel.getQuads(state, side, 1234));
    }
    tess.draw();
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IUnlistedProperty(net.minecraftforge.common.property.IUnlistedProperty) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ExtendedBlockState(net.minecraftforge.common.property.ExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) RenderTools(mods.railcraft.client.render.tools.RenderTools) Minecraft(net.minecraft.client.Minecraft)

Example 12 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Railcraft by Railcraft.

the class JSONModelRenderer method renderModel.

public void renderModel(ResourceLocation model) {
    IBakedModel bakedModel = bakedModels.get(model);
    if (bakedModel == null)
        return;
    Minecraft mc = Minecraft.getMinecraft();
    mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    Tessellator tess = Tessellator.getInstance();
    VertexBuffer buffer = tess.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    putQuads(buffer, bakedModel.getQuads(null, null, 1234));
    for (EnumFacing side : EnumFacing.VALUES) {
        putQuads(buffer, bakedModel.getQuads(null, side, 1234));
    }
    tess.draw();
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft)

Example 13 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project Overloaded by CJ-MC-Mods.

the class ModelUtils method renderQuadsRGB.

public static void renderQuadsRGB(List<BakedQuad> listQuads, float r, float g, float b) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = (BakedQuad) listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        vertexbuffer.putColorRGB_F4(r, g, b);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 14 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project minecolonies by Minecolonies.

the class Structure method renderQuads.

private void renderQuads(final World world, final IBlockState actualState, final BlockPos pos, final List<BakedQuad> quads, final int alpha) {
    final Tessellator tessellator = Tessellator.getInstance();
    final VertexBuffer buffer = tessellator.getBuffer();
    for (final BakedQuad quad : quads) {
        buffer.begin(GL11.GL_QUADS, quad.getFormat());
        final int color = quad.hasTintIndex() ? this.getTint(world, actualState, pos, alpha, quad.getTintIndex()) : (alpha | 0xffffff);
        LightUtil.renderQuadColor(buffer, quad, color);
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 15 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project OpenModularTurrets by OpenModularTurretsTeam.

the class RocketRenderer method renderRocket.

@SuppressWarnings("unused")
private void renderRocket(RocketProjectile par1EntityRocket, double x, double y, double z, float entityYaw, float partialTicks) {
    if (par1EntityRocket.getFramesRendered() <= 1) {
        par1EntityRocket.setFramesRendered(par1EntityRocket.getFramesRendered() + 1);
        return;
    }
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    GlStateManager.translate((float) x, (float) y, (float) z);
    GlStateManager.rotate(par1EntityRocket.prevRotationYaw + (par1EntityRocket.rotationYaw - par1EntityRocket.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(par1EntityRocket.prevRotationPitch + (par1EntityRocket.rotationPitch - par1EntityRocket.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    GlStateManager.enableRescaleNormal();
    float f9 = (float) par1EntityRocket.arrowShake - partialTicks;
    if (f9 > 0.0F) {
        float f10 = -MathHelper.sin(f9 * 3.0F) * f9;
        GlStateManager.rotate(f10, 0.0F, 0.0F, 1.0F);
    }
    GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(0.05625F, 0.05625F, 0.05625F);
    GlStateManager.translate(-4.0F, 0.0F, 0.0F);
    GlStateManager.glNormal3f(0.05625F, 0.0F, 0.0F);
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    vertexbuffer.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    vertexbuffer.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    vertexbuffer.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    vertexbuffer.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();
    GlStateManager.glNormal3f(-0.05625F, 0.0F, 0.0F);
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    vertexbuffer.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    vertexbuffer.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    vertexbuffer.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    vertexbuffer.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();
    for (int j = 0; j < 4; ++j) {
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.glNormal3f(0.0F, 0.0F, 0.05625F);
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
        vertexbuffer.pos(-8.0D, -2.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
        vertexbuffer.pos(8.0D, -2.0D, 0.0D).tex(0.5D, 0.0D).endVertex();
        vertexbuffer.pos(8.0D, 2.0D, 0.0D).tex(0.5D, 0.15625D).endVertex();
        vertexbuffer.pos(-8.0D, 2.0D, 0.0D).tex(0.0D, 0.15625D).endVertex();
        tessellator.draw();
    }
    GlStateManager.disableRescaleNormal();
    GlStateManager.enableLighting();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Aggregations

VertexBuffer (net.minecraft.client.renderer.VertexBuffer)52 Tessellator (net.minecraft.client.renderer.Tessellator)50 BlockPos (net.minecraft.util.math.BlockPos)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 EnumFacing (net.minecraft.util.EnumFacing)5 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)3 Minecraft (net.minecraft.client.Minecraft)3 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)3 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 Entity (net.minecraft.entity.Entity)3 Vec3i (net.minecraft.util.math.Vec3i)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 FontRenderer (net.minecraft.client.gui.FontRenderer)2 RenderManager (net.minecraft.client.renderer.entity.RenderManager)2 Vec3d (net.minecraft.util.math.Vec3d)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 NotNull (org.jetbrains.annotations.NotNull)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)1