package com.yolp900.itsjustacharm.common.network; import com.yolp900.itsjustacharm.api.IJCConstants; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; public class NetworkHandler { public static SimpleNetworkWrapper Instance = NetworkRegistry.INSTANCE.newSimpleChannel(IJCConstants.MOD_ID); private static int i; public static void init() { i = 0; registerMessage(MessageParticle.class, Side.CLIENT); registerMessage(MessageChatMessage.class, Side.CLIENT); registerMessage(MessageSound.class, Side.CLIENT); } @SuppressWarnings("unchecked") private static void registerMessage(Class message, Side side) { Instance.registerMessage(message, message, i, side); i++; } public static void sendToServer(IMessage message) { Instance.sendToServer(message); } public static void sendTo(IMessage message, EntityPlayerMP player) { Instance.sendTo(message, player); } public static void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { Instance.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } }