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

The following examples show how to use net.minecraft.client.renderer.GlStateManager#scale() . 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: MixinModelPlayer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @author 9Y0, Mojang
 * @reason body parts
 */
@Overwrite
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) {
    super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
    GlStateManager.pushMatrix();

    if (isChild) {
        float f = 2.0F;
        GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);
        GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
    } else {
        if (entityIn.isSneaking()) GlStateManager.translate(0.0F, 0.2F, 0.0F);
    }

    bipedLeftLegwear.render(scale);
    bipedRightLegwear.render(scale);
    bipedLeftArmwear.render(scale);
    bipedRightArmwear.render(scale);
    bipedBodyWear.render(scale);
    bipedLeftForeArmwear.render(scale);
    bipedLeftForeArm.render(scale);
    bipedRightForeArmwear.render(scale);
    bipedRightForeArm.render(scale);
    bipedLeftLowerLeg.render(scale);
    bipedLeftLowerLegwear.render(scale);
    bipedRightLowerLeg.render(scale);
    bipedRightLowerLegwear.render(scale);
    butt.render(scale);

    GlStateManager.popMatrix();
}
 
Example 2
Source File: RenderHand.java    From pycode-minecraft with MIT License 5 votes vote down vote up
public void doRender(@Nonnull HandEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    this.bindEntityTexture(entity);
    float f3 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;

    GlStateManager.translate((float)x, (float)y + 0.7F, (float)z);
    GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-f3, 0.0F, 0.0F, 1.0F);

    if (this.renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }

    GlStateManager.scale(-1.0F, -1.0F, 1.0F);
    model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GlStateManager.popMatrix();

    if (this.renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    } else {
        this.renderName(entity, x, y, z);
    }

    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 3
Source File: RenderDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void preRenderCallback(EntityDabSquirrel entitylivingbaseIn, float partialTickTime) {
	if (this.getMainModel().isChild) {
		GlStateManager.scale(4.35D, 4.35D, 4.35D);
	} else {
		GlStateManager.scale(4.5D, 4.5D, 4.5D);
	}
}
 
Example 4
Source File: SurfaceHelper.java    From ForgeHax with MIT License 5 votes vote down vote up
public static void drawText(String msg, int x, int y, int color, double scale, boolean shadow) {
  GlStateManager.pushMatrix();
  GlStateManager.disableDepth();
  GlStateManager.scale(scale, scale, scale);
  MC.fontRenderer.drawString(
      msg, (int) (x * (1 / scale)), (int) (y * (1 / scale)), color, shadow);
  GlStateManager.enableDepth();
  GlStateManager.popMatrix();
}
 
Example 5
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void glBillboardDistanceScaled(float x, float y, float z, EntityPlayer player, float scale) {
    glBillboard(x, y, z);
    int distance = (int) player.getDistance(x, y, z);
    float scaleDistance = (distance / 2.0f) / (2.0f + (2.0f - scale));
    if (scaleDistance < 1f)
        scaleDistance = 1;
    GlStateManager.scale(scaleDistance, scaleDistance, scaleDistance);
}
 
Example 6
Source File: CustomCrosshair.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void drawDebugAxisCrosshair(int screenWidth, int screenHeight) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) screenWidth, (float) screenHeight, 0.0f);
    Entity entity = mc.getRenderViewEntity();
    GlStateManager.rotate(
        entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * 1.0f,
        -1.0f, 0.0f, 0.0f);
    GlStateManager
        .rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * 1.0f,
            0.0f, 1.0f, 0.0f);
    GlStateManager.scale(-1.0f, -1.0f, -1.0f);
    GlStateManager.disableTexture2D();
    GlStateManager.depthMask(false);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(GL11.GL_CLIENT_PIXEL_STORE_BIT, DefaultVertexFormats.POSITION_COLOR);
    GL11.glLineWidth(2.0f);
    worldrenderer.pos(0.0, 0.0, 0.0).color(255, 0, 0, 255).endVertex();
    worldrenderer.pos(10.0, 0.0, 0.0).color(255, 0, 0, 255).endVertex();
    worldrenderer.pos(0.0, 0.0, 0.0).color(0, 255, 0, 255).endVertex();
    worldrenderer.pos(0.0, 10.0, 0.0).color(0, 255, 0, 255).endVertex();
    worldrenderer.pos(0.0, 0.0, 0.0).color(0, 0, 255, 255).endVertex();
    worldrenderer.pos(0.0, 0.0, 10.0).color(0, 0, 255, 255).endVertex();
    tessellator.draw();
    GL11.glLineWidth(1.0f);
    GlStateManager.depthMask(true);
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example 7
Source File: GuiComponent.java    From AgriCraft with MIT License 5 votes vote down vote up
public final void renderComponent(AgriGuiWrapper gui) {
    if (this.isVisible && this.renderAction != null) {
        GlStateManager.pushAttrib();
        GlStateManager.pushMatrix();
        GlStateManager.translate(this.bounds.x, this.bounds.y, 0);
        GlStateManager.scale(scale, scale, scale);
        GlStateManager.color(1, 1, 1, 1);
        this.renderAction.accept(gui, this);
        GlStateManager.popMatrix();
        GlStateManager.popAttrib();
    }
}
 
Example 8
Source File: ModelOwl.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public void render(Entity entity, float time, float limbSwing, float f2, float headY, float headX, float scale) {
  super.render(entity, time, limbSwing, f2, headY, headX, scale);

  setRotationAngles(time, limbSwing, f2, headY, headX, scale, entity);

  float height = 25;
  // float owlScale = 0.65f;
  float owlScale = 1f;
  float transFactor = 1 - owlScale;

  if (isChild) {

    float headScale = owlScale * 0.6f;
    owlScale *= 0.5f;
    float translateScale = 1 - owlScale;
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, translateScale * (height - 2) * scale, 0.0F);
    GlStateManager.scale(headScale, headScale, headScale);
    head.render(scale);
    GlStateManager.popMatrix();

    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, translateScale * height * scale, 0.0F);
    GlStateManager.scale(owlScale, owlScale, owlScale);

    body.render(scale);
    GlStateManager.popMatrix();
  } else {

    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, transFactor * height * scale, 0.0F);
    GlStateManager.scale(owlScale, owlScale, owlScale);

    head.render(scale);
    body.render(scale);

    GlStateManager.popMatrix();
  }
}
 
Example 9
Source File: ModelOvergrownSheepFur.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
	this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);

	if (this.isChild)
	{
		GlStateManager.pushMatrix();
		GlStateManager.translate(0.0F, this.childYOffset * scale, this.childZOffset * scale);
		this.head.render(scale);
		GlStateManager.popMatrix();
		GlStateManager.pushMatrix();
		GlStateManager.scale(0.5F, 0.5F, 0.5F);
		GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
		this.body.render(scale);
		this.leg1.render(scale);
		this.leg2.render(scale);
		this.leg3.render(scale);
		this.leg4.render(scale);
		GlStateManager.popMatrix();
	}
	else
	{
		this.leg1.render(scale);
		this.leg2.render(scale);
		this.leg3.render(scale);
		this.leg4.render(scale);
		this.head.render(scale);

		GlStateManager.pushMatrix();
		float sc = entityIn.getDataManager().get(EntityOvergrownSheep.GROWTH);
		GlStateManager.scale(sc, sc, sc);
		float tran = Math.max(0, -1F + (sc / 1.25F));
		GlStateManager.translate(0F, -tran, 0);
		this.body.render(scale);

		GlStateManager.popMatrix();
	}
}
 
Example 10
Source File: ButtonBanner.java    From SkyblockAddons with MIT License 5 votes vote down vote up
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (bannerImage != null && banner == null) { // This means it was just loaded from the URL above.
        banner = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("banner", new DynamicTexture(bannerImage));
    }

    if (banner != null) { // Could have not been loaded yet.
        float alphaMultiplier = 1F;
        if (main.getUtils().isFadingIn()) {
            long timeSinceOpen = System.currentTimeMillis() - timeOpened;
            int fadeMilis = 500;
            if (timeSinceOpen <= fadeMilis) {
                alphaMultiplier = (float) timeSinceOpen / fadeMilis;
            }
        }

        float scale = (float) WIDTH / bannerImage.getWidth(); // max width

        hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition +
                WIDTH && mouseY < yPosition + bannerImage.getHeight() * scale;
        GlStateManager.enableBlend();

        if (hovered) {
            GlStateManager.color(1, 1, 1, alphaMultiplier * 1);
        } else {
            GlStateManager.color(1, 1, 1, alphaMultiplier * 0.8F);
        }

        mc.getTextureManager().bindTexture(banner);
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, 1);
        drawModalRectWithCustomSizedTexture(Math.round(xPosition / scale),
                Math.round(yPosition / scale), 0, 0, width, height, width, height);
        GlStateManager.popMatrix();
    }
}
 
