Search in sources :

Example 1 with PacketEnvironment

use of org.blockartistry.DynSurround.network.PacketEnvironment in project DynamicSurroundings by OreCruncher.

the class EnvironmentService method tickEvent.

@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.PlayerTickEvent event) {
    if (event.phase == Phase.END && event.side == Side.SERVER) {
        final EntityPlayer player = event.player;
        final VillageCollection villageCollection = player.getEntityWorld().getVillageCollection();
        boolean inVillage = false;
        if (villageCollection != null) {
            final List<Village> villages = villageCollection.getVillageList();
            if (villages != null && villages.size() > 0) {
                final BlockPos pos = player.getPosition();
                for (final Village v : villages) if (v.isBlockPosWithinSqVillageRadius(pos)) {
                    inVillage = true;
                    break;
                }
            }
        }
        final PacketEnvironment packet = new PacketEnvironment(inVillage);
        Network.sendToPlayer((EntityPlayerMP) player, packet);
    }
}
Also used : Village(net.minecraft.village.Village) PacketEnvironment(org.blockartistry.DynSurround.network.PacketEnvironment) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) VillageCollection(net.minecraft.village.VillageCollection) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Village (net.minecraft.village.Village)1 VillageCollection (net.minecraft.village.VillageCollection)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 PacketEnvironment (org.blockartistry.DynSurround.network.PacketEnvironment)1