我目前正在开发Minecraft骇客客户端,我想输入一个密钥,该密钥将删除文本并显示新的文本,反之亦然。在游戏开始时,左上角显示一些文本:hack名称及其关键。我想这样做,以便在按下某个键时,方法showDesc()会初始化并删除文本,但会编写一个新文本,其中不仅包含hack名称及其密钥,还包含类别和描述。我找不到隐藏文本的方法。我的代码:
package me.hacked.client;
import net.minecraft.client.Minecraft;
public class UI {
public static Minecraft mc = Minecraft.getMinecraft(); //get minecraft
public static boolean descShown = false;
public static void init() { //called on game start
mc.fontRendererObj.drawStringWithShadow("Hacked Client", 0, 0, 0x00FFFF);
mc.fontRendererObj.drawStringWithShadow("Sprint - F", 0, 9, 0xFF0000);
}
public static void showDesc() { //called on key press
descShown = !descShown;
if (descShown == false){
//TODO: Hide old text
mc.fontRendererObj.drawStringWithShadow("Hacked Client", 0, 0, 0x00FFFF);
mc.fontRendererObj.drawStringWithShadow("Sprint - F - Belongs to movement group - Always sprint, if possible.", 0, 9, 0xFF0000);
}else{
//TODO: Hide old text
mc.fontRendererObj.drawStringWithShadow("Hacked Client", 0, 0, 0x00FFFF);
mc.fontRendererObj.drawStringWithShadow("Sprint - F", 0, 9, 0xFF0000);
}
}
顺便说一句,我绝对会一遍又一遍地重写所有文本。
答案 0 :(得分:0)
你为什么要这么做:
if (descShown == false){
//TODO: Hide old text
mc.fontRendererObj.drawStringWithShadow("Hacked Client", 0, 0, 0x00FFFF);
mc.fontRendererObj.drawStringWithShadow("Sprint - F - Belongs to movement group - Always sprint, if possible.", 0, 9, 0xFF0000);
}else{
//TODO: Hide old text
mc.fontRendererObj.drawStringWithShadow("Hacked Client", 0, 0, 0x00FFFF);
mc.fontRendererObj.drawStringWithShadow("Sprint - F", 0, 9, 0xFF0000);
}
为什么这是另外一条语句?没用的。如果您不想输入文字,请不要输入其他文字。如果您的条件未通过,Minecraft将不会渲染