-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7e43c6
commit 46fcbff
Showing
5 changed files
with
28 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
.../main/java/dev/the_fireplace/playtest/network/serverbound/reciever/ThirdPingReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
package dev.the_fireplace.playtest.network.serverbound.reciever; | ||
|
||
import dev.the_fireplace.lib.api.network.interfaces.ServerboundPacketReceiver; | ||
import dev.the_fireplace.lib.api.uuid.injectables.EmptyUUID; | ||
import dev.the_fireplace.playtest.network.serverbound.ThirdPing; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.TextComponent; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.server.network.ServerGamePacketListenerImpl; | ||
|
||
@Singleton | ||
public final class ThirdPingReceiver implements ServerboundPacketReceiver | ||
{ | ||
private final EmptyUUID emptyUUID; | ||
|
||
@Inject | ||
public ThirdPingReceiver(EmptyUUID emptyUUID) { | ||
this.emptyUUID = emptyUUID; | ||
} | ||
|
||
@Override | ||
public void receive(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl handler, FriendlyByteBuf buf) { | ||
if (!buf.readUtf().equals(ThirdPing.PAYLOAD)) { | ||
throw new Error("Received unexpected payload from third ping!"); | ||
} | ||
server.execute(() -> { | ||
player.sendSystemMessage(Component.literal("Third ping received. Networking is fully functional.")); | ||
player.sendMessage(new TextComponent("Third ping received. Networking is fully functional."), emptyUUID.get()); | ||
}); | ||
} | ||
} |