버전 1.20.1, 포지 47.2.20
- 버튼을 누를 시 서버로 바로 접속이 됩니다
- 접속 후 취소 버튼을 누르면 메인 화면으로 돌아가야 합니다.
접속 시도 시 연결하는 동안은 서버 접속하는 중 메시지가 총 2번 뜨게 됩니다
첫번째 뜰 때는 취소 시 메인으로 바로 돌아가지만
두번째 뜰 때 취소 시 멀티플레이어 화면으로 가지네요
JoinMultiplayerScreen이 사용되는 곳을 전부 살펴본거 같은데 해결이 안되고 있습니다
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
@Inject(method = "createNormalMenuOptions", at = @At("HEAD"), cancellable = true)
public void createNormalMenuOptions(int p_96764_, int p_96765_, CallbackInfo callbackInfo) {
Component component = getMultiplayerDisabledReason();
boolean flag = component == null;
Tooltip tooltip = component != null ? Tooltip.create(component) : null;
addRenderableWidget(Button.builder(Component.literal("전장으로..."), (p_210872_) -> {
var serverData = new ServerData("", "서버주소", false);
ConnectScreen.startConnecting(this, minecraft, ServerAddress.parseString(serverData.ip), serverData, false);
}).bounds(this.width / 2 - 100, p_96764_, 200, 20).tooltip(tooltip).build()).active = flag;
this.addRenderableWidget(Button.builder(Component.literal("연습하기"), (p_280833_) -> {
this.minecraft.setScreen(new SelectWorldScreen(this));
}).bounds(this.width / 2 - 100, p_96764_ + p_96765_, 200, 20).build());
callbackInfo.cancel();
}
}
영상에 나온 접속 시도 화면이 ConnectScreen 클래스입니다
위에서 접속 시도 시 연결하는 동안은 서버 접속하는 중 메시지가 총 2번 뜬다고 말씀드렸습니다
첫번째 메시지 때 취소 버튼을 누를 시 캔슬!! 메시지가 정상적으로 출력되지만
두번째 메시지 때 취소 버튼을 누르면 메시지가 출력되지 않습니다
protected void init() {
this.addRenderableWidget(Button.builder(CommonComponents.GUI_CANCEL, (p_289624_) -> {
synchronized(this) {
this.aborted = true;
if (this.channelFuture != null) {
this.channelFuture.cancel(true);
this.channelFuture = null;
}
if (this.connection != null) {
this.connection.disconnect(ABORT_CONNECTION);
}
}
this.minecraft.setScreen(this.parent);
System.out.println("캔슬!!")
}).bounds(this.width / 2 - 100, this.height / 4 + 120 + 12, 200, 20).build());
}
