- 55
- 1
- 1
Привет всем! Делаю GUI, хотел сделать ввод текста, посмотрел в GuiRepair (Наковальни), но возникла проблема, не появляется поле ввода. Вот код. Спасибо за помощь!
GuiContainer:
public class GUIArtillery extends GuiContainer
{
private GuiButton button;
private GuiTextField X;
private static TileEntityArtillery tile;
private static final ResourceLocation textures = new ResourceLocation(
Reference.modid, "textures/gui/container/artillery.png");
public GUIArtillery(InventoryPlayer player, TileEntityArtillery tile_) {
super(new ArtilleryContainer(player, tile));
tile = tile_;
}
@Override
public void initGui() {
super.initGui();
Keyboard.enableRepeatEvents(true);
X = new GuiTextField(2, fontRenderer, width / 2 - 75, height / 2 - 10, 150, 20);
this.buttonList.add(button = new GuiButton(1, width / 2 - 45, height / 2 - 15 , 95, 19, "Fire"));
}
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
X.textboxKeyTyped(typedChar, keyCode);
super.keyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
X.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public void updateScreen() {
X.updateCursorCounter();
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
X.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
}