use of net.minecraft.client.renderer.BufferBuilder in project Minestuck by mraof.
the class RenderGate method renderGateAt.
public void renderGateAt(TileEntityGate tileEntity, double posX, double posY, double posZ, float f, int p_180535_9_) {
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
float tick = tileEntity.getWorld().getTotalWorldTime() + f;
GlStateManager.translate(posX + 0.5, posY, posZ + 0.5);
GlStateManager.pushMatrix();
GlStateManager.rotate(tick, 0, 1, 0);
double y = 0.5;
this.bindTexture(nodeInner);
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
buffer.pos(-1.5, y, -1.5).tex(0, 0).endVertex();
buffer.pos(-1.5, y, 1.5).tex(0, 1).endVertex();
buffer.pos(1.5, y, 1.5).tex(1, 1).endVertex();
buffer.pos(1.5, y, -1.5).tex(1, 0).endVertex();
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.BufferBuilder in project minecolonies by Minecolonies.
the class RenderFishHook method doRender.
/**
* Render a fishing hook entity in the world
* This class uses some GL11 stuff
* and seems hard to document...
*
* @param entity the hook to render
* @param x the x position
* @param y the y position
* @param z the z position
* @param entityYaw the angle thrown
*/
@Override
public void doRender(@NotNull final EntityFishHook entity, final double x, final double y, final double z, final float entityYaw, final float partialTicks) {
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y, (float) z);
GlStateManager.enableRescaleNormal();
GlStateManager.scale(0.5F, 0.5F, 0.5F);
this.bindEntityTexture(entity);
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder vertexBuffer = tessellator.getBuffer();
GlStateManager.rotate((float) (180.0D - this.renderManager.playerViewY), 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
vertexBuffer.pos(-0.5D, -0.5D, 0.0D).tex(0.0625D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
vertexBuffer.pos(0.5D, -0.5D, 0.0D).tex(0.125D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
vertexBuffer.pos(0.5D, 0.5D, 0.0D).tex(0.125D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
vertexBuffer.pos(-0.5D, 0.5D, 0.0D).tex(0.0625D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
tessellator.draw();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
EntityCitizen citizen = entity.getCitizen();
// Check if he is a fisherman -> Through his texture
if (citizen == null) {
for (@NotNull final Object citizenX : CompatibilityUtils.getWorld(entity).getEntitiesWithinAABB(EntityCitizen.class, entity.getEntityBoundingBox().expand(10, 10, 10))) {
if (((EntityCitizen) citizenX).getModelID().textureBase.contains("Fisherman")) {
citizen = (EntityCitizen) citizenX;
break;
}
}
}
if (citizen != null) {
final double orientation = citizen.getSwingProgress(partialTicks);
final double finalOrientation = Math.sin(Math.sqrt(orientation) * Math.PI);
@NotNull final Vec3d Vec3d = new Vec3d(-0.36D, 0.03D, 0.35D);
Vec3d.rotatePitch((float) (-((double) citizen.prevRotationPitch + ((double) citizen.rotationPitch - (double) citizen.prevRotationPitch) * partialTicks) * Math.PI / Literals.HALF_CIRCLE));
Vec3d.rotateYaw((float) (-((double) citizen.prevRotationYaw + ((double) citizen.rotationYaw - (double) citizen.prevRotationYaw) * partialTicks) * Math.PI / Literals.HALF_CIRCLE));
Vec3d.rotateYaw((float) (finalOrientation * 0.5D));
Vec3d.rotatePitch((float) (-finalOrientation * 0.7D));
final double thirdPersonOffset = (citizen.prevRenderYawOffset + ((double) citizen.renderYawOffset - citizen.prevRenderYawOffset) * partialTicks) * Math.PI / Literals.HALF_CIRCLE;
final double correctedPosX = citizen.prevPosX + (citizen.posX - citizen.prevPosX) * (double) partialTicks - MathHelper.cos((float) thirdPersonOffset) * 0.35D - MathHelper.sin((float) thirdPersonOffset) * 0.8D;
final double correctedPosY = citizen.prevPosY + citizen.getEyeHeight() + (citizen.posY - citizen.prevPosY) * (double) partialTicks - 0.45D;
final double correctedPosZ = citizen.prevPosZ + (citizen.posZ - citizen.prevPosZ) * (double) partialTicks - MathHelper.sin((float) thirdPersonOffset) * 0.35D + MathHelper.cos((float) thirdPersonOffset) * 0.8D;
final double eyeHeight = citizen.isSneaking() ? -0.1875D : 0.0D;
final double distX = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks;
final double distY = entity.posY + 0.25;
final double distZ = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks;
final double correctionX = correctedPosX - distX;
final double correctionY = correctedPosY - distY + eyeHeight;
final double correctionZ = correctedPosZ - distZ;
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
vertexBuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
for (int l = 0; l <= 16; ++l) {
final double var = (double) l / 16.0;
vertexBuffer.pos(x + correctionX * var, y + correctionY * (var * var + var) * 0.5D + 0.25D, z + correctionZ * var).color(0, 0, 0, 255).endVertex();
}
tessellator.draw();
GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
}
use of net.minecraft.client.renderer.BufferBuilder in project minecolonies by Minecolonies.
the class Pathfinding method debugDrawNode.
@SideOnly(Side.CLIENT)
private static void debugDrawNode(@NotNull final Node n, final float r, final float g, final float b) {
GlStateManager.pushMatrix();
GlStateManager.translate((double) n.pos.getX() + 0.375, (double) n.pos.getY() + 0.375, (double) n.pos.getZ() + 0.375);
final Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
final double dx = n.pos.getX() - entity.posX;
final double dy = n.pos.getY() - entity.posY;
final double dz = n.pos.getZ() - entity.posZ;
if (Math.sqrt(dx * dx + dy * dy + dz * dz) <= 5D) {
renderDebugText(n);
}
GlStateManager.scale(0.25D, 0.25D, 0.25D);
final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
GlStateManager.color(r, g, b);
// X+
vertexBuffer.pos(1.0, 0.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 1.0, 1.0).endVertex();
vertexBuffer.pos(1.0, 0.0, 1.0).endVertex();
// X-
vertexBuffer.pos(0.0, 0.0, 1.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 1.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(0.0, 0.0, 0.0).endVertex();
// Z-
vertexBuffer.pos(0.0, 0.0, 0.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 0.0, 0.0).endVertex();
// Z+
vertexBuffer.pos(1.0, 0.0, 1.0).endVertex();
vertexBuffer.pos(1.0, 1.0, 1.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 1.0).endVertex();
vertexBuffer.pos(0.0, 0.0, 1.0).endVertex();
// Y+
vertexBuffer.pos(1.0, 1.0, 1.0).endVertex();
vertexBuffer.pos(1.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 0.0).endVertex();
vertexBuffer.pos(0.0, 1.0, 1.0).endVertex();
// Y-
vertexBuffer.pos(0.0, 0.0, 1.0).endVertex();
vertexBuffer.pos(0.0, 0.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 0.0, 0.0).endVertex();
vertexBuffer.pos(1.0, 0.0, 1.0).endVertex();
tessellator.draw();
if (n.parent != null) {
final double pdx = n.parent.pos.getX() - n.pos.getX() + 0.125;
final double pdy = n.parent.pos.getY() - n.pos.getY() + 0.125;
final double pdz = n.parent.pos.getZ() - n.pos.getZ() + 0.125;
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
vertexBuffer.pos(0.5D, 0.5D, 0.5D).color(0.75F, 0.75F, 0.75F, 1.0F).endVertex();
vertexBuffer.pos(pdx / 0.25, pdy / 0.25, pdz / 0.25).color(0.75F, 0.75F, 0.75F, 1.0F).endVertex();
tessellator.draw();
}
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.BufferBuilder in project Minestuck by mraof.
the class GuiSburbMachine method drawCustomBox.
/**
* Draws a box like drawModalRect, but with custom width and height values.
*/
public void drawCustomBox(int par1, int par2, int par3, int par4, int par5, int par6, int width, int height) {
float f = 1 / (float) width;
float f1 = 1 / (float) height;
BufferBuilder render = Tessellator.getInstance().getBuffer();
render.begin(7, DefaultVertexFormats.POSITION_TEX);
render.pos(par1, par2 + par6, 0D).tex((par3) * f, (par4 + par6) * f1).endVertex();
render.pos(par1 + par5, par2 + par6, this.zLevel).tex((par3 + par5) * f, (par4 + par6) * f1).endVertex();
render.pos(par1 + par5, par2, this.zLevel).tex((par3 + par5) * f, (par4) * f1).endVertex();
render.pos(par1, par2, this.zLevel).tex((par3) * f, (par4) * f1).endVertex();
Tessellator.getInstance().draw();
}
use of net.minecraft.client.renderer.BufferBuilder 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();
BufferBuilder 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