Example 11
Source File: ModelUnicorn.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	EntityUnicorn unicorn = (EntityUnicorn) entityIn;
	float f = unicorn.getGrassEatingAmount(0.0F);
	boolean flag = unicorn.isChild();
	float f1 = unicorn.getSize();

	if (!flag) {
		GlStateManager.pushMatrix();
		GlStateManager.scale(f1, 0.5F + f1 * 0.5F, f1);
		GlStateManager.translate(0.0F, 0.95F * (1.0F - f1), 0.0F);
	}

	this.backLeftLeg.render(scale);
	this.backLeftShin.render(scale);
	this.backLeftHoof.render(scale);
	this.backRightLeg.render(scale);
	this.backRightShin.render(scale);
	this.backRightHoof.render(scale);
	this.frontLeftLeg.render(scale);
	this.frontLeftShin.render(scale);
	this.frontLeftHoof.render(scale);
	this.frontRightLeg.render(scale);
	this.frontRightShin.render(scale);
	this.frontRightHoof.render(scale);

	if (!flag) {
		GlStateManager.popMatrix();
		GlStateManager.pushMatrix();
		GlStateManager.scale(f1, f1, f1);
		GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F);
	}

	this.body.render(scale);
	this.tailBase.render(scale);
	this.tailMiddle.render(scale);
	this.tailTip.render(scale);
	this.neck.render(scale);
	this.mane.render(scale);

	if (!flag) {
		GlStateManager.popMatrix();
		GlStateManager.pushMatrix();
		float f2 = 0.5F + f1 * f1 * 0.5F;
		GlStateManager.scale(f2, f2, f2);

		if (f <= 0.0F) {
			GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F);
		} else {
			GlStateManager.translate(0.0F, 0.9F * (1.0F - f1) * f + 1.35F * (1.0F - f1) * (1.0F - f), 0.15F * (1.0F - f1) * f);
		}
	}

	this.horseLeftEar.render(scale);
	this.horseRightEar.render(scale);

	this.head.render(scale);
	this.horn.render(scale);

	if (!flag) {
		GlStateManager.popMatrix();
	}
}
 
Example 12
Source File: PurchaseCarousel.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void render(int centerX, int centerY, int mouseX, int mouseY) {
    activeBlock = null;
    ScaledResolution current = ResolutionUtil.current();
    int totalWidth = current.getScaledWidth() / 3;
    int panel = totalWidth / 5;
    int mainWidth = panel * 3;
    int sideHeight = current.getScaledHeight() / 5 * 2;
    int mainHeight = current.getScaledHeight() / 5 * 3;
    int objLeft = centerX - mainWidth / 2;
    int objBottom = centerY + mainHeight / 2;
    int objRight = centerX + mainWidth / 2;

    if (index > 0) {
        //Draw left side
        RenderUtils.drawSmoothRect(centerX - panel * 2, centerY - sideHeight / 2, centerX,
            centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB());
    }
    if (index < items.length - 1) {
        RenderUtils.drawSmoothRect(centerX, centerY - sideHeight / 2, centerX + panel * 2,
            centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB());
    }

    RenderUtils.drawSmoothRect(objLeft, centerY - mainHeight / 2, objRight, objBottom, 10, new Color(23, 23, 23, 255).getRGB());
    CarouselItem item = items[index];
    GlStateManager.scale(.5, .5, .5);

    int barHeight = 16;
    fr.drawString(item.getName(), (objLeft + 5) * 2, (objBottom - 50) * 2, Color.WHITE.getRGB());
    int purchaseRight = (objLeft + 50) * 2;

    RenderUtils.drawSmoothRect((objLeft + 5) * 2, (objBottom - 20) * 2, purchaseRight,
        (objBottom - 20 + barHeight) * 2, 10, Color.WHITE.getRGB());

    GlStateManager.scale(2 / 3F, 2 / 3F, 2 / 3F);

    fr.drawString(item.isPurchased() ? I18n.format("gui.purchase.purchased") : I18n.format("gui.purchase.purchase"),
        (objLeft + 5) * 3, (objBottom - 18) * 3, new Color(23, 23, 23, 255).getRGB());

    GlStateManager.scale(3 / 2F, 3 / 2f, 3 / 2F);

    RenderUtils.drawFilledCircle(purchaseRight + barHeight * 2, (objBottom - 12) * 2, barHeight, Color.WHITE.getRGB());
    GlStateManager.color(0, 0, 0);

    Icons.SETTINGS.bind();
    Gui.drawScaledCustomSizeModalRect(purchaseRight + barHeight, (objBottom - 20) * 2, 0, 0,
        144, 144, barHeight * 2, barHeight * 2, 144, 144);

    GlStateManager.scale(2.0, 2.0, 2.0);

    if (mouseX >= objLeft - 8 && mouseX <= objLeft && mouseY >= centerY - 5 && mouseY <= centerY + 5) {
        if (!lhover) {
            lhover = true;
            larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.3f);
        }
    } else if (lhover) {
        lhover = false;
        larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.5f);
    }

    float v = larrow.getValue();
    GlStateManager.scale(v, v, v);
    fr.drawCenteredString("<", (objLeft - 5) / v, centerY / v - 10, 0xffffff);
    GlStateManager.scale(1 / v, 1 / v, 1 / v);

    if (mouseX >= objRight && mouseX <= objRight + 8 && mouseY >= centerY - 5 && mouseY <= centerY + 5) {
        if (!rhover) {
            rhover = true;
            rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.3f);
        }
    } else if (rhover) {
        rhover = false;
        rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.5f);
    }

    v = rarrow.getValue();
    GlStateManager.scale(v, v, v);
    fr.drawCenteredString(">", (objRight + 5) / v, centerY / v - 10, 0xffffff);

    GlStateManager.scale(1 / v, 1 / v, 1 / v);
    String s = I18n.format("gui.purchase.state") + ": " + (getCurrent().isPurchased() ? (getCurrent().isActive() ?
        I18n.format("gui.purchase.active") : I18n.format("gui.purchase.inactive")) : I18n.format("gui.purchase.notpurchased"));
    float e = .5F;

    GlStateManager.scale(e, e, e);
    fr.drawString(s, (centerX - fr.getWidth(s) / 4) / e, (centerY - mainHeight / 2f + 15) / e, Color.GREEN.getRGB());

    if (getCurrent().isPurchased() && !getCurrent().isActive()) {
        s = I18n.format("gui.purchase.clicktouse");
        float width = fr.getWidth(s);
        float x = centerX - width / 4;
        int i = centerY - mainHeight / 2 + 35;
        activeBlock = new GuiBlock((int) x, (int) (x + width * 2), i, i + 10);
        fr.drawString(s, x / e, i / e, Color.GREEN.getRGB());
    }

    GlStateManager.scale(1 / e, 1 / e, 1 / e);
}
 
Example 13
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
private static void renderEnchanted(IBackpack backpack, BlockModelRenderer renderer,
                                    float ticks, boolean renderStraps) {
	
	Minecraft mc = Minecraft.getMinecraft();
	float glintStrength = WearableBackpacks.CONFIG.cosmetic.enchantEffectOpacity.get().floatValue();
	if (glintStrength <= 0) return;
	float glintScale   = 1.5F;
	float animProgress = ticks / 10;
	
	int color = IntermodUtils.getRuneColor(backpack.getStack());
	float r = (color >> 16 & 0xFF) / 255.0F * glintStrength;
	float g = (color >>  8 & 0xFF) / 255.0F * glintStrength;
	float b = (color       & 0xFF) / 255.0F * glintStrength;
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	mc.entityRenderer.setupFogColor(true);
	
	GlStateManager.disableLighting();
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(GL11.GL_EQUAL);
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.scale(glintScale, glintScale, glintScale);
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		renderModel(backpack, renderer, ticks, renderStraps, r, g, b, true);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
	GlStateManager.depthFunc(GL11.GL_LEQUAL);
	GlStateManager.depthMask(true);
	GlStateManager.enableLighting();
	
	mc.entityRenderer.setupFogColor(false);
	
}
 
Example 14
Source File: TileCraftingPlateRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, int destroyStage, float alpha) {
	ArrayList<BlockPos> errors = new ArrayList<>(((IStructure) tile.getBlockType()).testStructure(tile.getWorld(), tile.getPos()));
	errors.sort(Vec3i::compareTo);

	ItemStack input = tile.getInput();
	if (input.isEmpty()) {
		input = tile.getOutput();
		if (input.isEmpty()) {
			input = ItemStack.EMPTY;
		}
	}

	ICraftingPlateRecipe recipeForItem = CraftingPlateRecipeManager.getRecipe(tile.getWorld(), tile.getPos(), input);
	if (recipeForItem != null) recipeForItem.renderInput(tile.getWorld(), tile.getPos(), input, partialTicks);

	if (!errors.isEmpty() && tile.revealStructure && tile.getBlockType() instanceof IStructure) {
		ModStructures.structureManager.draw(ModStructures.CRAFTING_PLATE, (float) (Math.sin(ClientTickHandler.getTicks() / 10.0) + 1) / 10.0f + 0.3f);
	}

	if (!errors.isEmpty()) {
		for (BlockPos error : errors) {
			StructureErrorRenderer.addError(error);
		}
		return;
	} else if (tile.getWorld().isAirBlock(tile.getPos().offset(EnumFacing.UP)) && !CraftingPlateRecipeManager.doesRecipeExist(tile.getWorld(), tile.getPos(), input) && RandUtil.nextInt(4) == 0) {
		LibParticles.CRAFTING_ALTAR_IDLE(tile.getWorld(), new Vec3d(tile.getPos()).add(0.5, 0.7, 0.5));
	}

	// render each item at its current position
	final int mapSize = hoveringStacks.size();
	for (HoveringStack hoveringStack : hoveringStacks.values()) {

		if (!hoveringStack.stack.isEmpty()) {

			{
				GlStateManager.pushMatrix();
				GlStateManager.translate(0.5 + hoveringStack.location.x, 1 + hoveringStack.location.y, 0.5 + hoveringStack.location.z);
				GlStateManager.scale(0.3, 0.3, 0.3);
				GlStateManager.rotate((hoveringStack.randX + ClientTickHandler.getTicks()), 0, 1, 0);
				GlStateManager.rotate((hoveringStack.randY + ClientTickHandler.getTicks()), 1, 0, 0);
				GlStateManager.rotate((hoveringStack.randZ + ClientTickHandler.getTicks()), 0, 0, 1);

				GlStateManager.enableLighting();
				RenderHelper.disableStandardItemLighting();
				Minecraft.getMinecraft().getRenderItem().renderItem(hoveringStack.stack, TransformType.NONE);
				RenderHelper.enableStandardItemLighting();
				GlStateManager.popMatrix();
			}

			if (tile.suckingCooldown <= 0) {
				if (RandUtil.nextInt(mapSize / 2) == 0) {
					LibParticles.CLUSTER_DRAPE(
							tile.getWorld(),
							hoveringStack.location.add(new Vec3d(tile.getPos())).add(0.5, 0.5, 0.5));
				}
			} else {
				if (RandUtil.nextInt(mapSize) == 0) {
					LibParticles.CRAFTING_ALTAR_CLUSTER_SUCTION(
							tile.getWorld(),
							new Vec3d(tile.getPos()).add(0.5, 0.75, 0.5),
							new InterpBezier3D(hoveringStack.location, new Vec3d(0, 0, 0)));
				}
			}
		}
	}
}
 
