- 1,185
- 3
Есть код, который рендерить что-то на главном экране, пытаюсь растянуть 1 штуковину, а она, вместо растягивания - перемещается. Help!
[merge_posts_bbcode]Добавлено: 11.04.2015 17:36:55[/merge_posts_bbcode]
Строка:
Код:
package com.svk.industrialGuns.Overlays;
import org.lwjgl.opengl.GL11;
import com.svk.industrialGuns.base.ModInfo;
import com.svk.industrialGuns.gunZak.Gun1;
import com.svk.industrialGuns.guns.Guns;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
public class IconOverlay extends Gui
{
private double percentage = 0.0F;
private double percentage2 = 0.0F;
public void renderOverlay(RenderGameOverlayEvent e)
{
ResourceLocation icon = new ResourceLocation(ModInfo.MODID, "textures/gui/gunsbar.png");
Minecraft mc = Minecraft.getMinecraft();
int x = 200;
int y = 36;
mc.renderEngine.bindTexture(icon);
if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null)
{
if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem() instanceof Guns)
{
Guns gun = (Guns) Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem();
ItemStack gunStack = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
double durability = gunStack.getTagCompound().getInteger("ammoCount");
double isDurability = gunStack.getTagCompound().getInteger("count") ;
percentage = isDurability / durability;
double health = gunStack.getTagCompound().getInteger("heating");
double maxHealth = gunStack.getTagCompound().getInteger("maxHeating");
percentage = isDurability / durability;
percentage2 = health / maxHealth;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(e.resolution.getScaledWidth() - 201, e.resolution.getScaledHeight() - 33, 0, 0, x, y);
this.drawTexturedModalRect((int) (e.resolution.getScaledWidth() - 201 + 9 ), e.resolution.getScaledHeight() - 33 + 9, (int) (0 - 95 * ((percentage - 1)*(-1))), 36, 95, 6);
if(maxHealth >= health)
{
this.drawTexturedModalRect((int) (e.resolution.getScaledWidth() - 201 + 9 ), e.resolution.getScaledHeight() - 33 + 9 + 10, (int) (0 - 95 * ((percentage2 - 1)*(-1))), 42, 95, 6);
}
else
{
this.drawTexturedModalRect((int) (e.resolution.getScaledWidth() - 201 + 9 ), e.resolution.getScaledHeight() - 33 + 9 + 10, 0, 42, 95, 6);
}
this.drawTexturedModalRect(e.resolution.getScaledWidth() - 201 + 9, e.resolution.getScaledHeight() - 33 + 9, 0, 54, 95, 6);
this.drawTexturedModalRect(e.resolution.getScaledWidth() - 201 + 9, e.resolution.getScaledHeight() - 33 + 9 + 10, 0, 54, 95, 6);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glScalef(1.0F, 1.0F, 1.0F); //Вот
this.drawTexturedModalRect((int) (e.resolution.getScaledWidth() - 201 + 9 ), e.resolution.getScaledHeight() - 100, 197, 7, 3, 10);
GL11.glPopMatrix();
//Текст
if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count") < 10)
{
drawString(Minecraft.getMinecraft().fontRenderer, String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count")) + " / " + String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("ammoCount")), e.resolution.getScaledWidth() - 62, e.resolution.getScaledHeight() - 18, 3468175);
}
else if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count") < 100)
{
drawString(Minecraft.getMinecraft().fontRenderer, " / " + String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("ammoCount")), e.resolution.getScaledWidth() - 55, e.resolution.getScaledHeight() - 18, 3468175);
drawString(Minecraft.getMinecraft().fontRenderer, String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count")), e.resolution.getScaledWidth() - 62, e.resolution.getScaledHeight() - 18, 3468175);
}
else if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count") < 1000)
{
drawString(Minecraft.getMinecraft().fontRenderer, String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("count")), e.resolution.getScaledWidth() - 68, e.resolution.getScaledHeight() - 18, 3468175);
drawString(Minecraft.getMinecraft().fontRenderer, " / " + String.valueOf(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getTagCompound().getInteger("ammoCount")), e.resolution.getScaledWidth() - 56, e.resolution.getScaledHeight() - 18, 3468175);
}
GL11.glPopMatrix();
}
}
}
}
Строка:
Код:
GL11.glScalef(1.0F, 1.0F, 1.0F); //Вот