mirror of
https://github.com/FabricMC/fabric.git
synced 2025-09-06 19:36:26 +00:00
23w03a (#2854)
* First look at 223w03a * Fix login * Support onboarding screen in client tests * Fix AFTER_ENTITY_CHANGE_WORLD event * Bump version
This commit is contained in:
@@ -38,6 +38,7 @@ import net.fabricmc.fabric.api.networking.v1.FutureListeners;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.impl.networking.AbstractNetworkAddon;
|
||||
import net.fabricmc.fabric.impl.networking.GenericFutureListenerHolder;
|
||||
import net.fabricmc.fabric.mixin.networking.client.accessor.ClientLoginNetworkHandlerAccessor;
|
||||
|
||||
public final class ClientLoginNetworkAddon extends AbstractNetworkAddon<ClientLoginNetworking.LoginQueryRequestHandler> {
|
||||
private final ClientLoginNetworkHandler handler;
|
||||
@@ -89,7 +90,7 @@ public final class ClientLoginNetworkAddon extends AbstractNetworkAddon<ClientLo
|
||||
listener = FutureListeners.union(listener, each);
|
||||
}
|
||||
|
||||
this.handler.getConnection().send(packet, GenericFutureListenerHolder.create(listener));
|
||||
((ClientLoginNetworkHandlerAccessor) this.handler).getConnection().send(packet, GenericFutureListenerHolder.create(listener));
|
||||
});
|
||||
} catch (Throwable ex) {
|
||||
this.logger.error("Encountered exception while handling in channel with name \"{}\"", channelName, ex);
|
||||
|
@@ -42,6 +42,7 @@ import net.fabricmc.fabric.impl.networking.ChannelInfoHolder;
|
||||
import net.fabricmc.fabric.impl.networking.GlobalReceiverRegistry;
|
||||
import net.fabricmc.fabric.impl.networking.NetworkHandlerExtensions;
|
||||
import net.fabricmc.fabric.impl.networking.NetworkingImpl;
|
||||
import net.fabricmc.fabric.mixin.networking.client.accessor.ClientLoginNetworkHandlerAccessor;
|
||||
import net.fabricmc.fabric.mixin.networking.client.accessor.ConnectScreenAccessor;
|
||||
import net.fabricmc.fabric.mixin.networking.client.accessor.MinecraftClientAccessor;
|
||||
|
||||
@@ -121,7 +122,8 @@ public final class ClientNetworkingImpl {
|
||||
ids.add(buf.readIdentifier());
|
||||
}
|
||||
|
||||
((ChannelInfoHolder) handler.getConnection()).getPendingChannelsNames().addAll(ids);
|
||||
ClientConnection connection = ((ClientLoginNetworkHandlerAccessor) handler).getConnection();
|
||||
((ChannelInfoHolder) connection).getPendingChannelsNames().addAll(ids);
|
||||
NetworkingImpl.LOGGER.debug("Received accepted channels from the server");
|
||||
|
||||
PacketByteBuf response = PacketByteBufs.create();
|
||||
|
@@ -45,7 +45,7 @@ public final class ClientPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public ClientPlayNetworkAddon(ClientPlayNetworkHandler handler, MinecraftClient client) {
|
||||
super(ClientNetworkingImpl.PLAY, handler.getConnection(), "ClientPlayNetworkAddon for " + handler.getProfile().getName());
|
||||
super(ClientNetworkingImpl.PLAY, handler.method_48296(), "ClientPlayNetworkAddon for " + handler.getProfile().getName());
|
||||
this.handler = handler;
|
||||
this.client = client;
|
||||
|
||||
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.networking.client.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
|
||||
@Mixin(ClientLoginNetworkHandler.class)
|
||||
public interface ClientLoginNetworkHandlerAccessor {
|
||||
@Accessor
|
||||
ClientConnection getConnection();
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
"package": "net.fabricmc.fabric.mixin.networking.client",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"client": [
|
||||
"accessor.ClientLoginNetworkHandlerAccessor",
|
||||
"accessor.ConnectScreenAccessor",
|
||||
"accessor.MinecraftClientAccessor",
|
||||
"ClientLoginNetworkHandlerMixin",
|
||||
|
@@ -20,9 +20,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -30,6 +31,7 @@ import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerLoginConnectionEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.mixin.networking.accessor.ServerLoginNetworkHandlerAccessor;
|
||||
|
||||
public final class NetworkingImpl {
|
||||
public static final String MOD_ID = "fabric-networking-api-v1";
|
||||
@@ -77,7 +79,8 @@ public final class NetworkingImpl {
|
||||
ids.add(buf.readIdentifier());
|
||||
}
|
||||
|
||||
((ChannelInfoHolder) handler.getConnection()).getPendingChannelsNames().addAll(ids);
|
||||
ClientConnection connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();
|
||||
((ChannelInfoHolder) connection).getPendingChannelsNames().addAll(ids);
|
||||
NetworkingImpl.LOGGER.debug("Received accepted channels from the client for \"{}\"", handler.getConnectionInfo());
|
||||
});
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ public final class ServerLoginNetworkAddon extends AbstractNetworkAddon<ServerLo
|
||||
|
||||
public ServerLoginNetworkAddon(ServerLoginNetworkHandler handler) {
|
||||
super(ServerNetworkingImpl.LOGIN, "ServerLoginNetworkAddon for " + handler.getConnectionInfo());
|
||||
this.connection = handler.connection;
|
||||
this.connection = ((ServerLoginNetworkHandlerAccessor) handler).getConnection();
|
||||
this.handler = handler;
|
||||
this.server = ((ServerLoginNetworkHandlerAccessor) handler).getServer();
|
||||
this.queryIdFactory = QueryIdFactory.create();
|
||||
|
@@ -34,6 +34,7 @@ import net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon;
|
||||
import net.fabricmc.fabric.impl.networking.ChannelInfoHolder;
|
||||
import net.fabricmc.fabric.impl.networking.NetworkingImpl;
|
||||
import net.fabricmc.fabric.mixin.networking.accessor.CustomPayloadC2SPacketAccessor;
|
||||
import net.fabricmc.fabric.mixin.networking.accessor.ServerPlayNetworkHandlerAccessor;
|
||||
|
||||
public final class ServerPlayNetworkAddon extends AbstractChanneledNetworkAddon<ServerPlayNetworking.PlayChannelHandler> {
|
||||
private final ServerPlayNetworkHandler handler;
|
||||
@@ -41,7 +42,7 @@ public final class ServerPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
||||
private boolean sentInitialRegisterPacket;
|
||||
|
||||
public ServerPlayNetworkAddon(ServerPlayNetworkHandler handler, MinecraftServer server) {
|
||||
super(ServerNetworkingImpl.PLAY, handler.getConnection(), "ServerPlayNetworkAddon for " + handler.player.getEntityName());
|
||||
super(ServerNetworkingImpl.PLAY, ((ServerPlayNetworkHandlerAccessor) handler).getConnection(), "ServerPlayNetworkAddon for " + handler.player.getEntityName());
|
||||
this.handler = handler;
|
||||
this.server = server;
|
||||
|
||||
|
@@ -19,6 +19,7 @@ package net.fabricmc.fabric.mixin.networking.accessor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerLoginNetworkHandler;
|
||||
|
||||
@@ -26,4 +27,7 @@ import net.minecraft.server.network.ServerLoginNetworkHandler;
|
||||
public interface ServerLoginNetworkHandlerAccessor {
|
||||
@Accessor
|
||||
MinecraftServer getServer();
|
||||
|
||||
@Accessor
|
||||
ClientConnection getConnection();
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.networking.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public interface ServerPlayNetworkHandlerAccessor {
|
||||
@Accessor
|
||||
ClientConnection getConnection();
|
||||
}
|
@@ -11,6 +11,7 @@
|
||||
"accessor.CustomPayloadC2SPacketAccessor",
|
||||
"accessor.EntityTrackerAccessor",
|
||||
"accessor.LoginQueryResponseC2SPacketAccessor",
|
||||
"accessor.ServerPlayNetworkHandlerAccessor",
|
||||
"accessor.ServerLoginNetworkHandlerAccessor",
|
||||
"accessor.ThreadedAnvilChunkStorageAccessor"
|
||||
],
|
||||
|
@@ -59,7 +59,7 @@ final class ChannelScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackgroundTexture(0);
|
||||
this.renderBackgroundTexture(matrices);
|
||||
this.channelList.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
||||
|
@@ -33,7 +33,7 @@ public class DisconnectScreenTest implements ClientModInitializer {
|
||||
builder.append("\nLine ").append(i + 1);
|
||||
}
|
||||
|
||||
context.getSource().getPlayer().networkHandler.getConnection().disconnect(Text.of(builder.toString()));
|
||||
context.getSource().getPlayer().networkHandler.method_48296().disconnect(Text.of(builder.toString()));
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
Reference in New Issue
Block a user