Files
BetterP2P/src/main/java/com/projecturanus/betterp2p/network/ClientOpenGuiHandler.kt
T
Firenoo 72a58213c2 Rework the Advanced Memory Card's internal mechanisms.
Changes how the advanced memory card internally stores P2P Tunnel information:

- Now uses its own custom class. No more sortedInfos/infos discrepency; you
  can now access the sorted and filtered fields only. The master map cannot
  be accessed directly.

- P2PInfo now uses a hash, which removes AE2 P2P tunnel dupes. It depends
  on the coordinates, facing, and dimension information.

- Corresponding equals() function implemented for P2PInfo.

- Send the entire P2P list when binding. A new packet type is likely in order, though.

- The rest of the changes is to fit this new data structure into the existing
  infrastructure.

Hopefully this makes the mod more resilient to crashes.
2023-02-25 09:54:23 -08:00

23 lines
867 B
Kotlin

package com.projecturanus.betterp2p.network
import com.projecturanus.betterp2p.client.gui.GuiAdvancedMemoryCard
import cpw.mods.fml.common.network.simpleimpl.IMessage
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler
import cpw.mods.fml.common.network.simpleimpl.MessageContext
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import net.minecraft.client.Minecraft
class ClientOpenGuiHandler : IMessageHandler<S2CListP2P, IMessage?> {
@SideOnly(Side.CLIENT)
override fun onMessage(message: S2CListP2P, ctx: MessageContext): IMessage? {
val gui = Minecraft.getMinecraft().currentScreen
if(gui is GuiAdvancedMemoryCard){
gui.refreshInfo(message.infos)
}else {
Minecraft.getMinecraft().displayGuiScreen(GuiAdvancedMemoryCard(message))
}
return null
}
}