Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. package fr.kerlann.gui;
  2.  
  3. import com.flansmod.client.ClientRenderHooks;
  4. import com.google.common.io.ByteArrayDataOutput;
  5. import com.google.common.io.ByteStreams;
  6. import fr.kerlann.main.DrawLife;
  7. import io.netty.buffer.ByteBufInputStream;
  8. import io.netty.buffer.Unpooled;
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.network.PacketBuffer;
  11. import net.minecraft.network.play.client.CPacketCustomPayload;
  12. import net.minecraft.util.ResourceLocation;
  13. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  14. import net.minecraftforge.fml.common.network.FMLEventChannel;
  15. import net.minecraftforge.fml.common.network.FMLNetworkEvent;
  16. import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
  17.  
  18. import java.io.IOException;
  19. import java.time.LocalDateTime;
  20.  
  21. public class VaultIconomySupportChannel
  22. {
  23. public static FMLEventChannel ICONOMY_ATM_CH;
  24. public static double currentPlayerMoney;
  25. private static int lastMoneyRqId;
  26.  
  27. public static void sendCurrentMoneyRq() {
  28. ByteArrayDataOutput out = ByteStreams.newDataOutput();
  29. out.writeUTF("rq");
  30. lastMoneyRqId += 1;
  31. out.writeInt(lastMoneyRqId);
  32. out.writeDouble(0);
  33. PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(out.toByteArray()));
  34. VaultIconomySupportChannel.ICONOMY_ATM_CH.sendToServer(new FMLProxyPacket(new CPacketCustomPayload("IconomyATM", buffer)));
  35. }
  36.  
  37.  
  38. public VaultIconomySupportChannel(FMLEventChannel ch)
  39. {
  40. ICONOMY_ATM_CH = ch;
  41. ch.register(this);
  42. }
  43.  
  44. @SubscribeEvent
  45. public void receivePacket(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException {
  46. ByteBufInputStream in = new ByteBufInputStream(event.getPacket().payload());
  47. String type = in.readUTF();
  48. if(type.contains("twitter")) {
  49. String[] parts = type.split(":");
  50. ClientRenderHooks.tweetUser = parts[2]; // 004
  51. ClientRenderHooks.tweetContent = parts[1]; // 034556
  52. ClientRenderHooks.tweetSecond = LocalDateTime.now().getSecond();
  53. } else {
  54. int taskID = in.readInt();
  55. Double content = in.readDouble();
  56. if (type.equals("money") && (VaultIconomySupportChannel.lastMoneyRqId == taskID || taskID == -10)) {
  57. VaultIconomySupportChannel.currentPlayerMoney = content;
  58. if (Minecraft.getMinecraft().currentScreen instanceof GuiConcessionnaire) {
  59. ((GuiConcessionnaire) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
  60. } else if (Minecraft.getMinecraft().currentScreen instanceof GuiRadarAmende) {
  61. ((GuiRadarAmende) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
  62. } else if (Minecraft.getMinecraft().currentScreen instanceof GuiVente) {
  63. ((GuiVente) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
  64. }
  65. }
  66. }
  67. }
  68.  
  69.  
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement