-
Notifications
You must be signed in to change notification settings - Fork 396
Fix prospection data task #5076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,5 +119,7 @@ public static void init() { | |
| register(SPacketSendWorldID.class, SPacketSendWorldID::new, NetworkDirection.PLAY_TO_CLIENT); | ||
| register(SPacketNotifyCapeChange.class, SPacketNotifyCapeChange::new, NetworkDirection.PLAY_TO_CLIENT); | ||
| register(SCPacketShareProspection.class, SCPacketShareProspection::new, null); | ||
| register(SPacketStartProspectionShare.class, SPacketStartProspectionShare::new, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :sadge: unlucky |
||
| NetworkDirection.PLAY_TO_CLIENT); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package com.gregtechceu.gtceu.common.network.packets; | ||
|
|
||
| import com.gregtechceu.gtceu.common.network.GTNetwork; | ||
| import com.gregtechceu.gtceu.integration.map.ClientCacheManager; | ||
|
|
||
| import net.minecraft.client.Minecraft; | ||
| import net.minecraft.network.FriendlyByteBuf; | ||
| import net.minecraftforge.network.NetworkEvent; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * Sent from the server to the sender's client to kick off sharing their local prospection cache. | ||
| * | ||
| * The {@code /gtceu share_prospection_data} command is a server command. The prospection cache | ||
| * only exists on the client, so the server delegates the actual read + send back to the sender's | ||
| * client via this packet. | ||
| */ | ||
| @AllArgsConstructor | ||
| public class SPacketStartProspectionShare implements GTNetwork.INetPacket { | ||
|
|
||
| private UUID receiver; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public SPacketStartProspectionShare() {} | ||
|
|
||
| public SPacketStartProspectionShare(FriendlyByteBuf buf) { | ||
| receiver = buf.readUUID(); | ||
| } | ||
|
|
||
| @Override | ||
| public void encode(FriendlyByteBuf buf) { | ||
| buf.writeUUID(receiver); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(NetworkEvent.Context context) { | ||
| UUID sender = Minecraft.getInstance().player.getUUID(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this fine to do on a dedicated server? I'm not sure.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it works on a dedi server, we tested before merging |
||
| Thread sendThread = new Thread(new ProspectingShareTask(sender, receiver)); | ||
| sendThread.start(); | ||
| } | ||
|
|
||
| private static class ProspectingShareTask implements Runnable { | ||
|
|
||
| private final List<ClientCacheManager.ProspectionInfo> prospectionData; | ||
| private final UUID sender; | ||
| private final UUID receiver; | ||
|
|
||
| public ProspectingShareTask(UUID sender, UUID receiver) { | ||
| prospectionData = ClientCacheManager.getProspectionShareData(); | ||
| this.sender = sender; | ||
| this.receiver = receiver; | ||
| } | ||
|
|
||
| @Override | ||
| public void run() { | ||
| boolean first = true; | ||
| for (ClientCacheManager.ProspectionInfo info : prospectionData) { | ||
| GTNetwork.sendToServer(new SCPacketShareProspection(sender, receiver, info.cacheName, info.key, | ||
| info.isDimCache, info.dim, info.data, first)); | ||
| first = false; | ||
|
|
||
| try { | ||
| Thread.sleep(1000); | ||
| } catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont remove this import, it's here for ease of use if/when client commands are added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they can add it back when they do imo, rather that than danglign imports