Example 15
Source File: HyperiumFontRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int drawString(String text, float x, float y, int color) {
    if (text == null) return 0;

    ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft());

    try {
        if (resolution.getScaleFactor() != prevScaleFactor) {
            prevScaleFactor = resolution.getScaleFactor();
            unicodeFont = new UnicodeFont(getFontByName(name).deriveFont(size * prevScaleFactor / 2));
            unicodeFont.addAsciiGlyphs();
            unicodeFont.getEffects().add(new ColorEffect(java.awt.Color.WHITE));
            unicodeFont.loadGlyphs();
        }
    } catch (FontFormatException | IOException | SlickException e) {
        e.printStackTrace();
    }

    this.antiAliasingFactor = resolution.getScaleFactor();

    GL11.glPushMatrix();
    GlStateManager.scale(1 / antiAliasingFactor, 1 / antiAliasingFactor, 1 / antiAliasingFactor);
    x *= antiAliasingFactor;
    y *= antiAliasingFactor;
    float originalX = x;
    float red = (float) (color >> 16 & 255) / 255.0F;
    float green = (float) (color >> 8 & 255) / 255.0F;
    float blue = (float) (color & 255) / 255.0F;
    float alpha = (float) (color >> 24 & 255) / 255.0F;
    GlStateManager.color(red, green, blue, alpha);

    int currentColor = color;

    char[] characters = text.toCharArray();

    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    String[] parts = COLOR_CODE_PATTERN.split(text);
    int index = 0;
    for (String s : parts) {
        for (String s2 : s.split("\n")) {
            for (String s3 : s2.split("\r")) {

                unicodeFont.drawString(x, y, s3, new org.newdawn.slick.Color(currentColor));
                x += unicodeFont.getWidth(s3);

                index += s3.length();
                if (index  < characters.length && characters[index ] == '\r') {
                    x = originalX;
                    index++;
                }
            }
            if (index < characters.length && characters[index] == '\n') {
                x = originalX;
                y += getHeight(s2) * 2;
                index++;
            }
        }
        if (index < characters.length) {
            char colorCode = characters[index];
            if (colorCode == 'ยง') {
                char colorChar = characters[index + 1];
                int codeIndex = ("0123456789" +
                    "abcdef").indexOf(colorChar);
                if (codeIndex < 0) {
                    if (colorChar == 'r') {
                        currentColor = color;
                    }
                } else {
                    currentColor = colorCodes[codeIndex];
                }
                index += 2;
            }
        }
    }

    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.bindTexture(0);
    GlStateManager.popMatrix();
    return (int) x;
}
 
Example 16
Source File: HyperiumGuiNewChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void drawChat(int updateCounter, List<ChatLine> drawnChatLines, int scrollPos, boolean isScrolled, Minecraft mc) {
    if (mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) {
        int i = parent.getLineCount();
        boolean flag = false;
        int j = 0;
        int k = drawnChatLines.size();
        float f = mc.gameSettings.chatOpacity * 0.9F + 0.1F;

        if (k > 0) {
            if (parent.getChatOpen()) flag = true;

            float f1 = parent.getChatScale();
            int l = MathHelper.ceiling_float_int((float) parent.getChatWidth() / f1);
            GlStateManager.pushMatrix();
            GlStateManager.translate(2.0F, 20.0F, 0.0F);
            GlStateManager.scale(f1, f1, 1.0F);

            for (int i1 = 0; i1 + scrollPos < drawnChatLines.size() && i1 < i; ++i1) {
                ChatLine chatline = drawnChatLines.get(i1 + scrollPos);

                if (chatline != null) {
                    int j1 = updateCounter - chatline.getUpdatedCounter();

                    if (j1 < 200 || flag) {
                        double d0 = (double) j1 / 200.0D;
                        d0 = 1.0D - d0;
                        d0 = d0 * 10.0D;
                        d0 = MathHelper.clamp_double(d0, 0.0D, 1.0D);
                        d0 = d0 * d0;
                        int l1 = (int) (255.0D * d0);

                        if (flag) l1 = 255;

                        l1 = (int) ((float) l1 * f);
                        ++j;

                        if (l1 > 3) {
                            int i2 = 0;
                            int j2 = -i1 * 9;
                            if (!Settings.FASTCHAT)
                                Gui.drawRect(i2, j2 - 9, i2 + l + 4, j2, l1 / 2 << 24);
                            String s = chatline.getChatComponent().getFormattedText();
                            GlStateManager.enableBlend();
                            mc.fontRendererObj.drawStringWithShadow(s, (float) i2, (float) (j2 - 8), 16777215 + (l1 << 24));
                            GlStateManager.disableAlpha();
                            GlStateManager.disableBlend();
                        }
                    }
                }
            }

            if (flag) {
                int k2 = mc.fontRendererObj.FONT_HEIGHT;
                GlStateManager.translate(-3.0F, 0.0F, 0.0F);
                int l2 = k * k2 + k;
                int i3 = j * k2 + j;
                int j3 = scrollPos * i3 / k;
                int k1 = i3 * i3 / l2;

                if (l2 != i3) {
                    int k3 = j3 > 0 ? 170 : 96;
                    int l3 = isScrolled ? 13382451 : 3355562;
                    Gui.drawRect(0, -j3, 2, -j3 - k1, l3 + (k3 << 24));
                    Gui.drawRect(2, -j3, 1, -j3 - k1, 13421772 + (k3 << 24));
                }
            }

            GlStateManager.popMatrix();
        }
    }
}
 
Example 17
Source File: ElementRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void endDrawing(DisplayElement element) {
    GlStateManager.scale(1.0 / element.getScale(), 1.0 / element.getScale(), 1.0 / element.getScale());

    GlStateManager.popMatrix();
}
 
