Java Code Examples for net.minecraft.client.renderer.GlStateManager#shadeModel()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#shadeModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerDisplay.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void draw(int x, double y, boolean config) {
    GlStateManager.pushMatrix();
    GlStateManager.color(1, 1, 1);

    GlStateManager.translate(x, y, 0);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.enableAlpha();

    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableAlpha();
    GlStateManager.enableDepth();

    GlStateManager.rotate(30, 0, 1.0F, 0);
    GuiInventory.drawEntityOnScreen(0, 100, 50, 0, 0, Minecraft.getMinecraft().thePlayer);
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.resetColor();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableDepth();
    GlStateManager.popMatrix();
}
 
Example 2
Source File: OptionScrollPane.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void drawOverlayGrad(int x1, int x2, int y1, int y2, float zLevel) {
    GlStateManager.disableTexture2D();
    GlStateManager.disableCull();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    WorldRenderer r = CCRenderState.startDrawing();
    r.setColorRGBA_I(0, 255);
    r.addVertex(x2, y1, zLevel);
    r.addVertex(x1, y1, zLevel);
    r.setColorRGBA_I(0, 0);
    r.addVertex(x1, y2, zLevel);
    r.addVertex(x2, y2, zLevel);
    CCRenderState.draw();
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
    GlStateManager.enableTexture2D();
}
 
Example 3
Source File: OptionScrollPane.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void drawOverlayGrad(int x1, int x2, int y1, int y2, float zLevel) {
    GlStateManager.disableTexture2D();
    GlStateManager.disableCull();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    CCRenderState ccrs = CCRenderState.instance();

    BufferBuilder buffer = ccrs.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    buffer.pos(x2, y1, zLevel).color(0, 0, 0, 255).endVertex();
    buffer.pos(x1, y1, zLevel).color(0, 0, 0, 255).endVertex();

    buffer.pos(x1, y2, zLevel).color(0, 0, 0, 0).endVertex();
    buffer.pos(x2, y2, zLevel).color(0, 0, 0, 0).endVertex();

    ccrs.draw();
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
    GlStateManager.enableTexture2D();
}
 
Example 4
Source File: PhasedBlockRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static BufferBuilder beginRender() {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableTexture2D();
	GlStateManager.enableCull();
	GlStateManager.cullFace(GlStateManager.CullFace.BACK);
	GlStateManager.depthMask(false);
	GlStateManager.enablePolygonOffset();
	GlStateManager.doPolygonOffset(-0.1f, -1000f);
	GlStateManager.enableColorMaterial();

	GlStateManager.color(1, 1, 1, 1);
	GlStateManager.shadeModel(GL11.GL_SMOOTH);

	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT);

	BufferBuilder buffer = Tessellator.getInstance().getBuffer();
	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
	buffer.setTranslation(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ);

	return buffer;
}
 
Example 5
Source File: MetaTileEntityTESR.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderTileEntityFastPart(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    }
    else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

    renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, partialTicks, buffer);
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}
 
