use of net.minecraft.client.gui.FontRenderer in project SilentGems by SilentChaos512.
the class EquipmentTooltips method renderForArmor.
private void renderForArmor(RenderTooltipEvent.PostText event, ItemStack stack) {
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fontRenderer = event.getFontRenderer();
ItemArmor itemArmor = (ItemArmor) stack.getItem();
ItemStack currentEquip = StackHelper.empty();
for (ItemStack itemstack : mc.player.getEquipmentAndArmor()) {
Item item = itemstack.getItem();
if (item instanceof ItemArmor && ((ItemArmor) item).armorType == itemArmor.armorType) {
currentEquip = itemstack;
}
}
double scale = 0.75;
int x = (int) (event.getX() / scale);
int y = (int) ((event.getY() - 16) / scale);
int durability = getDurability(stack, 0);
int equippedDurability = getDurability(currentEquip, durability);
float protection = getProtection(stack, 0);
float equippedProtection = getProtection(currentEquip, protection);
float toughness = getToughness(stack, 0);
float equippedToughness = getToughness(currentEquip, toughness);
GlStateManager.pushMatrix();
GlStateManager.color(1f, 1f, 1f, 1f);
GlStateManager.scale(scale, scale, scale);
mc.renderEngine.bindTexture(TEXTURE);
// Durability
x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
// Protection
x = renderStat(mc, fontRenderer, 6, x, y, protection, equippedProtection, StackHelper.isValid(currentEquip));
// Toughness
if (toughness > 0 || equippedToughness > 0)
x = renderStat(mc, fontRenderer, 7, x, y, toughness, equippedToughness, StackHelper.isValid(currentEquip));
lastWidth = (int) (x * scale - event.getX());
GlStateManager.popMatrix();
}
use of net.minecraft.client.gui.FontRenderer in project SilentGems by SilentChaos512.
the class GuiMaterialGrader method drawDebugInfo.
private void drawDebugInfo() {
FontRenderer fontRender = mc.fontRenderer;
int x = 5;
int y = 5;
int yIncrement = 10;
int color = 0xFFFFFF;
GlStateManager.pushMatrix();
float scale = 1f;
GlStateManager.scale(scale, scale, 1f);
for (String str : tileInventory.getDebugLines()) {
fontRender.drawStringWithShadow(str, x, y, color);
y += yIncrement;
}
GlStateManager.popMatrix();
}
use of net.minecraft.client.gui.FontRenderer in project SilentGems by SilentChaos512.
the class GuiQuiverArrowOverlay method renderArrow.
private void renderArrow(ItemStack stack, int count, EntityPlayer player) {
Minecraft mc = Minecraft.getMinecraft();
RenderItem itemRenderer = mc.getRenderItem();
FontRenderer fontRenderer = mc.fontRenderer;
ScaledResolution res = new ScaledResolution(mc);
int y = res.getScaledHeight() - 19;
int x = res.getScaledWidth() / 2 + 97;
itemRenderer.renderItemAndEffectIntoGUI(player, stack, x, y);
// this.itemRenderer.renderItemOverlays(this.mc.fontRenderer, stack, p_184044_1_, p_184044_2_);
String str = Integer.toString(count);
int strWidth = fontRenderer.getStringWidth(str);
fontRenderer.drawStringWithShadow(str, x + 14, y + 9, 0xFFFFFF);
}
use of net.minecraft.client.gui.FontRenderer in project SilentGems by SilentChaos512.
the class ItemTeleporterLinker method renderGameOverlay.
@SideOnly(Side.CLIENT)
public void renderGameOverlay(RenderGameOverlayEvent event) {
if (event.getType() != ElementType.TEXT) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
ItemStack heldItem = mc.player.getHeldItem(EnumHand.MAIN_HAND);
if (StackHelper.isEmpty(heldItem)) {
heldItem = mc.player.getHeldItem(EnumHand.OFF_HAND);
}
if (StackHelper.isValid(heldItem) && heldItem.getItem() == this) {
ScaledResolution res = new ScaledResolution(mc);
FontRenderer fontRender = mc.fontRenderer;
int width = res.getScaledWidth();
int height = res.getScaledHeight();
String str;
if (isLinked(heldItem)) {
DimensionalPosition pos = getLinkedPosition(heldItem);
double x = pos.x - player.posX;
double z = pos.z - player.posZ;
int distance = (int) Math.sqrt(x * x + z * z);
LocalizationHelper loc = SilentGems.instance.localizationHelper;
str = loc.getItemSubText(itemName, "Distance", distance);
int textX = width / 2 - fontRender.getStringWidth(str) / 2;
int textY = height * 3 / 5;
// Text colored differently depending on situation.
// Outside free range, same dimension
int color = 0xffff00;
if (pos.dim != player.dimension) {
// Different dimension
color = 0xff6600;
str = loc.getItemSubText(itemName, "DifferentDimension");
} else if (distance < GemsConfig.TELEPORTER_FREE_RANGE) {
// Inside free range
color = 0x00aaff;
}
fontRender.drawStringWithShadow(str, textX, textY, color);
}
}
}
use of net.minecraft.client.gui.FontRenderer in project Almura by AlmuraDev.
the class MixinTileEntitySignRenderer method render.
/**
* @author Grinch - Steven Downer
* @reason Do not render signposts past a configurable length. Fairly decent client optimization.
*/
@Overwrite
public void render(TileEntitySign te, double x, double y, double z, float partialTicks, int destroyStage, float val) {
final ClientConfiguration config = StaticAccess.config.get();
Block block = te.getBlockType();
GlStateManager.pushMatrix();
float f = 0.6666667F;
if (block == Blocks.STANDING_SIGN) {
GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
float f1 = (float) (te.getBlockMetadata() * 360) / 16.0F;
GlStateManager.rotate(-f1, 0.0F, 1.0F, 0.0F);
this.model.signStick.showModel = true;
} else {
int k = te.getBlockMetadata();
float f2 = 0.0F;
if (k == 2) {
f2 = 180.0F;
}
if (k == 4) {
f2 = 90.0F;
}
if (k == 5) {
f2 = -90.0F;
}
GlStateManager.translate((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(0.0F, -0.3125F, -0.4375F);
this.model.signStick.showModel = false;
}
if (destroyStage >= 0) {
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 2.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
} else {
this.bindTexture(SIGN_TEXTURE);
}
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
GlStateManager.scale(0.6666667F, -0.6666667F, -0.6666667F);
this.model.renderSign();
GlStateManager.popMatrix();
FontRenderer fontrenderer = this.getFontRenderer();
float f3 = 0.010416667F;
GlStateManager.translate(0.0F, 0.33333334F, 0.046666667F);
GlStateManager.scale(0.010416667F, -0.010416667F, 0.010416667F);
GlStateManager.glNormal3f(0.0F, 0.0F, -0.010416667F);
GlStateManager.depthMask(false);
int i = 0;
// Almura start
boolean renderText = te.signText.length > 0;
if (renderText) {
// Greater than 0 means the client has selected a non-Vanilla render distance
if (config.client.signTextRenderDistance > 0) {
EntityLivingBase viewer = (EntityLivingBase) Minecraft.getMinecraft().getRenderViewEntity();
if (viewer == null) {
viewer = Minecraft.getMinecraft().player;
}
if (viewer == null || !te.hasWorld() || te.getDistanceSq(viewer.posX, viewer.posY, viewer.posZ) > (config.client.signTextRenderDistance * 16)) {
renderText = false;
}
}
}
if (renderText && destroyStage < 0) {
// Almura End
for (int j = 0; j < te.signText.length; ++j) {
if (te.signText[j] != null) {
ITextComponent itextcomponent = te.signText[j];
List<ITextComponent> list = GuiUtilRenderComponents.splitText(itextcomponent, 90, fontrenderer, false, true);
String s = list != null && !list.isEmpty() ? ((ITextComponent) list.get(0)).getFormattedText() : "";
if (j == te.lineBeingEdited) {
s = "> " + s + " <";
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, 0);
} else {
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, j * 10 - te.signText.length * 5, 0);
}
}
}
}
GlStateManager.depthMask(true);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
if (destroyStage >= 0) {
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
}
Aggregations