Advertisement
Guest User

Untitled

a guest
May 26th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 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. private static ResourceLocation SIREN_SOUND;
  27.  
  28. public static void sendCurrentMoneyRq() {
  29. ByteArrayDataOutput out = ByteStreams.newDataOutput();
  30. out.writeUTF("rq");
  31. lastMoneyRqId += 1;
  32. out.writeInt(lastMoneyRqId);
  33. out.writeDouble(0);
  34. PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(out.toByteArray()));
  35. VaultIconomySupportChannel.ICONOMY_ATM_CH.sendToServer(new FMLProxyPacket(new CPacketCustomPayload("IconomyATM", buffer)));
  36. }
  37.  
  38.  
  39. public VaultIconomySupportChannel(FMLEventChannel ch)
  40. {
  41. ICONOMY_ATM_CH = ch;
  42. ch.register(this);
  43. }
  44.  
  45. @SubscribeEvent
  46. public void receivePacket(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException {
  47. ByteBufInputStream in = new ByteBufInputStream(event.getPacket().payload());
  48. String type = in.readUTF();
  49. if(type.contains("twitter")) {
  50. String[] parts = type.split(":");
  51. ClientRenderHooks.tweetUser = parts[2]; // 004
  52. ClientRenderHooks.tweetContent = parts[1]; // 034556
  53. ClientRenderHooks.tweetSecond = LocalDateTime.now().getSecond();
  54. } else {
  55. int taskID = in.readInt();
  56. Double content = in.readDouble();
  57. if (type.equals("money") && (VaultIconomySupportChannel.lastMoneyRqId == taskID || taskID == -10)) {
  58. VaultIconomySupportChannel.currentPlayerMoney = content;
  59. if (Minecraft.getMinecraft().currentScreen instanceof GuiConcessionnaire) {
  60. ((GuiConcessionnaire) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
  61. } else if (Minecraft.getMinecraft().currentScreen instanceof GuiRadarAmende) {
  62. ((GuiRadarAmende) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
  63. }
  64. }
  65. }
  66. }
  67.  
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement