gpt4 book ai didi

java - 错误 : no suitable constructor found for

转载 作者:行者123 更新时间:2023-11-30 09:27:52 29 4
gpt4 key购买 nike

我是 java 新手,正在尝试为 Minecraft 制作模组,但我不知道如何修复此错误:

src\minecraft\net\minecraft\src\ThreadConnectToServer.java:39: error: no suitabl
e constructor found for Packet2ClientProtocol(int,Minecraft,String,String,int)
GuiConnecting.getNetClientHandler(this.connectingGui).addToSendQueue
(new Packet2ClientProtocol(51, GuiConnecting.func_74254_c(this.connectingGui), t
his.Username, this.ip, this.port));

^

constructor Packet2ClientProtocol.Packet2ClientProtocol(int,String,int) is n
ot applicable
(actual and formal argument lists differ in length)
constructor Packet2ClientProtocol.Packet2ClientProtocol() is not applicable
(actual and formal argument lists differ in length)
1 error

这是我的代码:

package net.minecraft.src;

import java.net.ConnectException;
import java.net.UnknownHostException;

public class ThreadConnectToServer extends Thread
{

/** The IP address or domain used to connect. */
final String ip;

/** The port used to connect. */
final int port;

/** A reference to the GuiConnecting object. */
final GuiConnecting connectingGui;

final String Username;

ThreadConnectToServer(GuiConnecting par1GuiConnecting, String par2Str, int par3)
{
this.connectingGui = par1GuiConnecting;
this.ip = par2Str;
this.port = par3;
String Username = Info.Username;
}

public void run()
{
try
{
GuiConnecting.setNetClientHandler(this.connectingGui, new NetClientHandler(GuiConnecting.func_74256_a(this.connectingGui), this.ip, this.port));

if (GuiConnecting.isCancelled(this.connectingGui))
{
return;
}

GuiConnecting.getNetClientHandler(this.connectingGui).addToSendQueu(new Packet2ClientProtocol(51, GuiConnecting.func_74254_c(this.connectingGui), this.Username, this.ip, this.port));
}
catch (UnknownHostException var2)
{
if (GuiConnecting.isCancelled(this.connectingGui))
{
return;
}

GuiConnecting.func_74249_e(this.connectingGui).displayGuiScreen(new GuiDisconnected("connect.failed", "disconnect.genericReason", new Object[] {"Unknown host \'" + this.ip + "\'"}));
}
catch (ConnectException var3)
{
if (GuiConnecting.isCancelled(this.connectingGui))
{
return;
}

GuiConnecting.func_74250_f(this.connectingGui).displayGuiScreen(new GuiDisconnected("connect.failed", "disconnect.genericReason", new Object[] {var3.getMessage()}));
}
catch (Exception var4)
{
if (GuiConnecting.isCancelled(this.connectingGui))
{
return;
}

var4.printStackTrace();
GuiConnecting.func_74251_g(this.connectingGui).displayGuiScreen(new GuiDisconnected("connect.failed", "disconnect.genericReason", new Object[] {var4.toString()}));
}
}
}

这有什么问题我正在尝试使字符串“用户名”重定向到另一个类。

最佳答案

Java 编译器告诉您不能构造 Packet2ClientProtocol 对象,因为您对构造函数的调用不匹配任何已知的构造函数。

具体来说,编译器找到了两个构造函数:

Packet2ClientProtocol.Packet2ClientProtocol(int,String,int)
Packet2ClientProtocol.Packet2ClientProtocol()

但是您的电话:

new Packet2ClientProtocol(51, GuiConnecting.func_74254_c(this.connectingGui), this.Username, this.ip, this.port)

与它们都不匹配。

关于java - 错误 : no suitable constructor found for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14300449/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com