- 12
- 0
У меня есть капа с информацией о игроке. Одна из переменных игрока, хранящаяся в капе - максимальный переносимый вес.
Работает это вне GUI идеально. Никаких проблем с выводом переменной нет. Но вот когда я решил выводить её в инвентаре - получил вот это
вместо 0.0/30.0.
Когда вывожу через оверлей на экран - получаю абсолютно идентичную картину.
Работает это вне GUI идеально. Никаких проблем с выводом переменной нет. Но вот когда я решил выводить её в инвентаре - получил вот это
вместо 0.0/30.0.
Код:
public class GuiRPGInventory extends GuiContainer {
private float oldMouseX;
private float oldMouseY;
private static final ResourceLocation INVENTORY_GUI_TEXTURE = new ResourceLocation("ethrpg:render/inventory/inventory.png");
public GuiRPGInventory(EntityPlayer player, InventoryPlayer inventoryPlayer, RPGInventory cInventory) {
super(new ContainerRPGPlayer(inventoryPlayer, cInventory, player));
}
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
this.oldMouseX = (float)mouseX;
this.oldMouseY = (float)mouseY;
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
IRpgPlayer rpg = (IRpgPlayer)this.mc.thePlayer.getCapability(RpgPlayerProvider.RPG_PLAYER_CAP, null);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(INVENTORY_GUI_TEXTURE);
int i = this.guiLeft;
int j = this.guiTop;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize + 64, this.ySize+37);
this.string(""+rpg.getGold(), i+99, j+66, 0xFFD900);
this.string(rpg.getPhysicalResist() + " %", i+192, j+13, 0xFFFFFF);
this.string(rpg.getFireResist() + " %", i+192, j+30, 0xFF6D2E);
this.string(rpg.getColdResist() + " %", i+192, j+47, 0xC2FFFE);
this.string(rpg.getDarknessResist() + " %", i+192, j+63, 0x190075);
this.string(rpg.getLightResist() + " %", i+192, j+77, 0xFFFFAD);
if(rpg.getWeight() < rpg.getMaxWeight()) this.string(rpg.getWeight() + "/" + rpg.getMaxWeight() + " kg", i+34, j+174, 0xFFFFFF);
if(rpg.getWeight() == rpg.getMaxWeight()) this.string(rpg.getWeight() + "/" + rpg.getMaxWeight() + " kg", i+34, j+174, 0xFFBF00);
if(rpg.getWeight() > rpg.getMaxWeight()) this.string(rpg.getWeight() + "/" + rpg.getMaxWeight() + " kg", i+34, j+174, 0xFF0000);
GuiInventory.drawEntityOnScreen(i + 50, j + 75, 30, (float)(i + 51) - this.oldMouseX, (float)(j + 75 - 50) - this.oldMouseY, this.mc.thePlayer);
}
public void string(String text, int x, int y, int color) {
FontRenderer font = this.mc.fontRendererObj;
ScaledResolution res = new ScaledResolution(this.mc);
if (y < 0) {
if (x >= 0) {
font.drawString(text, x, res.getScaledHeight() + y, color);
} else {
font.drawString(text, res.getScaledWidth() + x, res.getScaledHeight() + y, color);
}
}
else if (x >= 0) {
font.drawString(text, x, y, color);
} else {
font.drawString(text, res.getScaledWidth() + x, y, color);
}
}
}