use of net.minecraft.client.renderer.BufferBuilder in project ForestryMC by ForestryMC.
the class TankWidget method drawFluidTexture.
private static void drawFluidTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
double uMin = textureSprite.getMinU();
double uMax = textureSprite.getMaxU();
double vMin = textureSprite.getMinV();
double vMax = textureSprite.getMaxV();
uMax = uMax - maskRight / 16.0 * (uMax - uMin);
vMax = vMax - maskTop / 16.0 * (vMax - vMin);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
buffer.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
buffer.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
buffer.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
buffer.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
tessellator.draw();
}
use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.
the class TropicraftWaterRenderFixer method onBlockOverlay.
@SubscribeEvent
public void onBlockOverlay(RenderBlockOverlayEvent event) {
if (event.getOverlayType() == OverlayType.WATER) {
double d0 = event.getPlayer().posY + event.getPlayer().getEyeHeight();
BlockPos blockpos = new BlockPos(event.getPlayer().posX, d0, event.getPlayer().posZ);
IBlockState atPos = event.getPlayer().getEntityWorld().getBlockState(blockpos);
if (tropicalOverlayBlocks.contains(atPos)) {
event.setCanceled(true);
Minecraft mc = Minecraft.getMinecraft();
// ItemRenderer#renderOverlays
mc.getTextureManager().bindTexture(RES_UNDERWATER_OVERLAY);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
float f = mc.player.getBrightness();
GlStateManager.color(f, f, f, 0.6F);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.pushMatrix();
float f7 = -mc.player.rotationYaw / 64.0F;
float f8 = mc.player.rotationPitch / 64.0F;
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(-1.0D, -1.0D, -0.5D).tex((double) (4.0F + f7), (double) (4.0F + f8)).endVertex();
vertexbuffer.pos(1.0D, -1.0D, -0.5D).tex((double) (0.0F + f7), (double) (4.0F + f8)).endVertex();
vertexbuffer.pos(1.0D, 1.0D, -0.5D).tex((double) (0.0F + f7), (double) (0.0F + f8)).endVertex();
vertexbuffer.pos(-1.0D, 1.0D, -0.5D).tex((double) (4.0F + f7), (double) (0.0F + f8)).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();
}
}
}
use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.
the class ModelEagleRay method renderWing.
private void renderWing(boolean reverse) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
float minUFront = 0f;
float maxUFront = 0.25f;
float minVFront = 0f;
float maxVFront = 0.5f;
float minUBack = 0f;
float maxUBack = 0.25f;
float minVBack = 0.5f;
float maxVBack = 1f;
for (int i = 1; i < EntityEagleRay.WING_JOINTS; i++) {
float prevAmplitude = interpolatedWingAmplitudes[i - 1];
float amplitude = interpolatedWingAmplitudes[i];
float prevX = (i - 1) / (EntityEagleRay.WING_JOINTS - 1f);
float x = i / (EntityEagleRay.WING_JOINTS - 1f);
float prevUFront = minUFront + (maxUFront - minUFront) * prevX;
float uFront = minUFront + (maxUFront - minUFront) * x;
float prevUBack = minUBack + (maxUBack - minUBack) * prevX;
float uBack = minUBack + (maxUBack - minUBack) * x;
float offset = -0.001f;
// Bottom
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
buf(buffer, x, amplitude - offset, 0.0D, uBack, reverse ? maxVBack : minVBack);
buf(buffer, x, amplitude - offset, 1.0D, uBack, reverse ? minVBack : maxVBack);
buf(buffer, prevX, prevAmplitude - offset, 1.0D, prevUBack, reverse ? minVBack : maxVBack);
buf(buffer, prevX, prevAmplitude - offset, 0.0D, prevUBack, reverse ? maxVBack : minVBack);
tessellator.draw();
// Top
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
buf(buffer, prevX, prevAmplitude, 0.0D, prevUFront, reverse ? maxVFront : minVFront);
buf(buffer, prevX, prevAmplitude, 1.0D, prevUFront, reverse ? minVFront : maxVFront);
buf(buffer, x, amplitude, 1.0D, uFront, reverse ? minVFront : maxVFront);
buf(buffer, x, amplitude, 0.0D, uFront, reverse ? maxVFront : minVFront);
tessellator.draw();
}
}
use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.
the class RenderEchinodermEgg method doRender.
@Override
public void doRender(EntityEchinodermEgg entity, double x, double y, double z, float yaw, float partialTicks) {
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y, (float) z);
GlStateManager.enableRescaleNormal();
this.bindEntityTexture(entity);
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.rotate(180f - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.25f, 0.25f, 0.25f);
float f = 0;
float f1 = 1;
float f2 = 0;
float f3 = 1;
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
buf(buffer, (double) (0.0F - f5), (double) (0.0F - f6), 0.0D, (double) f, (double) f3);
buf(buffer, (double) (f4 - f5), (double) (0.0F - f6), 0.0D, (double) f1, (double) f3);
buf(buffer, (double) (f4 - f5), (double) (f4 - f6), 0.0D, (double) f1, (double) f2);
buf(buffer, (double) (0.0F - f5), (double) (f4 - f6), 0.0D, (double) f, (double) f2);
tessellator.draw();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.BufferBuilder in project Tropicraft by Tropicraft.
the class RenderEgg method drawFlatEgg.
public void drawFlatEgg(EntityEgg ent, double x, double y, double z, float yaw, float ticks) {
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
this.bindEntityTexture(ent);
Tessellator tessellator = Tessellator.getInstance();
GlStateManager.translate(x, y, z);
GlStateManager.rotate(180f - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.25f, 0.25f, 0.25f);
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
buffer.pos(-.5, -.25, 0).tex(0, 1).endVertex();
buffer.pos(.5, -.25, 0).tex(1, 1).endVertex();
buffer.pos(.5, .75, 0).tex(1, 0).endVertex();
buffer.pos(-.5, .75, 0).tex(0, 0).endVertex();
tessellator.draw();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
Aggregations