Example 6
Source File: GuiAssembler.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void drawGradientRect(GuiRoutiduct gui, int x, int y, int width, int height, int startColor, int endColor) {
	x = adjustX(gui, x);
	y = adjustY(gui, y);

	int left = x;
	int top = y;
	int right = x + width;
	int bottom = y + height;
	float f = (float) (startColor >> 24 & 255) / 255.0F;
	float f1 = (float) (startColor >> 16 & 255) / 255.0F;
	float f2 = (float) (startColor >> 8 & 255) / 255.0F;
	float f3 = (float) (startColor & 255) / 255.0F;
	float f4 = (float) (endColor >> 24 & 255) / 255.0F;
	float f5 = (float) (endColor >> 16 & 255) / 255.0F;
	float f6 = (float) (endColor >> 8 & 255) / 255.0F;
	float f7 = (float) (endColor & 255) / 255.0F;
	GlStateManager.disableTexture2D();
	GlStateManager.enableBlend();
	GlStateManager.disableAlpha();
	GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.shadeModel(7425);
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vertexbuffer = tessellator.getBuffer();
	vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
	vertexbuffer.pos((double) right, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
	vertexbuffer.pos((double) left, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
	vertexbuffer.pos((double) left, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
	vertexbuffer.pos((double) right, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
	tessellator.draw();
	GlStateManager.shadeModel(7424);
	GlStateManager.disableBlend();
	GlStateManager.enableAlpha();
	GlStateManager.enableTexture2D();
}
 
Example 7
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public static void enableBlendAlphaStuffs() {
	GlStateManager.enableBlend();
	GlStateManager.tryBlendFuncSeparate(
		SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA,
		SourceFactor.ZERO, DestFactor.ONE);
	GlStateManager.disableTexture2D();
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
}
 
Example 8
Source File: PlayerOverlay.java    From MediaMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a rectangle with a vertical gradient between the specified colors (ARGB format).
 * Args: x1, y1, x2, y2, topColor, bottomColor
 *
 * @author ScottehBoeh
 */
private void drawGradientRect(double left, double top, double right, double bottom, int startColor, int endColor) {
    float f = (float) (startColor >> 24 & 255) / 255.0F;
    float f1 = (float) (startColor >> 16 & 255) / 255.0F;
    float f2 = (float) (startColor >> 8 & 255) / 255.0F;
    float f3 = (float) (startColor & 255) / 255.0F;
    float f4 = (float) (endColor >> 24 & 255) / 255.0F;
    float f5 = (float) (endColor >> 16 & 255) / 255.0F;
    float f6 = (float) (endColor >> 8 & 255) / 255.0F;
    float f7 = (float) (endColor & 255) / 255.0F;
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(7425);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(right, top, 0).color(f1, f2, f3, f).endVertex();
    worldrenderer.pos(left, top, 0).color(f1, f2, f3, f).endVertex();
    worldrenderer.pos(left, bottom, 0).color(f5, f6, f7, f4).endVertex();
    worldrenderer.pos(right, bottom, 0).color(f5, f6, f7, f4).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(7424);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
}
 
Example 9
Source File: GuiComponentColorPicker.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public void render(int offsetX, int offsetY, int mouseX, int mouseY) {
	GlStateManager.color(1, 1, 1, 1);

	int renderX = offsetX + x;
	int renderY = offsetY + y;

	bindComponentsSheet();
	drawTexturedModalRect(renderX, renderY, 156, 206, getWidth(), getColorsHeight());
	drawRect(renderX, renderY, renderX + getWidth(), renderY + getColorsHeight(), (tone << 24) | 0xFFFFFF);

	GlStateManager.enableBlend();
	GlStateManager.disableTexture2D();
	GlStateManager.disableAlpha();
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
	GL11.glBegin(GL11.GL_QUADS);
	GlStateManager.color(0, 0, 0, 1.0f);
	GL11.glVertex3d(renderX, renderY + getColorsHeight(), 0.0);
	GL11.glVertex3d(renderX + getWidth(), renderY + getColorsHeight(), 0.0);
	GlStateManager.color(0, 0, 0, 0f);
	GL11.glVertex3d(renderX + getWidth(), renderY, 0.0D);
	GL11.glVertex3d(renderX, renderY, 0.0);
	GL11.glEnd();
	GlStateManager.shadeModel(GL11.GL_FLAT);
	GlStateManager.disableBlend();
	GlStateManager.enableTexture2D();
	GlStateManager.enableAlpha();
	drawRect(renderX + pointX - 1,
			renderY + pointY - 1,
			renderX + pointX + 1,
			renderY + pointY + 1, 0xCCCC0000);
}
 
Example 10
Source File: GuiUtils.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
    float startAlpha = (float) (startColor >> 24 & 255) / 255.0F;
    float startRed = (float) (startColor >> 16 & 255) / 255.0F;
    float startGreen = (float) (startColor >> 8 & 255) / 255.0F;
    float startBlue = (float) (startColor & 255) / 255.0F;
    float endAlpha = (float) (endColor >> 24 & 255) / 255.0F;
    float endRed = (float) (endColor >> 16 & 255) / 255.0F;
    float endGreen = (float) (endColor >> 8 & 255) / 255.0F;
    float endBlue = (float) (endColor & 255) / 255.0F;

    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GlStateManager.shadeModel(GL11.GL_SMOOTH);

    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
    worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
    worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
    worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
    tessellator.draw();

    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
}
 
Example 11
Source File: RenderEventService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRenderWorld(RenderWorldLastEvent event) {
  GlStateManager.pushMatrix();
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  GlStateManager.disableDepth();
  
  GlStateManager.glLineWidth(1.f);
  
  Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks());
  
  RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks());
  e.resetTranslation();
  MinecraftForge.EVENT_BUS.post(e);
  
  GlStateManager.glLineWidth(1.f);
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 12
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine3D(float x, float y, float z, float x1, float y1, float z1, float thickness, int hex) {
    float red = (hex >> 16 & 0xFF) / 255.0F;
    float green = (hex >> 8 & 0xFF) / 255.0F;
    float blue = (hex & 0xFF) / 255.0F;
    float alpha = (hex >> 24 & 0xFF) / 255.0F;

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(thickness);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    GlStateManager.disableDepth();
    glEnable(GL32.GL_DEPTH_CLAMP);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(GL_LINES, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos((double) x, (double) y, (double) z).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos((double) x1, (double) y1, (double) z1).color(red, green, blue, alpha).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.enableDepth();
    glDisable(GL32.GL_DEPTH_CLAMP);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example 13
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine(float x, float y, float x1, float y1, float thickness, int hex) {
    float red = (hex >> 16 & 0xFF) / 255.0F;
    float green = (hex >> 8 & 0xFF) / 255.0F;
    float blue = (hex & 0xFF) / 255.0F;
    float alpha = (hex >> 24 & 0xFF) / 255.0F;

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(thickness);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos((double) x, (double) y, (double) 0).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos((double) x1, (double) y1, (double) 0).color(red, green, blue, alpha).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example 14
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void drawGradientRect(float left, float top, float right, float bottom, int startColor, int endColor) {
    float f = (float) (startColor >> 24 & 255) / 255.0F;
    float f1 = (float) (startColor >> 16 & 255) / 255.0F;
    float f2 = (float) (startColor >> 8 & 255) / 255.0F;
    float f3 = (float) (startColor & 255) / 255.0F;
    float f4 = (float) (endColor >> 24 & 255) / 255.0F;
    float f5 = (float) (endColor >> 16 & 255) / 255.0F;
    float f6 = (float) (endColor >> 8 & 255) / 255.0F;
    float f7 = (float) (endColor & 255) / 255.0F;
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.shadeModel(7425);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos((double) right, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
    bufferbuilder.pos((double) left, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
    bufferbuilder.pos((double) left, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
    bufferbuilder.pos((double) right, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(7424);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
}
 
Example 15
Source File: GuiCustom.java    From Custom-Main-Menu with MIT License 4 votes vote down vote up
@Override
public void initGui()
{
	GlStateManager.disableTexture2D();
	GlStateManager.enableBlend();
	GlStateManager.disableAlpha();
	GlStateManager.shadeModel(7425);
	GlStateManager.shadeModel(7424);
	GlStateManager.disableBlend();
	GlStateManager.enableAlpha();
	GlStateManager.enableTexture2D();

	if (!loadedSplashText && guiConfig.splashText != null)
	{
		if (guiConfig.splashText.synced)
		{
			this.splashText = CustomMainMenu.INSTANCE.config.getGUI("mainmenu").splashText;
		}
		else
		{
			loadSplashTexts();
		}

		loadedSplashText = true;
	}

	textLabels = new ArrayList<GuiCustomLabel>();
	buttonCounter = 0;
	this.viewportTexture = new DynamicTexture(256, 256);
	this.field_110351_G = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture);
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(new Date());

	if (calendar.get(2) + 1 == 11 && calendar.get(5) == 9)
	{
		this.splashText = "Happy birthday, ez!";
	}
	else if (calendar.get(2) + 1 == 6 && calendar.get(5) == 1)
	{
		this.splashText = "Happy birthday, Notch!";
	}
	else if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24)
	{
		this.splashText = "Merry X-mas!";
	}
	else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1)
	{
		this.splashText = "Happy new year!";
	}
	else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31)
	{
		this.splashText = "OOoooOOOoooo! Spooky!";
	}

	int idCounter = 6000;

	// Add Custom Buttons
	for (Button b : guiConfig.customButtons)
	{
		if (b.wrappedButtonID != -1)
		{
			this.buttonList.add(alignButton(b, new GuiCustomWrappedButton(b.wrappedButtonID, b.wrappedButtonID, b)));
		}
		else
		{
			this.buttonList.add(alignButton(b, new GuiCustomButton(idCounter, b)));
			idCounter++;
		}
	}

	// Add Labels
	for (Label t : guiConfig.customLabels)
	{
		textLabels.add(new GuiCustomLabel(this, t, modX(t.posX, t.alignment), modY(t.posY, t.alignment)));
	}
}
 
Example 16
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public static void disableBlendAlphaStuffs() {
	GlStateManager.shadeModel(GL11.GL_FLAT);
	GlStateManager.enableTexture2D();
	GlStateManager.disableBlend();
}
 
Example 17
Source File: ProjectilesModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onRender(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();

    ThrowableType throwingType = this.getTypeFromCurrentItem(mc.player);

    if (throwingType == ThrowableType.NONE) {
        return;
    }

    FlightPath flightPath = new FlightPath(mc.player, throwingType);

    while (!flightPath.isCollided()) {
        flightPath.onUpdate();

        flightPoint.offer(new Vec3d(flightPath.position.x - mc.getRenderManager().viewerPosX,
                flightPath.position.y - mc.getRenderManager().viewerPosY,
                flightPath.position.z - mc.getRenderManager().viewerPosZ));
    }

    final boolean bobbing = mc.gameSettings.viewBobbing;
    mc.gameSettings.viewBobbing = false;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(width.getValue());
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    GlStateManager.disableDepth();
    glEnable(GL32.GL_DEPTH_CLAMP);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();

    while (!flightPoint.isEmpty()) {
        bufferbuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
        Vec3d head = flightPoint.poll();
        bufferbuilder.pos(head.x, head.y, head.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();

        if (flightPoint.peek() != null) {
            Vec3d point = flightPoint.peek();
            bufferbuilder.pos(point.x, point.y, point.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();
        }

        tessellator.draw();
    }

    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.enableDepth();
    glDisable(GL32.GL_DEPTH_CLAMP);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();

    mc.gameSettings.viewBobbing = bobbing;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);

    if (flightPath.collided) {
        final RayTraceResult hit = flightPath.target;
        AxisAlignedBB bb = null;

        if (hit.typeOfHit == RayTraceResult.Type.BLOCK) {
            final BlockPos blockpos = hit.getBlockPos();
            final IBlockState iblockstate = mc.world.getBlockState(blockpos);

            if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) {
                final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
                bb = iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z);
            }
        } else if (hit.typeOfHit == RayTraceResult.Type.ENTITY && hit.entityHit != null) {
            final AxisAlignedBB entityBB = hit.entityHit.getEntityBoundingBox();
            if (entityBB != null) {
                bb = new AxisAlignedBB(entityBB.minX - mc.getRenderManager().viewerPosX, entityBB.minY - mc.getRenderManager().viewerPosY, entityBB.minZ - mc.getRenderManager().viewerPosZ, entityBB.maxX - mc.getRenderManager().viewerPosX, entityBB.maxY - mc.getRenderManager().viewerPosY, entityBB.maxZ - mc.getRenderManager().viewerPosZ);
            }
        }

        if (bb != null) {
            RenderUtil.drawBoundingBox(bb, width.getValue(), red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f);
        }
    }
}
 
Example 18
Source File: RenderUtils.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void drawLine(
    Vec3d startPos, Vec3d endPos, int color, boolean smooth, float width) {
  Tessellator tessellator = Tessellator.getInstance();
  BufferBuilder BufferBuilder = tessellator.getBuffer();
  
  Vec3d endVecPos = endPos.subtract(startPos);
  
  float r = (float) (color >> 16 & 255) / 255.0F;
  float g = (float) (color >> 8 & 255) / 255.0F;
  float b = (float) (color & 255) / 255.0F;
  float a = (float) (color >> 24 & 255) / 255.0F;
  
  if (smooth) {
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
  }
  
  GL11.glLineWidth(width);
  
  GlStateManager.pushMatrix();
  GlStateManager.translate(startPos.x, startPos.y, startPos.z);
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  
  BufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
  BufferBuilder.pos(0, 0, 0).color(r, g, b, a).endVertex();
  BufferBuilder.pos(endVecPos.x, endVecPos.y, endVecPos.z).color(r, g, b, a).endVertex();
  tessellator.draw();
  
  if (smooth) {
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
  }
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 19
Source File: RenderUtils.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void drawBox(
    Vec3d startPos, Vec3d endPos, int color, float width, boolean ignoreZ) {
  Tessellator tessellator = Tessellator.getInstance();
  BufferBuilder buffer = tessellator.getBuffer();
  
  Vec3d renderPos = EntityUtils.getInterpolatedPos(getLocalPlayer(), MC.getRenderPartialTicks());
  
  Vec3d min = startPos.subtract(renderPos);
  Vec3d max = endPos.subtract(renderPos);
  
  double minX = min.x, minY = min.y, minZ = min.z;
  double maxX = max.x, maxY = max.y, maxZ = max.z;
  
  float r = (float) (color >> 16 & 255) / 255.0F;
  float g = (float) (color >> 8 & 255) / 255.0F;
  float b = (float) (color & 255) / 255.0F;
  float a = (float) (color >> 24 & 255) / 255.0F;
  
  GlStateManager.pushMatrix();
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  GlStateManager.glLineWidth(width);
  
  if (ignoreZ) {
    GlStateManager.disableDepth();
  }
  
  GlStateManager.color(r, g, b, a);
  
  // GlStateManager.translate(startPos.xCoord, startPos.yCoord, startPos.zCoord);
  
  buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
  buffer.pos(minX, minY, minZ).endVertex();
  buffer.pos(maxX, minY, minZ).endVertex();
  buffer.pos(maxX, minY, maxZ).endVertex();
  buffer.pos(minX, minY, maxZ).endVertex();
  buffer.pos(minX, minY, minZ).endVertex();
  tessellator.draw();
  buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
  buffer.pos(minX, maxY, minZ).endVertex();
  buffer.pos(maxX, maxY, minZ).endVertex();
  buffer.pos(maxX, maxY, maxZ).endVertex();
  buffer.pos(minX, maxY, maxZ).endVertex();
  buffer.pos(minX, maxY, minZ).endVertex();
  tessellator.draw();
  buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
  buffer.pos(minX, minY, minZ).endVertex();
  buffer.pos(minX, maxY, minZ).endVertex();
  buffer.pos(maxX, minY, minZ).endVertex();
  buffer.pos(maxX, maxY, minZ).endVertex();
  buffer.pos(maxX, minY, maxZ).endVertex();
  buffer.pos(maxX, maxY, maxZ).endVertex();
  buffer.pos(minX, minY, maxZ).endVertex();
  buffer.pos(minX, maxY, maxZ).endVertex();
  tessellator.draw();
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 20
Source File: UnicornTrailRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void render(RenderWorldLastEvent event) {
	World world = Minecraft.getMinecraft().world;
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null || world == null) return;

	GlStateManager.pushMatrix();

	double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
	double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
	double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();

	GlStateManager.translate(-interpPosX, -interpPosY + 0.1, -interpPosZ);

	GlStateManager.disableCull();
	GlStateManager.depthMask(false);
	GlStateManager.enableBlend();
	GlStateManager.disableTexture2D();
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
	GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
	GlStateManager.enableColorMaterial();
	GlStateManager.disableLighting();

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vb = tessellator.getBuffer();

	Set<EntityUnicorn> corns = new HashSet<>(positions.keySet());
	for (EntityUnicorn corn : corns) {
		if (corn.world.provider.getDimension() != world.provider.getDimension()) continue;

		List<Point> points = new ArrayList<>(positions.getOrDefault(corn, new ArrayList<>()));
		boolean q = false;

		vb.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR);
		for (Point pos : points) {
			if (pos == null) continue;

			float sub = (world.getTotalWorldTime() - pos.time);
			Color color = Color.getHSBColor(sub % 360.0f / 360.0f, 1f, 1f);

			int alpha;
			if (sub < 500) {
				alpha = (int) (MathHelper.clamp(Math.log(sub + 1) / 2.0, 0, 1) * 80.0);
			} else {
				alpha = (int) (MathHelper.clamp(1 - (Math.log(sub) / 2.0), 0, 1) * 80.0);
			}

			pos(vb, pos.origin.subtract(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
			pos(vb, pos.origin.add(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
			q = !q;
		}

		tessellator.draw();
	}

	GlStateManager.enableCull();
	GlStateManager.depthMask(true);
	GlStateManager.disableBlend();
	GlStateManager.enableTexture2D();
	GlStateManager.shadeModel(GL11.GL_FLAT);
	GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);

	GlStateManager.popMatrix();
}