Example 18
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 4 votes vote down vote up
public void renderItemInFirstPerson(AbstractClientPlayer p_187457_1_, float p_187457_2_, float p_187457_3_, EnumHand p_187457_4_, float p_187457_5_, @Nullable ItemStack p_187457_6_, float p_187457_7_)
{
	boolean flag = p_187457_4_ == EnumHand.MAIN_HAND;
	EnumHandSide enumhandside = flag ? p_187457_1_.getPrimaryHand() : p_187457_1_.getPrimaryHand().opposite();
	GlStateManager.pushMatrix();

	if (p_187457_6_ == null)
	{
		if (flag && !p_187457_1_.isInvisible())
		{
			
			this.renderArmFirstPerson(p_187457_7_, p_187457_5_, enumhandside);
		}
	}
	else if (p_187457_6_.getItem() instanceof net.minecraft.item.ItemMap)
	{
		if (flag && itemStackOffHand == null)
		{
			this.renderMapFirstPerson(p_187457_3_, p_187457_7_, p_187457_5_);
		}
		else
		{
			this.renderMapFirstPersonSide(p_187457_7_, enumhandside, p_187457_5_, p_187457_6_);
		}
	}
	else
	{
		boolean flag1 = enumhandside == EnumHandSide.RIGHT;

		if (p_187457_1_.isHandActive() && p_187457_1_.getItemInUseCount() > 0 && p_187457_1_.getActiveHand() == p_187457_4_)
		{
			int j = flag1 ? 1 : -1;

			switch (p_187457_6_.getItemUseAction())
			{
				case NONE:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case EAT:
				case DRINK:
					this.transformEatFirstPerson(p_187457_2_, enumhandside, p_187457_6_);
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BLOCK:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					break;
				case BOW:
					this.transformSideFirstPerson(enumhandside, p_187457_7_);
					GlStateManager.translate((float)j * -0.2785682F, 0.18344387F, 0.15731531F);
					GlStateManager.rotate(-13.935F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate((float)j * 35.3F, 0.0F, 1.0F, 0.0F);
					GlStateManager.rotate((float)j * -9.785F, 0.0F, 0.0F, 1.0F);
					float f5 = (float)p_187457_6_.getMaxItemUseDuration() - ((float)this.mc.thePlayer.getItemInUseCount() - p_187457_2_ + 1.0F);
					float f6 = f5 / 20.0F;
					f6 = (f6 * f6 + f6 * 2.0F) / 3.0F;

					if (f6 > 1.0F)
					{
						f6 = 1.0F;
					}

					if (f6 > 0.1F)
					{
						float f7 = MathHelper.sin((f5 - 0.1F) * 1.3F);
						float f3 = f6 - 0.1F;
						float f4 = f7 * f3;
						GlStateManager.translate(f4 * 0.0F, f4 * 0.004F, f4 * 0.0F);
					}

					GlStateManager.translate(f6 * 0.0F, f6 * 0.0F, f6 * 0.04F);
					GlStateManager.scale(1.0F, 1.0F, 1.0F + f6 * 0.2F);
					GlStateManager.rotate((float)j * 45.0F, 0.0F, -1.0F, 0.0F);
			}
		}
		else
		{
			float f = -0.4F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * (float)Math.PI);
			float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt_float(p_187457_5_) * ((float)Math.PI * 2F));
			float f2 = -0.2F * MathHelper.sin(p_187457_5_ * (float)Math.PI);
			int i = flag1 ? 1 : -1;
			GlStateManager.translate((float)i * f, f1, f2);
			this.transformSideFirstPerson(enumhandside, p_187457_7_);
			this.transformFirstPerson(enumhandside, p_187457_5_);
		}

		this.renderItemSide(p_187457_1_, p_187457_6_, flag1 ? ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND : ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, !flag1);
	}

	GlStateManager.popMatrix();
}
 
Example 19
Source File: RocketEventHandler.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
private void renderModuleSlots(ItemStack armorStack, int slot, RenderGameOverlayEvent event) {
	int index = 1;
	float color = 0.85f + 0.15F*MathHelper.sin( 2f*(float)Math.PI*((Minecraft.getMinecraft().world.getTotalWorldTime()) % 60)/60f );
	BufferBuilder buffer = Tessellator.getInstance().getBuffer();
	GlStateManager.enableBlend();
	GlStateManager.enableAlpha();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	float alpha = 0.6f;


	if( armorStack != null ) {

		boolean modularArmorFlag = armorStack.getItem() instanceof IModularArmor;

		if(modularArmorFlag || ItemAirUtils.INSTANCE.isStackValidAirContainer(armorStack)) {

			int size = 24;
			int screenY = suitPanel.getRenderY() + (slot-1)*(size + 8);
			int screenX = suitPanel.getRenderX();

			//Draw BG
			GL11.glColor4f(1f,1f,1f, 1f);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
			RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX - 4, screenY - 4, screenX + size, screenY + size + 4,0d,0.5d,0d,1d);
			Tessellator.getInstance().draw();

			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
			RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX + size, screenY - 3, screenX + 2 + size, screenY + size + 3,0.5d,0.5d,0d,0d);
			Tessellator.getInstance().draw();

			//Draw Icon
			GlStateManager.color(color,color,color, color);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.armorSlots[slot-1]);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
			RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX, screenY, screenX + size, screenY + size,0d,1d,1d,0d);
			Tessellator.getInstance().draw();

			if(modularArmorFlag) {
				List<ItemStack> stacks = ((IModularArmor)armorStack.getItem()).getComponents(armorStack);
				for(ItemStack stack : stacks) {
					GL11.glColor4f(1f, 1f, 1f, 1f);
					((IArmorComponent)stack.getItem()).renderScreen(stack, stacks, event, this);

					ResourceIcon icon = ((IArmorComponent)stack.getItem()).getComponentIcon(stack);
					ResourceLocation texture = null; 
					if(icon != null) 
						texture= icon.getResourceLocation();

					//if(texture != null) {

					screenX = suitPanel.getRenderX() + 4 + index*(size+2);

					//Draw BG

					Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG);
					buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
					RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel -1, screenX - 4, screenY - 4, screenX + size - 2, screenY + size + 4,0.5d,0.5d,0d,1d);
					Tessellator.getInstance().draw();




					if(texture != null) {
						//Draw Icon
						Minecraft.getMinecraft().renderEngine.bindTexture(texture);
						GlStateManager.color(color,color,color, alpha);
						buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
						RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX, screenY, screenX + size, screenY + size, icon.getMinU(),icon.getMaxU(), icon.getMaxV(),icon.getMinV());
						Tessellator.getInstance().draw();
					}
					else {
						GL11.glPushMatrix();
						GlStateManager.translate(screenX , screenY, 0);
						GlStateManager.scale(1.5f, 1.5f, 1.5f);
						Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack,  0,0);
						GL11.glPopMatrix();
					}

					index++;
					//}
				}
			}

			screenX = (index)*(size+2) + suitPanel.getRenderX() - 12;
			//Draw BG
			GlStateManager.color(1,1,1, 1f);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.frameHUDBG);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
			RenderHelper.renderNorthFaceWithUV(buffer, this.zLevel-1, screenX + 12, screenY - 4, screenX + size, screenY + size + 4,0.75d,1d,0d,1d);
			Tessellator.getInstance().draw();
		}
	}

	GlStateManager.disableAlpha();
}
 
