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();
}
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();
}
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();
}
}
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();
}
}
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();
}
Aggregations