Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jun 3, 2022
1 parent b43c6bc commit 66d4686
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'

group = 'io.izzel.lightfall'
version = '1.0.1'
version = '1.0.2'
archivesBaseName = 'lightfallclient'

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
Expand Down
61 changes: 32 additions & 29 deletions src/main/java/io/izzel/lightfall/client/LightfallClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,43 @@ public class LightfallClient {
private static final byte[] RESET_ACK = "lightfall:ack".getBytes(StandardCharsets.UTF_8);

public LightfallClient() {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerChannel);
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClientSetup::registerChannel);
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(() -> "", (a, b) -> b));
() -> new IExtensionPoint.DisplayTest(() -> "", (a, b) -> true));
}

private void registerChannel() {
var channel = NetworkRegistry.newEventChannel(
new ResourceLocation("lightfall", "reset"),
() -> "1", s -> true, s -> true
);
channel.addListener(this::handleReset);
}
public static class ClientSetup {

private void handleReset(NetworkEvent.ServerCustomPayloadEvent event) {
var context = event.getSource().get();
var netManager = context.getNetworkManager();
if (netManager == null || !(netManager.getPacketListener() instanceof ClientGamePacketListener)) {
return;
private static void registerChannel() {
var channel = NetworkRegistry.newEventChannel(
new ResourceLocation("lightfall", "reset"),
() -> "1", s -> true, s -> true
);
channel.addListener(ClientSetup::handleReset);
}
context.enqueueWork(() -> {
var client = Minecraft.getInstance();
var screen = new LightfallHandshakeScreen(netManager);
client.setScreen(screen);
if (client.level != null) {
GameData.revertToFrozen();
client.level = null;

private static void handleReset(NetworkEvent.ServerCustomPayloadEvent event) {
var context = event.getSource().get();
var netManager = context.getNetworkManager();
if (netManager == null || !(netManager.getPacketListener() instanceof ClientGamePacketListener)) {
return;
}
netManager.setProtocol(ConnectionProtocol.LOGIN);
var buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(RESET_ACK));
netManager.send(new ServerboundCustomQueryPacket(0x11FFA1, buffer));
var netHandler = new ClientHandshakePacketListenerImpl(netManager, client, new JoinMultiplayerScreen(new TitleScreen()), screen::setComponent);
((ClientLoginNetHandlerBridge) netHandler).bridge$reusePlayHandler((ClientPacketListener) netManager.getPacketListener());
netManager.setListener(netHandler);
});
context.setPacketHandled(true);
context.enqueueWork(() -> {
var client = Minecraft.getInstance();
var screen = new LightfallHandshakeScreen(netManager);
client.setScreen(screen);
if (client.level != null) {
GameData.revertToFrozen();
client.level = null;
}
netManager.setProtocol(ConnectionProtocol.LOGIN);
var buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(RESET_ACK));
netManager.send(new ServerboundCustomQueryPacket(0x11FFA1, buffer));
var netHandler = new ClientHandshakePacketListenerImpl(netManager, client, new JoinMultiplayerScreen(new TitleScreen()), screen::setComponent);
((ClientLoginNetHandlerBridge) netHandler).bridge$reusePlayHandler((ClientPacketListener) netManager.getPacketListener());
netManager.setListener(netHandler);
});
context.setPacketHandled(true);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.lightfall.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"injectors": {
"defaultRequire": 1
},
"mixins": [
"client": [
"ClientLoginNetHandlerMixin"
]
}

0 comments on commit 66d4686

Please sign in to comment.