Example 20
Source File: IslandWarpGui.java    From SkyblockAddons with MIT License 4 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    ScaledResolution sr = new ScaledResolution(mc);
    int guiScale = sr.getScaleFactor();

    int startColor = new Color(0,0, 0, Math.round(255/3F)).getRGB();
    int endColor = new Color(0,0, 0, Math.round(255/2F)).getRGB();
    drawGradientRect(0, 0, sr.getScaledWidth(), sr.getScaledHeight(), startColor, endColor);

    drawCenteredString(mc.fontRendererObj, "Click a warp point to travel there!", sr.getScaledWidth()/2, 10, 0xFFFFFFFF);
    drawCenteredString(mc.fontRendererObj, "Must have the specific scroll unlocked.", sr.getScaledWidth()/2, 20, 0xFFFFFFFF);

    GlStateManager.pushMatrix();
    ISLAND_SCALE = 0.7F/1080*mc.displayHeight;
    float scale = ISLAND_SCALE;
    GlStateManager.scale(1F/guiScale, 1F/guiScale, 1);
    GlStateManager.scale(scale, scale, 1);

    float totalWidth = TOTAL_WIDTH*scale;
    float totalHeight = TOTAL_HEIGHT*scale;

    SHIFT_LEFT = (mc.displayWidth/2F-totalWidth/2F)/scale;
    SHIFT_TOP = (mc.displayHeight/2F-totalHeight/2F)/scale;
    GlStateManager.translate(SHIFT_LEFT, SHIFT_TOP, 0);

    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();

    IslandButton lastHoveredButton = null;

    for (GuiButton button : buttonList) {
        if (button instanceof IslandButton) {
            IslandButton islandButton = (IslandButton)button;

            // Call this just so it calculates the hover, don't actually draw.
            islandButton.drawButton(mc, mouseX, mouseY, false);

            if (islandButton.isHovering()) {
                if (lastHoveredButton != null) {
                    lastHoveredButton.setDisableHover(true);
                }
                lastHoveredButton = islandButton;
            }
        }
    }

    for (GuiButton guiButton : this.buttonList) {
        guiButton.drawButton(this.mc, mouseX, mouseY);
    }


    int x = Math.round(mc.displayWidth/ISLAND_SCALE-SHIFT_LEFT-500);
    int y = Math.round(mc.displayHeight/ISLAND_SCALE-SHIFT_TOP);
    GlStateManager.pushMatrix();
    float textScale = 3F;
    GlStateManager.scale(textScale, textScale, 1);
    if (guiIsActualWarpMenu) {
        mc.fontRendererObj.drawStringWithShadow(Feature.WARP_ADVANCED_MODE.getMessage(), x / textScale + 50, (y - 30 - 60 * 3) / textScale + 5, 0xFFFFFFFF);
        mc.fontRendererObj.drawStringWithShadow(Feature.FANCY_WARP_MENU.getMessage(), x / textScale + 50, (y - 30 - 60 * 2) / textScale + 5, 0xFFFFFFFF);
    }
    mc.fontRendererObj.drawStringWithShadow(Feature.DOUBLE_WARP.getMessage(), x / textScale + 50, (y - 30 - 60) / textScale + 5, 0xFFFFFFFF);
    GlStateManager.popMatrix();

    GlStateManager.popMatrix();

    detectClosestMarker(mouseX, mouseY);
}