Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.kerlann.gui;
- import com.flansmod.client.ClientRenderHooks;
- import com.google.common.io.ByteArrayDataOutput;
- import com.google.common.io.ByteStreams;
- import fr.kerlann.main.DrawLife;
- import io.netty.buffer.ByteBufInputStream;
- import io.netty.buffer.Unpooled;
- import net.minecraft.client.Minecraft;
- import net.minecraft.network.PacketBuffer;
- import net.minecraft.network.play.client.CPacketCustomPayload;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.network.FMLEventChannel;
- import net.minecraftforge.fml.common.network.FMLNetworkEvent;
- import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
- import java.io.IOException;
- import java.time.LocalDateTime;
- public class VaultIconomySupportChannel
- {
- public static FMLEventChannel ICONOMY_ATM_CH;
- public static double currentPlayerMoney;
- private static int lastMoneyRqId;
- public static void sendCurrentMoneyRq() {
- ByteArrayDataOutput out = ByteStreams.newDataOutput();
- out.writeUTF("rq");
- lastMoneyRqId += 1;
- out.writeInt(lastMoneyRqId);
- out.writeDouble(0);
- PacketBuffer buffer = new PacketBuffer(Unpooled.wrappedBuffer(out.toByteArray()));
- VaultIconomySupportChannel.ICONOMY_ATM_CH.sendToServer(new FMLProxyPacket(new CPacketCustomPayload("IconomyATM", buffer)));
- }
- public VaultIconomySupportChannel(FMLEventChannel ch)
- {
- ICONOMY_ATM_CH = ch;
- ch.register(this);
- }
- @SubscribeEvent
- public void receivePacket(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException {
- ByteBufInputStream in = new ByteBufInputStream(event.getPacket().payload());
- String type = in.readUTF();
- if(type.contains("twitter")) {
- String[] parts = type.split(":");
- ClientRenderHooks.tweetUser = parts[2]; // 004
- ClientRenderHooks.tweetContent = parts[1]; // 034556
- ClientRenderHooks.tweetSecond = LocalDateTime.now().getSecond();
- } else {
- int taskID = in.readInt();
- Double content = in.readDouble();
- if (type.equals("money") && (VaultIconomySupportChannel.lastMoneyRqId == taskID || taskID == -10)) {
- VaultIconomySupportChannel.currentPlayerMoney = content;
- if (Minecraft.getMinecraft().currentScreen instanceof GuiConcessionnaire) {
- ((GuiConcessionnaire) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
- } else if (Minecraft.getMinecraft().currentScreen instanceof GuiRadarAmende) {
- ((GuiRadarAmende) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
- } else if (Minecraft.getMinecraft().currentScreen instanceof GuiVente) {
- ((GuiVente) Minecraft.getMinecraft().currentScreen).moneyCheckedCallback(VaultIconomySupportChannel.currentPlayerMoney);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement