NaturesAura/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java

37 lines
1.7 KiB
Java
Raw Normal View History

2018-10-14 14:27:18 +02:00
package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.NaturesAura;
2019-10-20 22:30:49 +02:00
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
2018-10-14 14:27:18 +02:00
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
2019-10-20 22:30:49 +02:00
import net.minecraftforge.api.distmarker.Dist;
2018-10-14 14:27:18 +02:00
public final class PacketHandler {
private static SimpleNetworkWrapper network;
public static void init() {
network = new SimpleNetworkWrapper(NaturesAura.MOD_ID);
2019-10-20 22:30:49 +02:00
network.registerMessage(PacketParticleStream.Handler.class, PacketParticleStream.class, 0, Dist.CLIENT);
network.registerMessage(PacketParticles.Handler.class, PacketParticles.class, 1, Dist.CLIENT);
network.registerMessage(PacketAuraChunk.Handler.class, PacketAuraChunk.class, 2, Dist.CLIENT);
network.registerMessage(PacketClient.Handler.class, PacketClient.class, 3, Dist.CLIENT);
2018-10-14 14:27:18 +02:00
}
public static void sendToAllLoaded(World world, BlockPos pos, IMessage message) {
network.sendToAllTracking(message, new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0));
}
2018-10-16 01:36:30 +02:00
public static void sendToAllAround(World world, BlockPos pos, int range, IMessage message) {
network.sendToAllAround(message, new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), range));
}
2019-10-20 22:30:49 +02:00
public static void sendTo(PlayerEntity player, IMessage message) {
network.sendTo(message, (ServerPlayerEntity) player);
}
2018-10-14 14:27:18 +02:00
}