Mod avec GuiTextField
-
Bonjour j’aimerais savoir si c’est possible de créer un mod avec GuiTextField dedans ???
-
Pourquoi ça ne serait pas possible ? Bien sûr que oui c’est possible …
-
Pouraije avoir avoir le code
-
Tiens, regarde ce sujet : http://www.minecraftforge.net/forum/index.php?topic=22378.0
-
Tu peux aller voir la classe GuiRepair (dans net.minecraft.client.gui) si tu veux un exemple d’utilisation.
-
Si je mes sa
package fr.theazkaze.client.custommenu; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ChatAllowedCharacters; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class Login extends Gui { private final FontRenderer field_146211_a; public int xPosition; public int yPosition; /** The width of this text field. */ public int width; public int height; /** Has the current text being edited on the textbox. */ private String text = ""; private int maxStringLength = 32; private int cursorCounter; private boolean enableBackgroundDrawing = true; /** if true the textbox can lose focus by clicking elsewhere on the screen */ private boolean canLoseFocus = true; /** If this value is true along with isEnabled, keyTyped will process the keys. */ private boolean isFocused; /** If this value is true along with isFocused, keyTyped will process the keys. */ private boolean isEnabled = true; /** The current character index that should be used as start of the rendered text. */ private int lineScrollOffset; private int cursorPosition; /** other selection position, maybe the same as the cursor */ private int selectionEnd; private int enabledColor = 14737632; private int disabledColor = 7368816; /** True if this textbox is visible */ private boolean visible = true; private static final String __OBFID = "CL_00000670"; public Login(FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_) { this.field_146211_a = p_i1032_1_; this.xPosition = p_i1032_2_; this.yPosition = p_i1032_3_; this.width = p_i1032_4_; this.height = p_i1032_5_; } /** * Increments the cursor counter */ public void updateCursorCounter() { ++this.cursorCounter; } /** * Sets the text of the textbox */ public void setText(String p_146180_1_) { if (p_146180_1_.length() > this.maxStringLength) { this.text = p_146180_1_.substring(0, this.maxStringLength); } else { this.text = p_146180_1_; } this.setCursorPositionEnd(); } /** * Returns the contents of the textbox */ public String getText() { return this.text; } /** * returns the text between the cursor and selectionEnd */ public String getSelectedText() { int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; return this.text.substring(i, j); } /** * replaces selected text, or inserts text at the position on the cursor */ public void writeText(String p_146191_1_) { String s1 = ""; String s2 = ChatAllowedCharacters.filerAllowedCharacters(p_146191_1_); int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; int k = this.maxStringLength - this.text.length() - (i - this.selectionEnd); boolean flag = false; if (this.text.length() > 0) { s1 = s1 + this.text.substring(0, i); } int l; if (k < s2.length()) { s1 = s1 + s2.substring(0, k); l = k; } else { s1 = s1 + s2; l = s2.length(); } if (this.text.length() > 0 && j < this.text.length()) { s1 = s1 + this.text.substring(j); } this.text = s1; this.moveCursorBy(i - this.selectionEnd + l); } /** * Deletes the specified number of words starting at the cursor position. Negative numbers will delete words left of * the cursor. */ public void deleteWords(int p_146177_1_) { if (this.text.length() != 0) { if (this.selectionEnd != this.cursorPosition) { this.writeText(""); } else { this.deleteFromCursor(this.getNthWordFromCursor(p_146177_1_) - this.cursorPosition); } } } /** * delete the selected text, otherwsie deletes characters from either side of the cursor. params: delete num */ public void deleteFromCursor(int p_146175_1_) { if (this.text.length() != 0) { if (this.selectionEnd != this.cursorPosition) { this.writeText(""); } else { boolean flag = p_146175_1_ < 0; int j = flag ? this.cursorPosition + p_146175_1_ : this.cursorPosition; int k = flag ? this.cursorPosition : this.cursorPosition + p_146175_1_; String s = ""; if (j >= 0) { s = this.text.substring(0, j); } if (k < this.text.length()) { s = s + this.text.substring(k); } this.text = s; if (flag) { this.moveCursorBy(p_146175_1_); } } } } /** * see @getNthNextWordFromPos() params: N, position */ public int getNthWordFromCursor(int p_146187_1_) { return this.getNthWordFromPos(p_146187_1_, this.getCursorPosition()); } /** * gets the position of the nth word. N may be negative, then it looks backwards. params: N, position */ public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) { return this.func_146197_a(p_146183_1_, this.getCursorPosition(), true); } public int func_146197_a(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) { int k = p_146197_2_; boolean flag1 = p_146197_1_ < 0; int l = Math.abs(p_146197_1_); for (int i1 = 0; i1 < l; ++i1) { if (flag1) { while (p_146197_3_ && k > 0 && this.text.charAt(k - 1) == 32) { –k; } while (k > 0 && this.text.charAt(k - 1) != 32) { --k; } } else { int j1 = this.text.length(); k = this.text.indexOf(32, k); if (k == -1) { k = j1; } else { while (p_146197_3_ && k < j1 && this.text.charAt(k) == 32) { ++k; } } } } return k; } /** * Moves the text cursor by a specified number of characters and clears the selection */ public void moveCursorBy(int p_146182_1_) { this.setCursorPosition(this.selectionEnd + p_146182_1_); } /** * sets the position of the cursor to the provided index */ public void setCursorPosition(int p_146190_1_) { this.cursorPosition = p_146190_1_; int j = this.text.length(); if (this.cursorPosition < 0) { this.cursorPosition = 0; } if (this.cursorPosition > j) { this.cursorPosition = j; } this.setSelectionPos(this.cursorPosition); } /** * sets the cursors position to the beginning */ public void setCursorPositionZero() { this.setCursorPosition(0); } /** * sets the cursors position to after the text */ public void setCursorPositionEnd() { this.setCursorPosition(this.text.length()); } /** * Call this method from your GuiScreen to process the keys into the textbox */ public boolean textboxKeyTyped(char p_146201_1_, int p_146201_2_) { if (!this.isFocused) { return false; } else { switch (p_146201_1_) { case 1: this.setCursorPositionEnd(); this.setSelectionPos(0); return true; case 3: GuiScreen.setClipboardString(this.getSelectedText()); return true; case 22: if (this.isEnabled) { this.writeText(GuiScreen.getClipboardString()); } return true; case 24: GuiScreen.setClipboardString(this.getSelectedText()); if (this.isEnabled) { this.writeText(""); } return true; default: switch (p_146201_2_) { case 14: if (GuiScreen.isCtrlKeyDown()) { if (this.isEnabled) { this.deleteWords(-1); } } else if (this.isEnabled) { this.deleteFromCursor(-1); } return true; case 199: if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(0); } else { this.setCursorPositionZero(); } return true; case 203: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() - 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(-1)); } else { this.moveCursorBy(-1); } return true; case 205: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() + 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(1)); } else { this.moveCursorBy(1); } return true; case 207: if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(this.text.length()); } else { this.setCursorPositionEnd(); } return true; case 211: if (GuiScreen.isCtrlKeyDown()) { if (this.isEnabled) { this.deleteWords(1); } } else if (this.isEnabled) { this.deleteFromCursor(1); } return true; default: if (ChatAllowedCharacters.isAllowedCharacter(p_146201_1_)) { if (this.isEnabled) { this.writeText(Character.toString(p_146201_1_)); } return true; } else { return false; } } } } } /** * Args: x, y, buttonClicked */ public void mouseClicked(int p_146192_1_, int p_146192_2_, int p_146192_3_) { boolean flag = p_146192_1_ >= this.xPosition && p_146192_1_ < this.xPosition + this.width && p_146192_2_ >= this.yPosition && p_146192_2_ < this.yPosition + this.height; if (this.canLoseFocus) { this.setFocused(flag); } if (this.isFocused && p_146192_3_ == 0) { int l = p_146192_1_ - this.xPosition; if (this.enableBackgroundDrawing) { l -= 4; } String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); this.setCursorPosition(this.field_146211_a.trimStringToWidth(s, l).length() + this.lineScrollOffset); } } /** * Draws the textbox */ public void drawTextBox() { if (this.getVisible()) { if (this.getEnableBackgroundDrawing()) { drawRect(this.xPosition - 1, this.yPosition - 1, this.xPosition + this.width + 1, this.yPosition + this.height + 1, -6250336); drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, -16777216); } int i = this.isEnabled ? this.enabledColor : this.disabledColor; int j = this.cursorPosition - this.lineScrollOffset; int k = this.selectionEnd - this.lineScrollOffset; String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); boolean flag = j >= 0 && j <= s.length(); boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag; int l = this.enableBackgroundDrawing ? this.xPosition + 4 : this.xPosition; int i1 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition; int j1 = l; if (k > s.length()) { k = s.length(); } if (s.length() > 0) { String s1 = flag ? s.substring(0, j) : s; j1 = this.field_146211_a.drawStringWithShadow(s1, l, i1, i); } boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength(); int k1 = j1; if (!flag) { k1 = j > 0 ? l + this.width : l; } else if (flag2) { k1 = j1 - 1; --j1; } if (s.length() > 0 && flag && j < s.length()) { this.field_146211_a.drawStringWithShadow(s.substring(j), j1, i1, i); } if (flag1) { if (flag2) { Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.field_146211_a.FONT_HEIGHT, -3092272); } else { this.field_146211_a.drawStringWithShadow("_", k1, i1, i); } } if (k != j) { int l1 = l + this.field_146211_a.getStringWidth(s.substring(0, k)); this.drawCursorVertical(k1, i1 - 1, l1 - 1, i1 + 1 + this.field_146211_a.FONT_HEIGHT); } } } /** * draws the vertical line cursor in the textbox */ private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) { int i1; if (p_146188_1_ < p_146188_3_) { i1 = p_146188_1_; p_146188_1_ = p_146188_3_; p_146188_3_ = i1; } if (p_146188_2_ < p_146188_4_) { i1 = p_146188_2_; p_146188_2_ = p_146188_4_; p_146188_4_ = i1; } if (p_146188_3_ > this.xPosition + this.width) { p_146188_3_ = this.xPosition + this.width; } if (p_146188_1_ > this.xPosition + this.width) { p_146188_1_ = this.xPosition + this.width; } Tessellator tessellator = Tessellator.instance; GL11.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); GL11.glLogicOp(GL11.GL_OR_REVERSE); tessellator.startDrawingQuads(); tessellator.addVertex((double)p_146188_1_, (double)p_146188_4_, 0.0D); tessellator.addVertex((double)p_146188_3_, (double)p_146188_4_, 0.0D); tessellator.addVertex((double)p_146188_3_, (double)p_146188_2_, 0.0D); tessellator.addVertex((double)p_146188_1_, (double)p_146188_2_, 0.0D); tessellator.draw(); GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); GL11.glEnable(GL11.GL_TEXTURE_2D); } public void setMaxStringLength(int p_146203_1_) { this.maxStringLength = p_146203_1_; if (this.text.length() > p_146203_1_) { this.text = this.text.substring(0, p_146203_1_); } } /** * returns the maximum number of character that can be contained in this textbox */ public int getMaxStringLength() { return this.maxStringLength; } /** * returns the current position of the cursor */ public int getCursorPosition() { return this.cursorPosition; } /** * get enable drawing background and outline */ public boolean getEnableBackgroundDrawing() { return this.enableBackgroundDrawing; } /** * enable drawing background and outline */ public void setEnableBackgroundDrawing(boolean p_146185_1_) { this.enableBackgroundDrawing = p_146185_1_; } /** * Sets the text colour for this textbox (disabled text will not use this colour) */ public void setTextColor(int p_146193_1_) { this.enabledColor = p_146193_1_; } public void setDisabledTextColour(int p_146204_1_) { this.disabledColor = p_146204_1_; } /** * Sets focus to this gui element */ public void setFocused(boolean p_146195_1_) { if (p_146195_1_ && !this.isFocused) { this.cursorCounter = 0; } this.isFocused = p_146195_1_; } /** * Getter for the focused field */ public boolean isFocused() { return this.isFocused; } public void setEnabled(boolean p_146184_1_) { this.isEnabled = p_146184_1_; } /** * the side of the selection that is not the cursor, may be the same as the cursor */ public int getSelectionEnd() { return this.selectionEnd; } /** * returns the width of the textbox depending on if background drawing is enabled */ public int getWidth() { return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width; } /** * Sets the position of the selection anchor (i.e. position the selection was started at) */ public void setSelectionPos(int p_146199_1_) { int j = this.text.length(); if (p_146199_1_ > j) { p_146199_1_ = j; } if (p_146199_1_ < 0) { p_146199_1_ = 0; } this.selectionEnd = p_146199_1_; if (this.field_146211_a != null) { if (this.lineScrollOffset > j) { this.lineScrollOffset = j; } int k = this.getWidth(); String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), k); int l = s.length() + this.lineScrollOffset; if (p_146199_1_ == this.lineScrollOffset) { this.lineScrollOffset -= this.field_146211_a.trimStringToWidth(this.text, k, true).length(); } if (p_146199_1_ > l) { this.lineScrollOffset += p_146199_1_ - l; } else if (p_146199_1_ <= this.lineScrollOffset) { this.lineScrollOffset -= this.lineScrollOffset - p_146199_1_; } if (this.lineScrollOffset < 0) { this.lineScrollOffset = 0; } if (this.lineScrollOffset > j) { this.lineScrollOffset = j; } } } /** * if true the textbox can lose focus by clicking elsewhere on the screen */ public void setCanLoseFocus(boolean p_146205_1_) { this.canLoseFocus = p_146205_1_; } /** * returns true if this textbox is visible */ public boolean getVisible() { return this.visible; } /** * Sets whether or not this textbox is visible */ public void setVisible(boolean p_146189_1_) { this.visible = p_146189_1_; } }
Je dois ajouter quelque chose dans ma class principale ???
-
Euh… Il me semble que tu as fais un peu compliqué pour un Gui Textfield, je ne crois pas que tu es quelque chose à rajouter dans ta classe principale. De toute manière teste, tu verras bien.
-
Il faut simplement ajouter une variable de type GuiTextField dans la classe de ton Gui, l’initaliser dans la fonction initGui en n’oubliant pas de lui donner un ID unique et rajouter dans la fonction drawScreen this.taVariable.drawTextBox().
PS : çà ne sert à rien de copier des classes entières si l’on ne comprend pas le code.
-
J’ai des erreur au niveaux de keyTyped/mouseClicked/drawDefaultBackground/drawScreen/updateScreen/
package fr.theazkaze.client.custommenu; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; public class Login { private static final int width = 0; private static final int height = 0; private FontRenderer fontRendererObj; public void initGui() { this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height/2-46, 137, 20); text.setMaxStringLength(23); text.setText("sample text"); this.text.setFocused(true); } protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); this.text.textboxKeyTyped(par1, par2); } protected void mouseClicked(int x, int y, int btn) { super.mouseClicked(x, y, btn); this.text.mouseClicked(x, y, btn); } public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); this.text.drawTextBox(); super.drawScreen(par1, par2, par3); } public void updateScreen() { super.updateScreen(); this.text.updateCursorCounter(); } private GuiTextField text; }
-
private GuiTextField text;
Rajoute cette variable dans ton constructeur. Ce qui donne:
public class Login { private GuiTextField text;
-
Tu cherches à faire quoi exactement ?
-
private GuiTextField text;
est tout en bas m’ai l’erreur s’etais
public class Login extends GuiScreen
Mais sa ne l’intègres pas au jeux
-
Recommence du début. Tu veux mettre un textfield dans un GUI ?
Commence par définir ton GUI.
public class GuiTest extends GuiScreen // Définit que nous avons un gui { }
Ensuite la variable qui définit ton textfield :
private GuiTextField textfield;
La taille de ton GUI :
int guiWidth= 250; // Taille du gui (largeur) int guiHeight= 250;// Taille du gui (hauteur)
Ta méthode drawScreen :
@Override public void drawScreen(int x, int y, float ticks ) { int guix =(width - guiWidth) /2 ; int guiy =(height - guiHeight) /2; GL11.glColor4f(1,1,1,1); drawDefaultBackground(); mc.renderEngine.bindTexture(new ResourceLocation(ClassePrincipale.MODID,"textures/gui/guiTest.png")); // Le chemin de ton GUI drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); this.drawDefaultBackground(); this.textfield.drawTextBox(); // On met ton textfield ici super.drawScreen(x, y, ticks); }
De base, je pense que ton GUI met le jeu en pause. Avec cette méthode, le jeu continuera à se dérouler même si le GUI est ouvert :
@Override public boolean doesGuiPauseGame() { return false; }
Vient ensuite le tour de la fonction initGui :
int posX = (this.width - guiWidth) / 2; int posY = (this.height - guiHeight) / 2; this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height / 2 -75, 100, 20); textfield.setMaxStringLength(10); textfield.setText(""); this.xTextField.setFocused(true);
La fonction keyTyped :
protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); this.textfield.textboxKeyTyped(par1, par2); }
La fonction updateScreen :
public void updateScreen() { super.updateScreen(); }
Et la fonction mouseClicked :
protected void mouseClicked(int x, int y, int btn) { super.mouseClicked(x, y, btn); this.textfield.mouseClicked(x, y, btn); }
Bien entendu n’oublie pas de faire tous les imports nécessaires.
-
Robin je cherche a quand tu fais /l test sa marque /l ****
Et Laserflip33 il y a des erreur a guiWidth,guiHeight,xTextField
package fr.theazkaze.client.custommenu; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class Login extends GuiScreen { private static final int width = 0; private static final int height = 0; private FontRenderer fontRendererObj; public void initGui() { int posX = (this.width - guiWidth) / 2; int posY = (this.height - guiHeight) / 2; this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height / 2 -75, 100, 20); textfield.setMaxStringLength(10); textfield.setText(""); this.xTextField.setFocused(true); int guiWidth= 250; // Taille du gui (largeur) int guiHeight= 250;// Taille du gui (hauteur) this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height/2-46, 137, 20); text.setMaxStringLength(23); text.setText("sample text"); this.text.setFocused(true); } protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); this.textfield.textboxKeyTyped(par1, par2); } protected void mouseClicked(int x, int y, int btn) { super.mouseClicked(x, y, btn); this.textfield.mouseClicked(x, y, btn); } @Override public void drawScreen(int x, int y, float ticks ) { int guix =(width - guiWidth) /2 ; int guiy =(height - guiHeight) /2; GL11.glColor4f(1,1,1,1); drawDefaultBackground(); mc.renderEngine.bindTexture(new ResourceLocation(MenuCrack.MODID,"textures/gui/guiTest.png")); // Le chemin de ton GUI drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); this.drawDefaultBackground(); this.textfield.drawTextBox(); // On met ton textfield ici super.drawScreen(x, y, ticks); } public void updateScreen() { super.updateScreen(); } @Override public boolean doesGuiPauseGame() { return false; } private GuiTextField textfield; private GuiTextField text; }
-
Tu veux faire en sorte que ça agit sur le chat alors non ? Ou tu veux créer une case spécial pour entrer le login ?
-
Qu’il agit sur le tchat
-
Quelles erreurs?
-
@‘TheAzkaze’:
Robin je cherche a quand tu fais /l test sa marque /l ****
Et Laserflip33 il y a des erreur a guiWidth,guiHeight,xTextField
package fr.theazkaze.client.custommenu; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class Login extends GuiScreen { private static final int width = 0; private static final int height = 0; private FontRenderer fontRendererObj; public void initGui() { int posX = (this.width - guiWidth) / 2; int posY = (this.height - guiHeight) / 2; this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height / 2 -75, 100, 20); textfield.setMaxStringLength(10); textfield.setText(""); this.xTextField.setFocused(true); int guiWidth= 250; // Taille du gui (largeur) int guiHeight= 250;// Taille du gui (hauteur) this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height/2-46, 137, 20); text.setMaxStringLength(23); text.setText("sample text"); this.text.setFocused(true); } protected void keyTyped(char par1, int par2) { super.keyTyped(par1, par2); this.textfield.textboxKeyTyped(par1, par2); } protected void mouseClicked(int x, int y, int btn) { super.mouseClicked(x, y, btn); this.textfield.mouseClicked(x, y, btn); } @Override public void drawScreen(int x, int y, float ticks ) { int guix =(width - guiWidth) /2 ; int guiy =(height - guiHeight) /2; GL11.glColor4f(1,1,1,1); drawDefaultBackground(); mc.renderEngine.bindTexture(new ResourceLocation(MenuCrack.MODID,"textures/gui/guiTest.png")); // Le chemin de ton GUI drawTexturedModalRect(guix, guiy, 0, 0, guiWidth, guiHeight); this.drawDefaultBackground(); this.textfield.drawTextBox(); // On met ton textfield ici super.drawScreen(x, y, ticks); } public void updateScreen() { super.updateScreen(); } @Override public boolean doesGuiPauseGame() { return false; } private GuiTextField textfield; private GuiTextField text; }
La il sont marquer en haut
-
Quelles sont leurs natures?
Déjà remplace xTextField par textfield et recopie dans l’ordre là où je t’ai donné le code.
int posX = (this.width - guiWidth) / 2; int posY = (this.height - guiHeight) / 2;
Ne doit pas être dans le initGui
Ensuite pourquoi tu fais ça?
private GuiTextField textfield; private GuiTextField text;
Vire tout simplement private GuiTextField text;
-
Si tu veux qu’il agit sur le tchat ce n’est pas du tout comme ça qu’il faut faire. C’est plus complexe.
Il faut soit remplacer le tchat de mc par son propre tchat lorsqu’il est ouvert, soit modifier directement le code de mc via la lib asm.