所以我正在遵循教程,但它有错误
教程:https://www.youtube.com/watch?v=clonDGFq49Y\
错误:
错误是当我想在黑客中有长名字时它就会消失
请帮忙
我将拍摄代码:\
package sonikhack.render;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import sonikhack.Client;
import sonikhack.module.Module;
import sonikhack.module.Category;
public class ClickGui extends GuiScreen{
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
drawRect(150, 2, 220, 14, 0xffff6052);
mc.fontRendererObj.drawString("Combat", 152, 4, 0xffffffff);
drawRect(250, 2, 322, 14, 0xffff6052);
mc.fontRendererObj.drawString("Movement", 252, 4, 0xffffffff);
drawRect(350, 2, 432, 14, 0xffff6052);
mc.fontRendererObj.drawString("Render", 352, 4, 0xffffffff);
drawRect(450, 2, 506, 14, 0xffff6052);
mc.fontRendererObj.drawString("Misc", 452, 4, 0xffffffff);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
public int placeForHackY(Module m) {
if(m.getCategory().equals(Category.COMBAT)) return Category.placeInListCombat(m) * 14;
if(m.getCategory().equals(Category.MOVEMENT)) return Category.placeInListMovement(m) * 14;
if(m.getCategory().equals(Category.RENDER)) return Category.placeInListRender(m) * 14;
if(m.getCategory().equals(Category.MISC)) return Category.placeInListMisc(m) * 14;
return 0;
}
public int placeForHackX(Module m) {
if(m.getCategory().equals(Category.COMBAT)) return 150;
if(m.getCategory().equals(Category.MOVEMENT)) return 250;
if(m.getCategory().equals(Category.RENDER)) return 350;
if(m.getCategory().equals(Category.MISC)) return 450;
return 0;
}
public void initGui() {
for(int i = 1; i < Client.modules.size(); i++) {
Module m = Client.modules.get(i);
buttonList.add(new GuiButton(i, placeForHackX(m), placeForHackY(m), 25 + (m.getName().length() * 3) + m.getName().length(), 14, m.getName()));
}
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
for(int i= 1; i < Client.modules.size(); i++) {
if(button.id == i) {
Client.getModules().get(i).toggle();
}
}
}
}
这是clickgui
现在类别:
package sonikhack.module;
import sonikhack.Client;
public enum Category {
COMBAT("Combat"),
MOVEMENT("Movement"),
RENDER("Render"),
MISC("Misc");
public String name;
public int moduleIndex;
Category(String name) {
this.name = name;
}
public static int size(Category cat) {
int i = 0;
for(Module m : Client.getModules()) {
if(m.getCategory().equals(cat)) {
i++;
}
}
return 0;
}
public static int placeInListRender(Module m) {
int i = 0;
for(Module mod : Client.getModules()) {
if(mod.getCategory().equals(RENDER) && !mod.equals(m)) {
i++;
continue;
}
if(mod.getCategory().equals(RENDER) && mod.equals(m)) {
return i;
}
}
return 0;
}
public static int placeInListMovement(Module m) {
int i = 1;
for(Module mod : Client.getModules()) {
if(mod.getCategory().equals(MOVEMENT) && !mod.equals(m)) {
i++;
continue;
}
if(mod.getCategory().equals(MOVEMENT) && mod.equals(m)) {
return i;
}
}
return 0;
}
public static int placeInListCombat(Module m) {
int i = 1;
for(Module mod : Client.getModules()) {
if(mod.getCategory().equals(COMBAT) && !mod.equals(m)) {
i++;
continue;
}
if(mod.getCategory().equals(COMBAT) && mod.equals(m)) {
return i;
}
}
return 0;
}
public static int placeInListMisc(Module m) {
int i = 1;
for(Module mod : Client.getModules()) {
if(mod.getCategory().equals(MISC) && !mod.equals(m)) {
i++;
continue;
}
if(mod.getCategory().equals(MISC) && mod.equals(m)) {
return i;
}
}
return 0;
}
}
还有图形用户界面:
package sonikhack.render;
import org.lwjgl.input.Keyboard;
import sonikhack.module.Category;
import sonikhack.module.Module;
public class Gui extends Module{
public Gui() {
super("ClickGui", Keyboard.KEY_RSHIFT, Category.RENDER);
}
public void onEnable() {
mc.displayGuiScreen(new ClickGui());
toggle();
}
}
唯一建议的解决方案是缩短文本或尝试自己修复。这不是一个您可以发布代码并期望有人解决问题的地方。也许你应该在编写客户端代码之前尝试学习java。 (也许不是黑客客户端)
这可能有点晚了,但我刚刚遇到这个问题,并且有一个非常简单的解决方案。将您的 CLickGUI 分成 3 个不同的类,一个用于类别,一个用于模块,一个用于设置,然后相应地渲染它们,因为您定位元素的方式没有任何意义。